/** * jspsych plugin for categorization trials with feedback * Josh de Leeuw * * documentation: docs.jspsych.org **/ jsPsych.plugins['categorize-image'] = (function() { var plugin = {}; jsPsych.pluginAPI.registerPreload('categorize-image', 'stimulus', 'image'); plugin.info = { name: 'categorize-image', description: '', parameters: { stimulus: { type: jsPsych.plugins.parameterType.IMAGE, default: undefined, no_function: false, description: '' }, key_answer: { type: jsPsych.plugins.parameterType.KEYCODE, default: undefined, no_function: false, description: '' }, choices: { type: jsPsych.plugins.parameterType.KEYCODE, default: jsPsych.ALL_KEYS, array: true, no_function: false, description: '' }, text_answer: { type: jsPsych.plugins.parameterType.STRING, default: '', no_function: false, description: '' }, correct_text: { type: jsPsych.plugins.parameterType.STRING, default: 'Correct.', no_function: false, description: '' }, incorrect_text: { type: jsPsych.plugins.parameterType.STRING, default: 'Wrong.', no_function: false, description: '' }, prompt: { type: jsPsych.plugins.parameterType.STRING, default: '', no_function: false, description: '' }, force_correct_button_press: { type: jsPsych.plugins.parameterType.BOOL, default: false, no_function: false, description: '' }, show_stim_with_feedback: { type: jsPsych.plugins.parameterType.BOOL, default: true, no_function: false, description: '' }, show_feedback_on_timeout: { type: jsPsych.plugins.parameterType.BOOL, default: false, no_function: false, description: '' }, timeout_message: { type: jsPsych.plugins.parameterType.STRING, default: 'Please respond faster.', no_function: false, description: '' }, stimulus_duration: { type: jsPsych.plugins.parameterType.INT, default: -1, no_function: false, description: '' }, trial_duration: { type: jsPsych.plugins.parameterType.INT, default: -1, no_function: false, description: '' }, feedback_duration: { type: jsPsych.plugins.parameterType.INT, default: 2000, no_function: false, description: '' } } } plugin.trial = function(display_element, trial) { // default parameters trial.choices = trial.choices || jsPsych.ALL_KEYS; trial.text_answer = (typeof trial.text_answer === 'undefined') ? "" : trial.text_answer; trial.correct_text = (typeof trial.correct_text === 'undefined') ? "
Correct
" : trial.correct_text; trial.incorrect_text = (typeof trial.incorrect_text === 'undefined') ? "Incorrect
" : trial.incorrect_text; trial.show_stim_with_feedback = (typeof trial.show_stim_with_feedback === 'undefined') ? true : trial.show_stim_with_feedback; trial.force_correct_button_press = (typeof trial.force_correct_button_press === 'undefined') ? false : trial.force_correct_button_press; trial.prompt = (typeof trial.prompt === 'undefined') ? '' : trial.prompt; trial.show_feedback_on_timeout = (typeof trial.show_feedback_on_timeout === 'undefined') ? false : trial.show_feedback_on_timeout; trial.timeout_message = trial.timeout_message || "Please respond faster.
"; // timing params trial.stimulus_duration = trial.stimulus_duration || -1; // default is to show image until response trial.trial_duration = trial.trial_duration || -1; // default is no max response time trial.feedback_duration = trial.feedback_duration || 2000; display_element.innerHTML = '