diff --git a/plugins/jspsych-survey-multi-select.js b/plugins/jspsych-survey-multi-select.js new file mode 100644 index 00000000..055f5b5f --- /dev/null +++ b/plugins/jspsych-survey-multi-select.js @@ -0,0 +1,169 @@ +/** + * jspsych-survey-multi-select + * a jspsych plugin for multiple choice survey questions + * + * Shane Martin + * + * documentation: docs.jspsych.org + * + */ + + +jsPsych.plugins['survey-multi-select'] = (function() { + var plugin = {}; + + plugin.info = { + name: 'survey-multi-select', + description: '', + parameters: { + questions: { + type: [jsPsych.plugins.parameterType.STRING], + array: true, + default: undefined, + no_function: false, + description: '' + }, + options: { + type: [jsPsych.plugins.parameterType.STRING], + array: true, + default: undefined, + no_function: false, + description: '' + }, + required: { + type: [jsPsych.plugins.parameterType.BOOL], + array: true, + default: false, + no_function: false, + description: '' + }, + horitzontal: { + type: [jsPsych.plugins.parameterType.BOOL], + default: false, + no_function: false, + description: '' + }, + preamble: { + type: [jsPsych.plugins.parameterType.STRING], + default: '', + no_function: false, + description: '' + } + } + } + plugin.trial = function(display_element, trial) { + var plugin_id_name = "jspsych-survey-multi-select"; + var plugin_id_selector = '#' + plugin_id_name; + var _join = function( /*args*/ ) { + var arr = Array.prototype.slice.call(arguments, _join.length); + return arr.join(separator = '-'); + } + + // trial defaults + trial.preamble = typeof trial.preamble == 'undefined' ? "" : trial.preamble; + trial.required = typeof trial.required == 'undefined' ? null : trial.required; + trial.horizontal = typeof trial.required == 'undefined' ? false : trial.horizontal; + + // if any trial variables are functions + // this evaluates the function and replaces + // it with the output of the function + trial = jsPsych.pluginAPI.evaluateFunctionParameters(trial); + + // inject CSS for trial + var node = display_element.innerHTML += '