-
I'm trying to evaluate the response accuracy of practice trials and repeat if the participants don't pass a threshold. I ran into a few problems:
I feel I might have made a silly mistake somewhere but I cannot figure out where. I'd appreciate some feedback very much!
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @y-j-huang , It looks like your timeline variables array is not quite right. You've currently got it as: var practice_info = [
{
questions: [
{prompt: "I like vegetables", name: 'Vegetables', options: ["Yes", "No"], correct_response: "Yes", required: true}
]
},
{
questions: [
{prompt: "I like fruits", name: 'Fruits', options: ["Yes", "No"], correct_response: "Yes", required: true}
]
}
]; I added some indentation to make the structure of the variable clear. With this structure there is only 1 timeline variable per trial: You'll want to move the var practice_info = [
{
questions: [
{prompt: "I like vegetables", name: 'Vegetables', options: ["Yes", "No"], required: true}
],
correct_response: "Yes",
},
{
questions: [
{prompt: "I like fruits", name: 'Fruits', options: ["Yes", "No"], required: true}
],
correct_response: "Yes",
}
]; Note that the way you've defined the trial object is also not quite right: var practice_trial = {
type: 'survey-multi-choice',
questions: jsPsych.timelineVariable('questions'),
prompt: jsPsych.timelineVariable('prompt'),
options: jsPsych.timelineVariable('options'),
required: jsPsych.timelineVariable('required'),
data:{trial_part: 'practice',
correct_response: jsPsych.timelineVariable('correct_response')},
on_finish: function(data) {
var acc = false;
if (data.correct_response == data.responses) {
acc = true;
}
data.accuracy = acc;
console.log(data.correct_response);
}
}; The var practice_trial = {
type: 'survey-multi-choice',
questions: jsPsych.timelineVariable('questions'),
data: {
trial_part: 'practice',
correct_response: jsPsych.timelineVariable('correct_response')
},
on_finish: function(data) {
var acc = false;
if (data.correct_response == data.responses) {
acc = true;
}
data.accuracy = acc;
console.log(data.correct_response);
}
}; |
Beta Was this translation helpful? Give feedback.
Hi @y-j-huang ,
It looks like your timeline variables array is not quite right. You've currently got it as:
I added some indentation to make the structure of the variable clear. With this structure there is only 1 timeline variable per trial:
questions
. Everything else is nested within thequestions
variable.You'll want to move the
correct_response
option out of this variable: