-
Hello everyone, I am new to jsPsych. These days, I am going to conduct an experiment. This experiment involves letting participants watch several video trials. In each video trial, there exists dots movement. In some video trials, there exists a chasing behavior like a wolf chasing a sheep, while others doesn't. We are going to first let participants indicate if there exists such a chasing behavior. If participants answer yes, then they need to indicate which dot is wolf and which dot is sheep right after the first question being answered; if participants answer no, then they need to answer an attention check question. Below is my current code demo. For the moment, my question is that the code doesn't work in the conditional timeline module. That means, it can run but will skip "if_node" part. Can anyone give me some suggestions on that? `<script>
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @freewillbelief, Right now the I think putting the var attention = {
type: jsPsychHtmlButtonResponse,
stimulus: "<p>Which dot is <strong>green</strong>?</p>",
choices: ["1", "2", "3", "4", "5", "6"],
prompt: "<p>Please click the above button to answer the question.",
};
var if_node = {
timeline: [attention],
conditional_function: function () {
var data = jsPsych.data.get().last(1).values()[0];
if (jsPsych.pluginAPI.compareKeys(data.response, "f")) {
return false;
} else {
return true;
}
},
};
var video_trials = {
timeline: [
{
type: jsPsychVideoKeyboardResponse,
stimulus: jsPsych.timelineVariable("video"),
prompt:
"<p>Was there a wolf-sheep chasing? If yes, please press button <strong>F</strong>. Or <strong>J</strong> for no.</p>",
choices: ["f", "j"],
correct_response: jsPsych.timelineVariable("correct_response"),
response_allowed_while_playing: true,
response_ends_trial: true,
},
if_node, /** note the inclusion of the if_node here **/
{
type: jsPsychHtmlButtonResponse,
stimulus: "<p>Which dot is <strong>wolf</strong>?</p>",
choices: ["1", "2", "3", "4", "5", "6"],
prompt: "<p>Please click the above button to answer the question.",
},
{
type: jsPsychHtmlButtonResponse,
stimulus: "<p>Which dot is <strong>sheep</strong>?</p>",
choices: ["1", "2", "3", "4", "5", "6"],
prompt: "<p>Please click the above button to answer the question.",
},
],
timeline_variables: [
{ video: ["video/absent1.mp4"], correct_response: "j" },
{ video: ["video/absent2.mp4"], correct_response: "j" },
{ video: ["video/present1.mp4"], correct_response: "f" },
{ video: ["video/present2.mp4"], correct_response: "f" },
],
data: {
task: "response",
correct_response: jsPsych.timelineVariable("correct_response"),
},
on_finish: function (data) {
data.correct = jsPsych.pluginAPI.compareKeys(
data.response,
data.correct_response
);
},
randomize_order: true,
repetitions: 2,
}; In this version of the code the attention check should only run if they answer |
Beta Was this translation helpful? Give feedback.
Hi @freewillbelief,
Right now the
video_trials
will run before theif_node
, and thevideo_trials
includes the two questions about which dot is the wolf and the sheep. When theif_node
trial runs, thedata
value is the data from the last trial asking which dot is the sheep.I think putting the
if_node
as part of thevideo_trials
timeline will help solve the problem.