fail to create a repeat practice conditional #1026
-
Hello jsPsych team! Thank you so much for the workshops and tutorial videos. I am creating a reading experiment, referencing @jodeleeuw 's moving window script and the script for the semantic relatedness experiment that @becky-gilbert demonstrated in https://www.youtube.com/watch?v=LP7o0iAALik. However, I failed to replicate a repeat_practice conditional for my experiment. I've checked it using the developer tool, and here's the error message that I got: I think that there's something wrong regarding how I define the variable of the last_prac_trails, especially the filter part, but I am not sure how to fix it. I was wondering if you could take a look at my script and give me some suggestions on how to revise it. Any comments or suggestions would be greatly appreciated. `
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Yes you're right, the issues is with how you're defining Instead, inside the filter function, you should provide some key-value pair(s) that uniquely identify all of the practice trial data. You could filter on the trial type being "html-keyboard-response", but that would select both the So one way to do this is to first add a 'flag' to the var practice_question = {
...
data: {
trial_part: "practice_question",
correct_response: jsPsych.timelineVariable("correct_response"),
stimulus: jsPsych.timelineVariable("stimulus"),
question: jsPsych.timelineVariable("question")
},
...
}; Then, in your conditional function, you can filter the data on var last_prac_trials = jsPsych.data.get().filter({trial_part: 'practice_question'}).last(practice_question.length); Does that do what you need? |
Beta Was this translation helpful? Give feedback.
-
Ah, sorry, that was my fault - I told you to add the data to the practice trials like this: data: {
trial_part: "practice_question",
correct_response: jsPsych.timelineVariable("correct_response"),
stimulus: jsPsych.timelineVariable("stimulus"),
question: jsPsych.timelineVariable("question")
} But that doesn't work because, in your I think the easiest solution is to remove the nested structure from your objects in your var practice_stimuli = [
{ words: [, 'A', 'cat', 'was', 'chasing', 'a', 'dog.'], question: "A dog was chased by a cat.", correct_response: "j", stimulus: "a/cat/was/chasing/a/dog", question: "A dog was chased by a cat." },
{ words: [, 'A', 'cat', 'was', 'chasing', 'a', 'mouse'], question: "A mouse was chased by a cow.", correct_response: "f", stimulus: "a/cat/was/chasing/a/cow", question: "A cat was chased by a cow." },
{ words: [, 'A', 'thief', 'was', 'chasing', 'a', 'cop.'], question: "A cop was chased by a thief.", correct_response: "j", stimulus: "a/thief/was/chasing/a/cop", question: "A cop was chased by a thief." },
]; A second issue is that, inside of your var prop_corr = n_correct / practice_stimuli.length; I hope that helps! Let us know if it's working now. |
Beta Was this translation helpful? Give feedback.
Ah, sorry, that was my fault - I told you to add the data to the practice trials like this:
But that doesn't work because, in your
practice_stimuli
array, thecorrect_response
andstimulus
keys are nested inside of thedata
key, which means that they can't be accessed by thejsPsych.timelineVariable
function. So the reason that your responses were always scored as incorrect is becausecorrect_response
was never stored in the trial data.I think the easiest solution is to remove the …