You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on an experiment where I need to assign participants to different trial timelines based on their JATOS worker ID. The timelines are similar for each participant but the trials are in randomized orders and counter balanced. I aim to use the modulo operator to determine whether the participant should be in the 'even' or 'odd' condition (e.g., workerId % 2). However, I've encountered issues implementing this in my jsPsych setup.
Here's what I've tried so far:
Retrieving the JATOS worker ID using jatos.workerId
Tried to have two timelines and choose which timeline to use with an if clause ( if (workerId % 2){condition A} else{condition B}
using timeline.push conditional on the worker ID
Using the retrieved ID to conditionally add different timelines to jsPsych.addNodeToEndOfTimeline because I saw that recommended somewhere here on github; I placed the function both in the script and in the onload function of the last trial before I want the conditional timelines but this didn't work either. This is where I am currently at
Here’s a simplified version of my code:
var startMainExperiment = {
type: jsPsychHtmlButtonResponse,
choices: ['Begin Main Experiment'],
stimulus: '<p>Good job with the training! The main part of the experiment will start now. When you are ready, click the "Begin Main Experiment" button to proceed.</p>',
extensions: [
{type: jsPsychExtensionWebgazer, params: {
targets: ['#jspsych-image-button-response-stimulus', '.jspsych-btn']
},
},
{type: jsPsychExtensionMouseTracking}
],
on_finish: function(){
if (part_ID % 2 == 0){ //06/17
jsPsych.addNodeToEndOfTimeline(new_timeline_even)
}
else {
jsPsych.addNodeToEndOfTimeline(new_timeline_odd)
}
}
};
var allTrials_even = [
size_trial,
pre_ahead_right_1b_1c,
size_trial,
...
];
var allTrials_odd = [
size_trial,
pre_ahead_left_3b_5c, //these are the main experiment trials, I create them earlier by using a function
size_trial,
...
];
var new_timeline_even = {
timeline: [allTrials_even]
}
var new_timeline_odd = {
timeline: [allTrials_odd]
}
var finalTimeline = [
//instruction trials etc.
startMainExperiment
];
finalTimeline.push(survey)
finalTimeline.push(endStudy)
var part_ID;
jatos.onLoad(() => {
part_ID = jatos.workerId;
jsPsych.run(finalTimeline);
});
An alternative thing I was thinking was to use groups in JATOS or maybe a general file that you write to which handles the randomizations?
I would greatly appreciate any insights or examples from anyone who has tackled similar challenges. Thank you in advance for your time and help!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi jsPsych Community,
I am working on an experiment where I need to assign participants to different trial timelines based on their JATOS worker ID. The timelines are similar for each participant but the trials are in randomized orders and counter balanced. I aim to use the modulo operator to determine whether the participant should be in the 'even' or 'odd' condition (e.g., workerId % 2). However, I've encountered issues implementing this in my jsPsych setup.
Here's what I've tried so far:
Here’s a simplified version of my code:
An alternative thing I was thinking was to use groups in JATOS or maybe a general file that you write to which handles the randomizations?
I would greatly appreciate any insights or examples from anyone who has tackled similar challenges. Thank you in advance for your time and help!
Beta Was this translation helpful? Give feedback.
All reactions