Editing timeline variables based on info from JATOS #2077
-
Hi! This is a parallel thread to a question I posed on the JATOS forum over here. My immediate issue is that I have a timeline_variable array of 1085 objects, and I want to be able to shorten this array based on information from JATOS. Specifically, a few RA's are annotating a dataset, and I'm using JATOS's batch information to find what the index was of the last timeline_variable object that individual had annotated, then using .slice to update the length of the timeline_variable array so that it the already-annotated objects get dropped. However, the loop with the annotation task isn't getting this updated, shorter timeline_variable array; it's just getting the full one that was defined when the task started running. I tried using dynamic parameters to sort this out, but ended up replicating basically the same issue! :( Does anyone have advice about how to edit timeline variables based on info from JATOS? Here are the relevant bits of code, plus the complete jatos.onload chunk, which almost definitely has irrelevant information as well. :)
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @Kedersha, I wonder if the problem is that the jatos.onload(function() {
ra_num = jatos.studySessionData.ra_num;
//truncating the timeline_variables array to only the ones remaining for this RA
rec_ind = 0; //record index set to 0 by default
//if there is a value associated with this RA from previous runs, change rec_ind
ra_rec = jatos.batchSession.get("RA"+ra_num+"_record");
if(ra_rec){
rec_obj = timeline_variables.find(elem => elem.record === ra_rec);
rec_ind = timeline_variables.indexOf(rec_obj) + 1;
};
timeline_variables = timeline_variables.slice(rec_ind, timeline_variables.length); // modify the timeline variables array here
//VERY SIMPLIFIED version of the task
var node = {
timeline_variables: timeline_variables, // use the modified array here
timeline: [
type: 'survey-multi-choice',
preamble: function(){
return '<p>Record ID: '+jsPsych.timelineVariable('record', true)+'</p><p>Other data: '+jsPsych.timelineVariable('other-data', true)
},
questions: [{prompt: 'describe the other-data', name: 'description'}]
],
randomize_order: false,
repetitions: 1
}
jsPsych.init({
timeline: [RA_ID, node],
// etc. |
Beta Was this translation helpful? Give feedback.
-
Hi @becky-gilbert -- thanks for the rapid answer! I don't know why I assumed the jatos.onLoad chunk should follow the variables that make up my jsPsych study, but I definitely had been assuming that, and I definitely shouldn't have. :) It's working perfectly now, thanks again. |
Beta Was this translation helpful? Give feedback.
Hi @Kedersha, I wonder if the problem is that the
node
variable is created beforetimeline_variables
has been modified, so it's using the unmodified version. Would it work to just reorder things so that the modification totimeline_variables
comes before you set up thenode
trial procedure? Something like this: