diff --git a/jspsych.js b/jspsych.js index 224aa540..bea9e04a 100755 --- a/jspsych.js +++ b/jspsych.js @@ -939,7 +939,8 @@ jsPsych.plugins = (function() { IMAGE: 8, AUDIO: 9, VIDEO: 10, - OBJECT: 11 + OBJECT: 11, + COMPLEX: 12 } module.universalPluginParameters = { diff --git a/tests/jsPsych.data/dataparameter.test.js b/tests/jsPsych.data/dataparameter.test.js index 0cc7871c..5ce9a77d 100644 --- a/tests/jsPsych.data/dataparameter.test.js +++ b/tests/jsPsych.data/dataparameter.test.js @@ -156,6 +156,39 @@ describe('The data parameter', function(){ expect(jsPsych.data.get().filter({added: false}).count()).toBe(1); }); + test('timeline variable should be available in trial on_finish', function(){ + require(root + 'jspsych.js'); + require(root + 'plugins/jspsych-html-keyboard-response.js'); + + var trial = { + timeline: [ + { + type: 'html-keyboard-response', + stimulus: 'foo', + data: {added: jsPsych.timelineVariable('added')}, + on_finish: function(data){ + data.added_copy = data.added; + }} + ], + timeline_variables: [ + {added: true}, + {added: false} + ] + } + + jsPsych.init({ + timeline: [trial] + }); + + utils.pressKey(32); // trial 1 + utils.pressKey(32); // trial 2 + + console.log(jsPsych.data.get().json()) + + expect(jsPsych.data.get().filter({added_copy: true}).count()).toBe(1); + expect(jsPsych.data.get().filter({added_copy: false}).count()).toBe(1); + }); + test.skip('should record data to all nested trials with timeline variables even when nested trials have own data', function(){ require(root + 'jspsych.js'); diff --git a/tests/plugins/plugin-survey-multi-select.test.js b/tests/plugins/plugin-survey-multi-select.test.js index b8e5c595..f5456f25 100644 --- a/tests/plugins/plugin-survey-multi-select.test.js +++ b/tests/plugins/plugin-survey-multi-select.test.js @@ -16,14 +16,18 @@ describe('survey-multi-select plugin', function(){ test('quoted values for options work', function(){ var trial = { type: 'survey-multi-select', - questions: ['foo'], - options: [['Hello "boo"', "yes, 'bar'"]] + questions: [{ + prompt: 'foo', + options: ['Hello "boo"', "yes, 'bar'"] + }] } jsPsych.init({ timeline: [trial] }); + console.log(jsPsych.getDisplayElement().innerHTML); + expect(jsPsych.getDisplayElement().querySelector('#jspsych-survey-multi-select-option-0-0 input').value).toBe('Hello "boo"'); expect(jsPsych.getDisplayElement().querySelector('#jspsych-survey-multi-select-option-0-1 input').value).toBe("yes, 'bar'");