/** * jspsych-survey-likert * a jspsych plugin for measuring items on a likert scale * * Josh de Leeuw * * documentation: docs.jspsych.org * */ jsPsych.plugins['survey-likert'] = (function() { var plugin = {}; plugin.info = { name: 'survey-likert', description: '', parameters: { questions: { type: [jsPsych.plugins.parameterType.STRING], array: true, default: undefined, no_function: false, description: '' }, labels: { type: [jsPsych.plugins.parameterType.STRING], array: true, default: undefined, no_function: false, description: '' } } } plugin.trial = function(display_element, trial) { // default parameters for the trial trial.preamble = typeof trial.preamble === 'undefined' ? "" : trial.preamble; // if any trial variables are functions // this evaluates the function and replaces // it with the output of the function trial = jsPsych.pluginAPI.evaluateFunctionParameters(trial); // show preamble text display_element.append($('
', { "id": 'jspsych-survey-likert-preamble', "class": 'jspsych-survey-likert-preamble' })); $('#jspsych-survey-likert-preamble').html(trial.preamble); display_element.append('
'); // add likert scale questions for (var i = 0; i < trial.questions.length; i++) { form_element = $('#jspsych-survey-likert-form'); // add question form_element.append(''); // add options var width = 100 / trial.labels[i].length; options_string = ''; form_element.append(options_string); } // add submit button display_element.append($('