Hi,
I am impmenting an experiment with jsPsych (version: 6.3.0) that should be hosted on Pavlovia with participants recruited from Prolific.
The trial order is set for every participant in a json file that I load with the jquery library, i.e. $.getJSON(...)
. Each trial file can only be used once, so participant 1 should get file 1, participant 2 → file 2, … (or randomized, but still I need to track which files were already used).
I thought of having another json file which keeps track of the file numbers used like this:
$.getJSON(`trials/used_trials.json`).done(function(used_trials){
const used_trial_nrs = used_trials.map(t => t.trial_file_nr);
const trials_to_delete = new Set(used_trial_nrs);
const all_trials = [...Array(100).keys()].map(String).map(n => lpad(n,3,0));
const available_trials = all_trials.filter((name) => {
return !trials_to_delete.has(name);
});
// create random number to choose from array of available stimuli files
const random = Math.floor(Math.random() * available_trials.length);
const rand_stim_nr_from_list = available_trials[random];
The issue I face is how to create this file, because obviously it is not allowed to write from the index-html to the pavlovia folder.
I thought of writing a monitoring watchdog event handler that reads out the trial file used from the saved data each time a new data file is added, but that would need to be writen in javascript as well, as python scripts are not allowed to run on pavlovia.
If the data-files could be saved to a MySQL table it would be possible to read out the file-information but as I understood that is not possible, right?
I also came across @wakecarters consecutive participant ID numbers webpage (https://moryscarter.com/vespr/pavlovia.php) which might be useful. If I get it right I would add this modified link https://moryscarter.com/vespr/pavlovia.php?folder=myfolder&experiment=experiment1 than to Prolific and could then read out from the URL the assigned participant number with jsPsych.data.getURLVariable("participant")
??
Any other ideas on how to solve this are highly appreciated!