diff --git a/examples/iat-example.html b/examples/jspsych-iat.html similarity index 85% rename from examples/iat-example.html rename to examples/jspsych-iat.html index b1ae0260..cb39763a 100644 --- a/examples/iat-example.html +++ b/examples/jspsych-iat.html @@ -43,7 +43,7 @@ var category_block = { var instructions_block = { type: 'text', text: "

Press E for:
" + - "YOUNG

" + "

Press I for:
" + "OLD

" + + "OLD

" + "

Press I for:
" + "YOUNG

" + "
" + "

Put a left finger on the E key for items that belong to the Old People category. Put a right finger on the " + "I key for items that belong to the Young People " + @@ -65,27 +65,27 @@ var trial_block = { wrong_image_name: 'red X', display_feedback: true, timing_response: 3000, //Only if display_feedback is false - left_category_key: 'E', - right_category_key: 'I', - left_category_label: ['young'], - right_category_label: ['old'], - key_to_move_forward: [], + left_category_key: 'e', + right_category_key: 'i', + left_category_label: ['old'], + right_category_label: ['young'], + key_to_move_forward: [jsPsych.ALL_KEYS], response_ends_trial: true } ], timeline_variables: [ - {stimulus: "age/of1.jpg", stim_key_association: "right"}, - {stimulus: "age/of2.jpg", stim_key_association: "right"}, - {stimulus: "age/of3.jpg", stim_key_association: "right"}, - {stimulus: "age/om1.jpg", stim_key_association: "right"}, - {stimulus: "age/om2.jpg", stim_key_association: "right"}, - {stimulus: "age/om3.jpg", stim_key_association: "right"}, - {stimulus: "age/yf1.jpg", stim_key_association: "left"}, - {stimulus: "age/yf4.jpg", stim_key_association: "left"}, - {stimulus: "age/yf5.jpg", stim_key_association: "left"}, - {stimulus: "age/ym2.jpg", stim_key_association: "left"}, - {stimulus: "age/ym3.jpg", stim_key_association: "left"}, - {stimulus: "age/ym5.jpg", stim_key_association: "left"} + {stimulus: "age/of1.jpg", stim_key_association: "left"}, + {stimulus: "age/of2.jpg", stim_key_association: "left"}, + {stimulus: "age/of3.jpg", stim_key_association: "left"}, + {stimulus: "age/om1.jpg", stim_key_association: "left"}, + {stimulus: "age/om2.jpg", stim_key_association: "left"}, + {stimulus: "age/om3.jpg", stim_key_association: "left"}, + {stimulus: "age/yf1.jpg", stim_key_association: "right"}, + {stimulus: "age/yf4.jpg", stim_key_association: "right"}, + {stimulus: "age/yf5.jpg", stim_key_association: "right"}, + {stimulus: "age/ym2.jpg", stim_key_association: "right"}, + {stimulus: "age/ym3.jpg", stim_key_association: "right"}, + {stimulus: "age/ym5.jpg", stim_key_association: "right"} ], randomize_order: true, repititions: 2 @@ -121,7 +121,7 @@ var trial_block2 = { right_category_key: 'I', left_category_label: ['bad'], right_category_label: ['good'], - key_to_move_forward: [], + key_to_move_forward: [jsPsych.ALL_KEYS], response_ends_trial: true } ], @@ -150,8 +150,8 @@ var trial_block2 = { var instructions_block3 = { type: 'text', text: "

Press 'E' for:
" + - "BAD
" + "or
" + "OLD PEOPLE
" + "
" + - "Press 'I' for:
" + "GOOD
" + "or
" + "YOUNG PEOPLE
" + + "BAD
" + "or
" + "OLD
" + "
" + + "Press 'I' for:
" + "GOOD
" + "or
" + "YOUNG
" + "

Use E for Bad and for " + "Old People
" + "Use I for Good and for Young People
" + "Each item belongs to only one category.

" + "If you " + @@ -173,9 +173,9 @@ var trial_block3 = { timing_response: 3000, //Only if display_feedback is false left_category_key: 'E', right_category_key: 'I', - left_category_label: ['bad', 'old people'], - right_category_label: ['good', 'young people'], - key_to_move_forward: [], + left_category_label: ['bad', 'old'], + right_category_label: ['good', 'young'], + key_to_move_forward: [jsPsych.ALL_KEYS], response_ends_trial: true } ], @@ -215,9 +215,9 @@ var trial_block3 = { var instructions_block4 = { type: 'text', - text: "

Press 'E' for:
" + - "Bad
" + "or
" + "Old People
" + "
" + - "Press 'I' for:
" + "Good
" + "or
" + "Young People
" + + text: "
Press 'E' for:
" + + "BAD
" + "or
" + "OLD
" + "
" + + "Press 'I' for:
" + "GOOD
" + "or
" + "YOUNG
" + "

This is the same as the previous part.
" + "Use E for Bad and for " + "Old People
" + "Use I for Good and for Young People
" + "Each item belongs to only one category.

" + "If you " + @@ -239,9 +239,9 @@ var trial_block4 = { timing_response: 3000, //Only if display_feedback is false left_category_key: 'E', right_category_key: 'I', - left_category_label: ['bad', 'old people'], - right_category_label: ['good', 'young people'], - key_to_move_forward: [], + left_category_label: ['bad', 'old'], + right_category_label: ['good', 'young'], + key_to_move_forward: [jsPsych.ALL_KEYS], response_ends_trial: true } ], @@ -281,8 +281,8 @@ var trial_block4 = { var instructions_block5 = { type: 'text', - text: "

Press 'E' for:
" + "Young People
" + - "
Press 'I' for:
" + "Old People
" + + text: "
Press 'E' for:
" + "YOUNG
" + + "
Press 'I' for:
" + "OLD
" + "

Watch out, the labels have changed positions!
" + "Use E for Young People
" + "Use I for Old People

" + "If you make a mistake, a red X will appear. Press the keys listed below " + @@ -303,9 +303,9 @@ var trial_block4 = { timing_response: 3000, //Only if display_feedback is false left_category_key: 'E', right_category_key: 'I', - left_category_label: ['young people'], - right_category_label: ['old people'], - key_to_move_forward: [], + left_category_label: ['young'], + right_category_label: ['old'], + key_to_move_forward: [jsPsych.ALL_KEYS], response_ends_trial: true } ], @@ -329,9 +329,9 @@ var trial_block4 = { var instructions_block6 = { type: 'text', - text: "

Press 'E' for:
" + "Bad
" + "or
" + - "Old People
" + "
Press 'I' for:
" + "Good
" + "or
" + - "Young People
" + + text: "
Press 'E' for:
" + "BAD
" + "or
" + + "OLD
" + "
Press 'I' for:
" + "GOOD
" + "or
" + + "YOUNG
" + "

Use E for Bad and for Old People
" + "Use I for Good and for Young People

" + "If you make a mistake, a red X will appear. Press the keys listed below " + @@ -352,9 +352,9 @@ var trial_block4 = { timing_response: 3000, //Only if display_feedback is false left_category_key: 'E', right_category_key: 'I', - left_category_label: ['bad', 'old people'], - right_category_label: ['good', 'young people'], - key_to_move_forward: [] + left_category_label: ['bad', 'old'], + right_category_label: ['good', 'young'], + key_to_move_forward: [jsPsych.ALL_KEYS], } ], timeline_variables: [ @@ -393,8 +393,8 @@ var trial_block4 = { var instructions_block7 = { type: 'text', - text: "

Press 'E' for:
" + "Bad
" + "or
" + - "Old People
" + "
Press 'I' for:
" + "Good
" + "or
" + + text: "
Press 'E' for:
" + "Bad
" + "or
" + + "Old People
" + "
Press 'I' for:
" + "Good
" + "or
" + "Young People
" + "

This is the same as the previous part
" + "Use E for Bad and for Old People
" + @@ -424,12 +424,12 @@ var trial_block4 = { var timeline = []; // timeline.push(welcome_block); // timeline.push(category_block); -//timeline.push(instructions_block); -timeline.push(trial_block); -timeline.push(instructions_block2); -timeline.push(trial_block2); -timeline.push(instructions_block3); -timeline.push(trial_block3); +// timeline.push(instructions_block); +// timeline.push(trial_block); +// timeline.push(instructions_block2); +// timeline.push(trial_block2); +// timeline.push(instructions_block3); +// timeline.push(trial_block3); timeline.push(instructions_block4); timeline.push(trial_block4); timeline.push(instructions_block5); diff --git a/plugins/jspsych-iat.js b/plugins/jspsych-iat.js index 86a28ea3..bdadafcf 100644 --- a/plugins/jspsych-iat.js +++ b/plugins/jspsych-iat.js @@ -1,6 +1,6 @@ /** * jspsych-single-stim - * Josh de Leeuw + * Kristin Diep * * plugin for displaying a stimulus and getting a keyboard response * @@ -40,6 +40,7 @@ trial.right_category_label = trial.right_category_label || ['right']; trial.stim_key_association = trial.stim_key_association || 'undefined'; trial.response_ends_trial = (typeof trial.response_ends_trial == 'undefined') ? true : trial.response_ends_trial; + trial.timing_response = trial.timing_response || 0; trial.key_to_move_forward = trial.key_to_move_forward || jsPsych.ALL_KEYS; trial.is_html = (typeof trial.is_html == 'undefined') ? false : trial.is_html; trial.prompt = trial.prompt || ""; @@ -64,9 +65,9 @@ html_str += "

"; if (!trial.is_html) { - html_str += "
"; + html_str += "
"; } else { - html_str += "

"+trial.stimulus+"

"; + html_str += "

"+trial.stimulus+"

"; } html_str += "
"; @@ -100,11 +101,11 @@ var wImg = document.getElementById("wrongImgID"); //wImg.style.visibility = "hidden"; - if(trial.key_to_move_forward.length == 0) { - html_str += "

If you press the wrong key, a " + trial.wrong_image_name + " will appear. Press any key to continue.

"; - } else if(trial.key_to_move_forward.length == 1) { + if(trial.key_to_move_forward.length == 1) { if(trial.key_to_move_forward[0] == "other key") { html_str += "

If you press the wrong key, a " + trial.wrong_image_name + " will appear. Press the other key to continue.

" + } else if(trial.key_to_move_forward[0] == jsPsych.ALL_KEYS) { + html_str += "

If you press the wrong key, a " + trial.wrong_image_name + " will appear. Press any key to continue.

" } else { html_str += "

If you press the wrong key, a " + trial.wrong_image_name + " will appear. Press " + trial.key_to_move_forward[0] + " to continue.

"; } @@ -205,7 +206,7 @@ } else if(trial.response_ends_trial && trial.display_feedback != true) { var keyListener = jsPsych.pluginAPI.getKeyboardResponse({ callback_function: end_trial, - valid_responses: [] + valid_responses: [jsPsych.ALL_KEYS] }); } } @@ -234,7 +235,7 @@ } else if(trial.response_ends_trial && trial.display_feedback != true) { var keyListener = jsPsych.pluginAPI.getKeyboardResponse({ callback_function: end_trial, - valid_responses: [] + valid_responses: [jsPsych.ALL_KEYS] }); } } @@ -258,7 +259,7 @@ jsPsych.pluginAPI.setTimeout(function() { end_trial(); }, trial.timing_response); - } + } };