Alternating between lists
Hi!
I'm about to run an experiment that uses a Latin Square. I've coded it with jsPsych. So far I've created four lists and pseudo-randomised them (as I want them pseudo-randomised). I want each participant to see only one list. The stimuli are sentences.
My first idea was to randomly shuffle between them, so that jsPsych would randomly assign a list to each participant. This method seems to work, but it is too random, and it would force me to discard a lot of data.
I tried to use Jatos' jatos.startNextComponent and assign conditions, but it doesn't work either: Jatos can't go from one component to the other. The same happens when I download the template (Randomize Tasks Between Workers) task from the website (and I have Jatos 3.8.4).
Then I tried to create different batch sessions, which got me a little bit further:
function initBatchConditions() { if (!jatos.batchSession.defined("/trials")) { jatos.batchSession.set("trials", 0).fail(initBatchConditions); } trials = jatos.batchSession.get("trials") jatos.batchSession.set("trials", trials + 1 ).fail(initBatchConditions); // If it fails: try again console.log(jatos.batchSession.getAll()); console.log(trials % groups.length); return trials; }
This gets part of the job done: it selects between the four lists of stimuli. The problem is that then I cannot get <\trials> to be a defined variable.
Something goes wrong here (I think):
//changing the appareance of buttons var btn_html = '<button class="jspsych-btn">%choice%</button>' //the actual survey var trial_structure = { type: jsPsychHtmlButtonResponse, prompt: "<p><em>Rate this sentence</em></p>", choices: ["1", "2", "3", "4", "5", "6", "7"], stimulus: jsPsych.timelineVariable("sentence"), button_html: ['<p>Unacceptable <button class="jspsych-btn">%choice%</button></p>', btn_html, btn_html, btn_html, btn_html, btn_html, '<p><button class="jspsych-btn">%choice%</button> Perfect</p>'] }; var trial_1 = { timeline: [trial_structure], timeline_variables: groups[trials % groups.length] //takes a random group, feeds the sentences to the survey }; timeline.push(trial_1)
Apologies for the confusion! It is my first time coding and I'm "learning on the job".
Thanks!! Any help would be hugely appreciated.
Gianluca
Comments
Hi Gianluca,
I didn't completely understand the third part of your question. I might be missing something obvious, but how does that relate to the batch session problem?
Either way, I don't see an obvious problem with your use of the batch session functions. In fact if I run your code on the console (from any random JATOS study), then
jatos.batchSession.defined("/trials")
returnstrue
.I also don't quite understand what didn't work with your first attempt. What do you mean, that jatos can't go from one component to the next? What error message do you get?
With this information, I might be able to help more. This should be more or less easy to solve, I just didn't understand your problem yet :)
Best
Elisa