From 75dc0e8b571a6d2a30ce4ed64dfa230cc2e53e03 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Mon, 28 Apr 2014 16:47:15 -0400 Subject: [PATCH 1/4] Adding enforceArray method --- jspsych.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/jspsych.js b/jspsych.js index 70c44d8e..88e039c2 100755 --- a/jspsych.js +++ b/jspsych.js @@ -223,6 +223,11 @@ }; + // + // These are public functions, intended to be used for developing plugins. + // They aren't considered part of the normal API for the core library. + // + core.normalizeTrialVariables = function(trial){ var keys = getKeys(trial); @@ -239,6 +244,23 @@ return tmp; } + + // if possible_array is not an array, then return a one-element array + // containing possible_array + core.enforceArray = function(possible_array) { + + // function to check if something is an array, fallback + // to string method if browser doesn't support Array.isArray + var ckArray = Array.isArray || function(a) { + return toString.call(a) == '[object Array]'; + } + + if(ckArray(possible_array)){ + return(possible_array); + } else { + return([possible_array]); + } + } // // private functions // From efed8009a1c9c924178680ddde13b4001b4c3556 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Mon, 19 May 2014 10:06:21 -0400 Subject: [PATCH 2/4] delete files - from master merge --- plugins/dev/jspsych-active-match.js | 174 --------- .../dev/jspsych-adaptive-category-train.js | 355 ------------------ plugins/dev/jspsych-ballistic-match-2.js | 223 ----------- plugins/dev/jspsych-ballistic-match.js | 227 ----------- plugins/dev/jspsych-categorize-multi.js | 182 --------- plugins/dev/jspsych-paint.js | 186 --------- plugins/dev/jspsych-samedifferentloc.js | 144 ------- plugins/dev/jspsych-staircase-categorize.js | 248 ------------ plugins/dev/jspsych-staircase-xab.js | 223 ----------- plugins/dev/jspsych-storybook.js | 82 ---- plugins/dev/jspsych-touch-freepick.js | 89 ----- plugins/dev/jspsych-twoimage-keyresponse.js | 110 ------ plugins/dev/jspsych-xab-touch.js | 96 ----- 13 files changed, 2339 deletions(-) delete mode 100644 plugins/dev/jspsych-active-match.js delete mode 100644 plugins/dev/jspsych-adaptive-category-train.js delete mode 100644 plugins/dev/jspsych-ballistic-match-2.js delete mode 100644 plugins/dev/jspsych-ballistic-match.js delete mode 100644 plugins/dev/jspsych-categorize-multi.js delete mode 100644 plugins/dev/jspsych-paint.js delete mode 100644 plugins/dev/jspsych-samedifferentloc.js delete mode 100644 plugins/dev/jspsych-staircase-categorize.js delete mode 100644 plugins/dev/jspsych-staircase-xab.js delete mode 100644 plugins/dev/jspsych-storybook.js delete mode 100644 plugins/dev/jspsych-touch-freepick.js delete mode 100644 plugins/dev/jspsych-twoimage-keyresponse.js delete mode 100644 plugins/dev/jspsych-xab-touch.js diff --git a/plugins/dev/jspsych-active-match.js b/plugins/dev/jspsych-active-match.js deleted file mode 100644 index cbc0b815..00000000 --- a/plugins/dev/jspsych-active-match.js +++ /dev/null @@ -1,174 +0,0 @@ -(function( $ ) { - jsPsych.active_match = (function(){ - - var plugin = {}; - - plugin.create = function(params) { - stims = params["stimuli"]; - trials = new Array(stims.length); - for(var i = 0; i < trials.length; i++) - { - trials[i] = {}; - trials[i]["type"] = "active_match"; - trials[i]["target_idx"] = params["target_idx"][i]; - trials[i]["start_idx"] = params["start_idx"][i]; - trials[i]["stimuli"] = params["stimuli"][i]; - trials[i]["timing"] = params["timing"]; - trials[i]["key_dec"] = params["key_dec"]; - trials[i]["key_inc"] = params["key_inc"]; - if(params["prompt"] != undefined){ - trials[i]["prompt"] = params["prompt"]; - } - if(params["data"]!=undefined){ - trials[i]["data"] = params["data"][i]; - } - } - return trials; - } - - // data to keep track of - var responses = []; - var last_response_time = 0; - var start_time = 0; - var direction_changes = 0; - var last_response = -1; - - plugin.trial = function(display_element, block, trial, part) - { - switch(part){ - case 1: - // reset response variables - responses = []; - last_response_time = 0; - start_time = 0; - direction_changes = 0; - last_response = -1; - - // starting new trial - start_time = (new Date()).getTime(); - last_response_time = start_time; - - current_idx = trial.start_idx; - - // show target image - display_element.append($('', { - "src": trial.stimuli[trial.target_idx], - "class": '', - "id": 'am_target' - })); - - // show manipulate image - display_element.append($('', { - "src": trial.stimuli[trial.start_idx], - "class": '', - "id": 'am_manipulate' - })); - - // append a div for showing messages - display_element.append($('
', { - "id": 'am_message_box' - })); - - if(trial.prompt) - { - display_element.append(trial.prompt); - } - - // add function on keypress to control manipulate image - // pressing key_dec will move the index down - // pressing key_inc will move the index up - - var resp_func = function(e) { - var change = 0; - var valid_response = false; - if(e.which == trial.key_dec) - { - change = -1; - valid_response = true; - } else if (e.which == trial.key_inc) - { - change = 1; - valid_response = true; - } - - if(valid_response){ - var resp_time = (new Date()).getTime(); - var response = {"key": e.which, "rt": (resp_time-last_response_time)}; - responses.push(response); - - if(e.which != last_response && last_response != -1) - { - direction_changes++; - } - - last_response = e.which; - last_response_time = resp_time; - - var next_idx = current_idx + change; - if(next_idx < 0) { - // can't do this - if($('#am_message_box').children().length == 0) - { - $('#am_message_box').append("

Minimum value reached. Go the other direction.

"); - } - next_idx = 0; - } else if(next_idx == trial.stimuli.length) { - // can't do this - if($('#am_message_box').children().length == 0) - { - $('#am_message_box').append("

Maximum value reached. Go the other direction.

"); - } - next_idx = current_idx; - } else { - // update current_idx - current_idx = next_idx; - - $("#am_message_box").html(''); - - // change the image - $("#am_manipulate").attr("src",trial.stimuli[current_idx]); - } - - if(current_idx == trial.target_idx) - { - // unbind response function to prevent further change - $(document).unbind('keyup',resp_func); - // match! - plugin.trial(display_element, block, trial, part + 1); - - } - } - } - - $(document).keyup(resp_func); - break; - - case 2: - $("#am_target").addClass('matched'); - $("#am_manipulate").addClass('matched'); - - var key_responses_string = ""; - var rt_responses_string = ""; - for(var i=0;i -1 && this.blocks_under_thresh >=stop_criteria) - { - // end training due to failure to learn - - block.next(); - } else { - if(this.remaining_items.length > 0) - { - if(this.remaining_items.length < min_per_block) - { - shuffle(this.complete_items); - for( var i = 0; this.remaining_items.length < min_per_block; i++) - { - this.remaining_items.push(this.complete_items[i]); - } - } - // present remaining items in random order - shuffle(this.remaining_items); - var iterator = new TrialIterator(display_element, this.remaining_items, this, block, this.curr_block); - this.curr_block++; - var updated_trials = iterator.next(); // when this finishes, all trials are complete. - // updated_trials will have the updated consecutive correct responses - - } else { - // end training - block.next(); - } - } - } - - this.round_complete = function(trials) - { - // check items for threshold and remove items where consecutive responses has been reached - var cont_trials = []; - - this.remaining_items = trials; - var score_denominator = this.remaining_items.length; - var score_numerator = 0; - - - for(var i=0; i 0) - { - score_numerator++; - } - } - - var percent_correct = Math.round((score_numerator / score_denominator)*100); - - if(percent_correct < min_percent_correct){ - this.blocks_under_thresh++; - } else { - this.blocks_under_thresh = 0; - } - - for(var i=0; i=min_percent_correct){ - // newly completed item - this.remaining_items[i].complete = true; - this.complete_items.push(this.remaining_items[i]); - } else { - cont_trials.push(this.remaining_items[i]); - } - } - } - } - - this.remaining_items = cont_trials; - - var remaining_objects = this.remaining_items.length; - var completed_objects = this.total_items - remaining_objects; - - - if(show_progress) - { - this.display_progress(completed_objects, remaining_objects, score_numerator, score_denominator); - } else { - // call next round - this.next_round(); - } - } - - this.display_progress = function(completed_objects, remaining_objects, score_numerator, score_denominator, blocks_under_criteria) - { - var completed = ''; - - var percent_correct = Math.round((score_numerator / score_denominator)*100); - - if(percent_correct < min_percent_correct) - { - completed = '

You need to categorize at least '+min_percent_correct+'% of the items correctly in each round in order to make progress in training.

' - if(stop_criteria > -1) { - var remaining_blocks = stop_criteria - this.blocks_under_thresh; - if(remaining_blocks >= 1){ - completed += '

If you continue to have an accuracy below '+min_percent_correct+'% for '+remaining_blocks+' more round(s) of training, then training will stop and you will not be eligible for the bonus payment.

' - } else { - completed += '

Training will now stop because your accuracy was below '+min_percent_correct+'% for '+stop_criteria+' consecutive rounds.

' - } - } - - } else { - if(remaining_objects == 0) - { - completed = '

Congratulations! You have completed training.

'; - } - else if(completed_objects > 0) - { - completed = '

You have correctly categorized '+completed_objects+' item(s) in '+min_correct+' consecutive rounds. You need to correctly categorize '+remaining_objects+ - ' more item(s) in '+min_correct+' consecutive rounds to complete training. Items that you have correctly identified in '+min_correct+' consecutive rounds will not be shown as frequently.

'; - } - else - { - completed = '

Good job! You need to categorize an item correctly in '+min_correct+' consecutive rounds to finish training for that item. Once you have finished training for all items the next part of the experiment will begin.

'; - } - } - - display_element.html( - '

You correctly categorized '+percent_correct+'% of the items in that round.

'+completed+'

Press ENTER to continue.

' - ); - - var controller = this; - - var key_listener = function(e) { - if(e.which=='13') - { - $(document).unbind('keyup',key_listener); // remove the response function, so that it doesn't get triggered again. - display_element.html(''); // clear the display - setTimeout(function(){controller.next_round();}, this.timing_post_trial); // call block.next() to advance the experiment after a delay. - } - } - $(document).keyup(key_listener); - } - } - - function TrialIterator(display_element, trials, controller, block, block_idx){ - this.trials = trials; - this.curr_trial = 0; - this.curr_block = block_idx; - - this.next = function() { - if(this.curr_trial >= this.trials.length) - { - // call function in the controller - controller.round_complete(trials); - } else { - this.do_trial(this.trials[this.curr_trial], this.curr_trial, this.curr_block); - } - } - - this.do_trial = function(trial, t_idx, b_idx) - { - // do the trial! - - // show the image - display_element.append($('', { - "src": trial.a_path, - "class": 'cf' - })); - - display_element.append(trial.prompt); - - startTime = (new Date()).getTime(); - - // get response - var resp_func = function(e) { - var flag = false; - var correct = false; - if(e.which==trial.correct_key) // correct category - { - flag = true; - correct = true; - } - else - { - // check if the key is any of the options, or if it is an accidental keystroke - for(var i=0;i', { - "src": trial.a_path, - "class": 'cf' - })); - - // give feedback - var atext = ""; - if(is_correct) - { - atext = trial.correct_text.replace("&ANS&", trial.text_answer); - } else { - atext = trial.incorrect_text.replace("&ANS&", trial.text_answer); - } - display_element.append(atext); - setTimeout(function(){finish_trial(iterator_object);}, trial.timing_display_feedback); - } - - function finish_trial(iterator_object){ - display_element.html(''); - - setTimeout(function(){ - iterator_object.curr_trial++; - iterator_object.next(); - }, trial.timing_post_trial); - } - } - } - - function shuffle(array) { - var tmp, current, top = array.length; - - if(top) while(--top) { - current = Math.floor(Math.random() * (top + 1)); - tmp = array[current]; - array[current] = array[top]; - array[top] = tmp; - } - - return array; - } - - return plugin; - })(); -})(jQuery); diff --git a/plugins/dev/jspsych-ballistic-match-2.js b/plugins/dev/jspsych-ballistic-match-2.js deleted file mode 100644 index eede0a79..00000000 --- a/plugins/dev/jspsych-ballistic-match-2.js +++ /dev/null @@ -1,223 +0,0 @@ -(function( $ ) { - jsPsych.ballistic_match = (function(){ - - var plugin = {}; - - plugin.create = function(params) { - stims = params["stimuli"]; - trials = new Array(stims.length); - for(var i = 0; i < trials.length; i++) - { - trials[i] = {}; - trials[i]["type"] = "ballistic_match"; - trials[i]["target_idx"] = params["target_idx"][i]; - trials[i]["start_idx"] = params["start_idx"][i]; - trials[i]["stimuli"] = params["stimuli"][i]; - trials[i]["timing"] = params["timing"]; - trials[i]["key_dec"] = params["key_dec"]; - trials[i]["key_inc"] = params["key_inc"]; - trials[i]["animate_frame_time"] = params["animate_frame_time"] || 100; - if(params["prompt"] != undefined){ - trials[i]["prompt"] = params["prompt"]; - } - if(params["data"]!=undefined){ - trials[i]["data"] = params["data"][i]; - } - } - return trials; - } - - - var change = 0; // which direction they indicated the stim should move. - var start_time; - var end_time; - - plugin.trial = function(display_element, block, trial, part) - { - switch(part){ - case 1: - // starting new trial - start_time = (new Date()).getTime(); - change = 0; - - // show manipulate image - display_element.append($('', { - "src": trial.stimuli[trial.start_idx], - "class": 'bm_img', - "id": 'bm_manipulate' - })); - - // show target image - display_element.append($('', { - "src": trial.stimuli[trial.target_idx], - "class": 'bm_img', - "id": 'bm_target' - })); - - if(trial.prompt) - { - display_element.append(trial.prompt); - } - - // categorize the image. - - var resp_func = function(e) { - var valid_response = false; - if(e.which == trial.key_dec) - { - change = -1; - valid_response = true; - } else if (e.which == trial.key_inc) - { - change = 1; - valid_response = true; - } - - if(valid_response){ - end_time = (new Date()).getTime(); - plugin.trial(display_element,block,trial,part+1); - $(document).unbind('keyup', resp_func); - } - } - - $(document).keyup(resp_func); - break; - case 2: - // clear everything - display_element.html(''); - setTimeout(function(){plugin.trial(display_element, block, trial, part + 1);}, trial.timing[1]); - break; - case 3: - // draw trajectory - draw_trajectory(display_element, - trial.stimuli[trial.target_idx], - trial.stimuli[trial.start_idx], - trial.target_idx/(trial.stimuli.length-1), - trial.start_idx/(trial.stimuli.length-1)); - - display_element.append($('
',{ - "id":"bm_feedback", - })); - - if(change>0) { - $("#bm_feedback").html('

You said increase.

'); - } else { - $("#bm_feedback").html('

You said decrease.

'); - } - - setTimeout(function(){plugin.trial(display_element, block, trial, part + 1);}, trial.timing[1]*3); - break; - case 4: - var curr_loc = trial.start_idx - animate_interval = setInterval(function(){ - - // clear everything - display_element.html(''); - // draw trajectory - draw_trajectory(display_element, - trial.stimuli[trial.target_idx], - trial.stimuli[curr_loc], - trial.target_idx/(trial.stimuli.length-1), - curr_loc/(trial.stimuli.length-1)); - - curr_loc += change; - - - if(curr_loc - change == trial.target_idx || curr_loc < 0 || curr_loc == trial.stimuli.length) - { - clearInterval(animate_interval); - var correct = false; - if(change > 0 && trial.start_idx < trial.target_idx) { correct = true; } - if(change < 0 && trial.start_idx > trial.target_idx) { correct = true; } - - display_element.append($('
',{ - "id":"bm_feedback", - })); - if(correct){ - $("#bm_feedback").html('

Correct!

'); - } else { - $("#bm_feedback").html('

Wrong.

'); - } - setTimeout(function(){plugin.trial(display_element, block, trial, part + 1);}, trial.timing[1]*3); - } - }, trial.animate_frame_time); - break; - case 5: - display_element.html(''); - var correct = false; - if(change > 0 && trial.start_idx < trial.target_idx) { correct = true; } - if(change < 0 && trial.start_idx > trial.target_idx) { correct = true; } - - var trial_data = {"start_idx":trial.start_idx, "target_idx": trial.target_idx, "correct": correct, "rt": (end_time-start_time)}; - block.data[block.trial_idx] = $.extend({},trial_data,trial.data); - - setTimeout(function(){block.next();}, trial.timing[0]); - break; - } - } - - function draw_trajectory(display_element,target_img, moving_img, target_loc_percent, marker_loc_percent) - { - // display the image as it morphs - display_element.append($('',{ - "src": moving_img, - "id": "moving_image" - })); - - // show the linear trajectory below - - display_element.append($('
', { - "id": "trajectory"})); - - $("#trajectory").append($('
', { - "id": "line"})); - - // display the images on the trajectory - $("#trajectory").append($('
', { - "id": "target_flag"})); - - $("#target_flag").append($('
', { - "id": "target_dot"})); - - $("#target_flag").append($('
', { - "id": "target_words"})); - - $("#target_words").html("

Target Cell

"); - - $("#trajectory").append($('
', { - "id": "marker_flag"})); - - $("#marker_flag").append($('
', { - "id": "marker_dot"})); - - $("#marker_flag").append($('
', { - "id": "marker_words"})); - - $("#marker_words").html("

Above Cell

"); - - // label the trajectory line - $("#trajectory").append($('', { - "id": "left_label"})); - - $("#trajectory").append($('', { - "id": "right_label"})); - - $("#left_label").html("Less Chemical X"); - $("#right_label").html("More Chemical X"); - - // set the location of the flags on the line - var dot_width = parseInt($("#marker_dot").css('width')); - var line_width = parseInt($("#line").css('width')); - - var target_flag_left = (line_width- dot_width) * target_loc_percent; - var marker_flag_left = (line_width- dot_width) * marker_loc_percent; - - $("#marker_flag").css('left', marker_flag_left); - $("#target_flag").css('left', target_flag_left); - - - } - - return plugin; - })(); -})(jQuery); \ No newline at end of file diff --git a/plugins/dev/jspsych-ballistic-match.js b/plugins/dev/jspsych-ballistic-match.js deleted file mode 100644 index 8bd3f6ea..00000000 --- a/plugins/dev/jspsych-ballistic-match.js +++ /dev/null @@ -1,227 +0,0 @@ -(function( $ ) { - jsPsych.ballistic_match = (function(){ - - var plugin = {}; - - plugin.create = function(params) { - stims = params["stimuli"]; - trials = new Array(stims.length); - for(var i = 0; i < trials.length; i++) - { - trials[i] = {}; - trials[i]["type"] = "ballistic_match"; - trials[i]["target_idx"] = params["target_idx"][i]; - trials[i]["start_idx"] = params["start_idx"][i]; - trials[i]["stimuli"] = params["stimuli"][i]; - trials[i]["timing"] = params["timing"]; - trials[i]["key_dec"] = params["key_dec"]; - trials[i]["key_inc"] = params["key_inc"]; - trials[i]["animate_frame_time"] = params["animate_frame_time"] || 100; - if(params["prompt"] != undefined){ - trials[i]["prompt"] = params["prompt"]; - } - if(params["data"]!=undefined){ - trials[i]["data"] = params["data"][i]; - } - } - return trials; - } - - - var change = 0; // which direction they indicated the stim should move. - var start_time; - var end_time; - - plugin.trial = function(display_element, block, trial, part) - { - switch(part){ - case 1: - // starting new trial - start_time = (new Date()).getTime(); - change = 0; - - // show manipulate image - display_element.append($('', { - "src": trial.stimuli[trial.start_idx], - "class": 'bm_img', - "id": 'bm_manipulate' - })); - - // show target image - display_element.append($('', { - "src": trial.stimuli[trial.target_idx], - "class": 'bm_img', - "id": 'bm_target' - })); - - if(trial.prompt) - { - display_element.append(trial.prompt); - } - - // categorize the image. - - var resp_func = function(e) { - var valid_response = false; - if(e.which == trial.key_dec) - { - change = -1; - valid_response = true; - } else if (e.which == trial.key_inc) - { - change = 1; - valid_response = true; - } - - if(valid_response){ - end_time = (new Date()).getTime(); - plugin.trial(display_element,block,trial,part+1); - $(document).unbind('keyup', resp_func); - } - } - - $(document).keyup(resp_func); - break; - case 2: - // clear everything - display_element.html(''); - setTimeout(function(){plugin.trial(display_element, block, trial, part + 1);}, trial.timing[1]); - break; - case 3: - // draw trajectory - draw_trajectory(display_element, - trial.stimuli[trial.target_idx], - trial.stimuli[trial.start_idx], - trial.target_idx/(trial.stimuli.length-1), - trial.start_idx/(trial.stimuli.length-1)); - - display_element.append($('
',{ - "id":"bm_feedback", - })); - - if(change>0) { - $("#bm_feedback").html('

You said increase.

'); - } else { - $("#bm_feedback").html('

You said decrease.

'); - } - - setTimeout(function(){plugin.trial(display_element, block, trial, part + 1);}, trial.timing[1]*3); - break; - case 4: - var curr_loc = trial.start_idx - animate_interval = setInterval(function(){ - - // clear everything - display_element.html(''); - // draw trajectory - draw_trajectory(display_element, - trial.stimuli[trial.target_idx], - trial.stimuli[curr_loc], - trial.target_idx/(trial.stimuli.length-1), - curr_loc/(trial.stimuli.length-1)); - - curr_loc += change; - - - if(curr_loc - change == trial.target_idx || curr_loc < 0 || curr_loc == trial.stimuli.length) - { - clearInterval(animate_interval); - var correct = false; - if(change > 0 && trial.start_idx < trial.target_idx) { correct = true; } - if(change < 0 && trial.start_idx > trial.target_idx) { correct = true; } - - display_element.append($('
',{ - "id":"bm_feedback", - })); - if(correct){ - $("#bm_feedback").html('

Correct!

'); - } else { - $("#bm_feedback").html('

Wrong.

'); - } - setTimeout(function(){plugin.trial(display_element, block, trial, part + 1);}, trial.timing[1]*3); - } - }, trial.animate_frame_time); - break; - case 5: - display_element.html(''); - var correct = false; - if(change > 0 && trial.start_idx < trial.target_idx) { correct = true; } - if(change < 0 && trial.start_idx > trial.target_idx) { correct = true; } - - var trial_data = {"start_idx":trial.start_idx, "target_idx": trial.target_idx, "correct": correct, "rt": (end_time-start_time)}; - block.data[block.trial_idx] = $.extend({},trial_data,trial.data); - - setTimeout(function(){block.next();}, trial.timing[0]); - break; - } - } - - function draw_trajectory(display_element,target_img, moving_img, target_loc_percent, moving_loc_percent) - { - display_element.append($('
', { - "id": "message_holder"})); - $("#message_holder").append($('

Less Chemical X

')); - $("#message_holder").append($('')); - - $("#message_holder").append($('',{ - "src":"img/400arrow.gif", - "id":"arrow" - })); - // display the images on the trajectory - display_element.append($('
',{ - "id": "bm_trajectory", - "css": { - "position":"relative" - } - })); - - $("#bm_trajectory").append($('',{ - "src":target_img, - "id": "bm_target", - "css": { - "position":"absolute", - } - })); - - var image_width = parseInt($("#bm_target").css('width')); - var image_height = parseInt($("#bm_target").css('height')); - var container_width = parseInt($("#bm_trajectory").css('width')); - var target_left = (container_width - image_width) * target_loc_percent; - var moving_left = (container_width - image_width) * moving_loc_percent; - - $("#bm_target").css('left', target_left); - $("#bm_target").css('top', image_height); - - $("#bm_trajectory").append($('',{ - "src":moving_img, - "id": "bm_moving", - "css": { - "position":"absolute", - "left": moving_left, - "top": 0 - } - })); - - $("#bm_trajectory").append($( - '
', - { - "id": "target_flag", - "css": { - "position":"absolute", - "left": target_left+(image_width/2)-40, - "bottom": "-10px", - "background-color": "#cccccc", - "border": "1px solid #999999", - "width": 80, - "height": 20 - - } - } - )); - - $("#target_flag").html('

TARGET

'); - } - - return plugin; - })(); -})(jQuery); \ No newline at end of file diff --git a/plugins/dev/jspsych-categorize-multi.js b/plugins/dev/jspsych-categorize-multi.js deleted file mode 100644 index 86b18bbd..00000000 --- a/plugins/dev/jspsych-categorize-multi.js +++ /dev/null @@ -1,182 +0,0 @@ -// 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(display_element, block, trial, part) - { - switch(part){ - case 1: - // show image - display_element.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 - display_element.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. - display_element.append($('