Can only define HTML using timeline variables within the entire test #1745
-
Hello, Here is my code. As you can see, it is made up of all the nested trials.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Ben! You can define trials as variables and then put them on a timeline: var fixation_cross = {
type: 'html-keyboard-response',
stimulus: '<div style="font-size:60px;">+</div>',
choices: jsPsych.NO_KEYS,
trial_duration: 1000
}
var audio_image_1 = {
type: 'audio-keyboard-response',
stimulus: jsPsych.timelineVariable('sound'),
choices: jsPsych.NO_KEYS,
prompt: function () {
var html = "<div class=wrapper><img src=" + jsPsych.timelineVariable('shape1') + " class=rotate class=box width=100 height=100 /><div style=font-size:60px;>+</div><img src=" + jsPsych.timelineVariable('shape2') + " class=rotate class=box width=100 height=100/></div>";
return html;
},
trial_duration: 2000,
}
var audio_image_2 = {
type: 'audio-keyboard-response',
stimulus: jsPsych.timelineVariable('sound'),
choices: ['f', 'j'],
prompt: function () {
var html = "<div class=wrapper><img src=" + jsPsych.timelineVariable('shape1') + " class=box width=100 height=100 /><div style=font-size:60px;>+</div><img src=" + jsPsych.timelineVariable('shape2') + " class=box width=100 height=100/></div>";
return html;
}
}
var conditional_audio_image_1 = {
timeline: [
{
type: 'audio-keyboard-response',
stimulus: jsPsych.timelineVariable('sound'),
choices: jsPsych.NO_KEYS,
prompt: function () {
var html = "<div class=wrapper><img src=" + jsPsych.timelineVariable('shape1') + " class=rotate class=box width=100 height=100 /><div style=font-size:60px;>+</div><img src=" + jsPsych.timelineVariable('shape2') + " class=box width=100 height=100/></div>";
return html;
},
trial_duration: 1000,
}],
conditional_function: function () {
// get the data from the previous trial,
// and check which key was pressed
var data = jsPsych.data.get().last(1).values()[0];
if (jsPsych.pluginAPI.compareKeys(data.response, 'f')) {
return true;
} else {
return false;
}
}
}
var conditional_audio_image_2 = {
timeline: [
{
type: 'audio-keyboard-response',
stimulus: jsPsych.timelineVariable('sound'),
choices: jsPsych.NO_KEYS,
prompt: function () {
var html = "<div class=wrapper><img src=" + jsPsych.timelineVariable('shape1') + " class=box width=100 height=100 /><div style=font-size:60px;>+</div><img src=" + jsPsych.timelineVariable('shape2') + " class=rotate class=box width=100 height=100/></div>";
return html;
},
trial_duration: 1000,
}],
conditional_function: function () {
// get the data from the previous trial,
// and check which key was pressed
var data = jsPsych.data.get().last(1).values()[0];
if (jsPsych.pluginAPI.compareKeys(data.response, 'j')) {
return true;
} else {
return false;
}
}
}
var test_procedure = {
timeline: [fixation_cross, audio_image_1, audio_image_2, conditional_audio_image_1, conditional_audio_image_2],
timeline_variables: [
{ sound: 'sound/teetee.wav', shape1: "img/bouba_3_L.png", shape2: "img/kiki_3_L.png" },
{ sound: 'sound/keekee.wav', shape1: "img/kiki_3_L.png", shape2: "img/bouba_3_L.png" }
]
} The timeline variables will still work because the trials are being executed in the context of |
Beta Was this translation helpful? Give feedback.
Hi Ben!
You can define trials as variables and then put them on a timeline: