-
Hi Team, I'm running a task using the image-button-response plugin to have participants choose an odd one out. I've set my trials to time out after a certain interval using trial_duration, but I want to display a trial that gives a message to the user in the event of timeout. I've tried to do use a conditional function that triggers the timeout message if the previous trial's response time is null, but I think I'm calling for the response time in the conditional function incorrectly, because my if statement always evaluates as null and I get the timeout message both on trials where no choice was made and on trials where a choice was made in time. My trials are coded as follows: var test = {
type: "image-button-response",
stimulus: jsPsych.timelineVariable('stimulus'),
choices: jsPsych.timelineVariable('choices'),
button_html: jsPsych.timelineVariable('button_html'),
prompt: "<span style='font-size:2vw;'><p>Click the image that does not belong.</p></span>", // prompt specified in general procedure b/c it does not vary across trials
data: jsPsych.timelineVariable('data'),
/* Not the function in question, checks whether response matched expected response and prints
accuracy in trial data. */
on_finish: check_choice_correct,
trial_duration: 30000,
post_trial_gap: 600,
}
/* A message to give to the user if a test trial times out. */
var timeout_message = {
type: 'html-button-response',
stimulus: "<span style='font-size:2vw;'><p>It seems like you're unsure about that one.</p><p>That's okay, try the next one!</p></span>",
choices: ['Next >'],
button_html: '<button style="position:fixed; width:8vw; left:calc(50vw - 6vw); bottom:0; margin:2vw;" class="jspsych-btn"; onclick=bloop.play()>%choice%</button>', // specify width as percentage of screen width, calc for left should be 50vw (50% across screen) minus half button width and margin width
data: {
test_part: 'timeout_message',
}
};
/* Conditional procedure; run timeout_message if check_trial_null function
returns true. See the conditional function below. */
var timeout_conditional = {
timeline: [timeout_message],
conditional_function: check_trial_null //the conditional function in question
};
/* Test trial timeline. */
var test_procedure = {
timeline: [mouse_to_bottom, test, timeout_conditional],
timeline_variables: test_stimuli,
randomize_order: true, // randomize order of trials in test_stimuli
}
timeline.push(test_procedure); And this is what I have for the conditional function that isn't working so far: /* Conditional function to evaluate whether last trial was null. */
function check_trial_null(data) {
var last_test_trial = jsPsych.data.getLastTrialData();
if (last_test_trial.rt == null) {
return true;
} else {
return false;
};
}; I'd appreciate any suggestions, I'm pretty new to this all and I imagine I'm missing something obvious. :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've got it! I just had to extract the actual value for rt from the last test trial. var last_test_trial = jsPsych.data.getLastTrialData().values()[0].rt; |
Beta Was this translation helpful? Give feedback.
I've got it! I just had to extract the actual value for rt from the last test trial.