// timing parameters: [length to show feedback, intertrial gap, optional length to display target]
// if optional length to display target is missing, then target is displayed until subject responds.
//TODO
// option to keep stim on screen during feedback
// way to provide corrective feedback
(function( $ ) {
jsPsych.categorize_multi = (function(){
var plugin = {};
plugin.create = function(params) {
cf_stims = params["stimuli"];
trials = new Array(cf_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "categorize_multi";
trials[i]["a_path"] = cf_stims[i];
trials[i]["choices"] = params["choices"];
trials[i]["answer_idx"] = params["answer_idx"][i];
trials[i]["text_answer"] = params["text_answer"][i];
trials[i]["correct_text"] = params["correct_text"];
trials[i]["incorrect_text"] = params["incorrect_text"];
trials[i]["show_stim_feedback"] = params["show_stim_feedback"] || true;
// timing params
trials[i]["timing_length_of_feedback"] = params["timing_length_of_feedback"] || 2000;
// opt params
if(params["prompt"] != undefined){
trials[i]["prompt"] = params["prompt"];
}
if(params["data"]!=undefined){
trials[i]["data"] = params["data"][i];
}
}
return trials;
}
// to save correct_answers between iterations of trial method...
var correct_answers = [];
plugin.trial = function($this, block, trial, part)
{
switch(part){
case 1:
// show image
$this.append($('
', {
"src": trial.a_path,
"class": 'cm'
}));
// hide image if the timing param is set.
if(trial.timing_show_image > 0)
{
setTimeout(function(){
$('.cm').css('visibility', 'hidden');
}, trial.timing_show_image);
}
// show prompt
$this.append(trial.prompt);
// start recording for RT
startTime = (new Date()).getTime();
// display button choices
// for each SET of choices
for(var i = 0; i', {
"id": "cm_"+i
}));
// for each INDIVIDUAL choice
for(var j = 0; j < trial.choices[i].length; j++)
{
// add a RADIO button
$('#cm_'+i).append($('', {
"type": "radio",
"name": "category_"+i,
"value": trial.choices[i][j],
"id": "cat_"+i+"_"+j
}));
$('#cm_'+i).append('');
}
}
// add a button to hit when done.
$this.append($('