/* jspsych plugin for categorization trials with feedback
* Josh de Leeuw
*
* display an image and then give corrective feedback based on the subject's response
*
* updated March 2013
*/
(function($) {
jsPsych.categorize_feedback = (function() {
var plugin = {};
plugin.create = function(params) {
var trials = [];
for (var i = 0; i < params.stimuli.length; i++) {
trials.push({});
trials[i].type = "categorize_feedback";
trials[i].a_path = params.stimuli[i];
trials[i].key_answer = params.key_answer[i];
trials[i].text_answer = params.text_answer[i];
trials[i].choices = params.choices;
trials[i].correct_text = params.correct_text;
trials[i].incorrect_text = params.incorrect_text;
// timing params
trials[i].timing_image = params.timing_image || -1; // default is to show image until response
trials[i].timing_feedback_duration = params.timing_feedback_duration || 2000;
trials[i].timing_post_trial = params.timing_post_trial || 1000;
// optional params
trials[i].show_stim_with_feedback = (typeof params.show_stim_with_feedback === 'undefined') ? true : params.show_stim_with_feedback;
trials[i].is_html = (typeof params.is_html === 'undefined') ? false : params.is_html;
trials[i].force_correct_button_press = (typeof params.force_correct_button_press === 'undefined') ? false : params.force_correct_button_press;
trials[i].prompt = (typeof params.prompt === 'undefined') ? '' : params.prompt;
trials[i].data = (typeof params.data === 'undefined') ? {} : params.data[i];
}
return trials;
};
var cf_trial_complete = false;
plugin.trial = function(display_element, block, trial, part) {
switch (part) {
case 1:
// set finish flag
cf_trial_complete = false;
if (!trial.is_html) {
// add image to display
display_element.append($('', {
"src": trial.a_path,
"class": 'cf',
"id": 'jspsych_cf_image'
}));
}
else {
display_element.append($('