/** * 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.COMPLEX, array: true, pretty_name: 'Questions', nested: { prompt: { type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Prompt', default: undefined, description: 'Questions that are associated with the slider.' }, labels: { type: jsPsych.plugins.parameterType.STRING, array: true, pretty_name: 'Labels', default: undefined, description: 'Labels to display for individual question.' }, required: { type: jsPsych.plugins.parameterType.BOOL, pretty_name: 'Required', default: false, description: 'Makes answering the question required.' }, name: { type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Question Name', default: '', description: 'Controls the name of data values associated with this question' } } }, randomize_question_order: { type: jsPsych.plugins.parameterType.BOOL, pretty_name: 'Randomize Question Order', default: false, description: 'If true, the order of the questions will be randomized' }, preamble: { type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Preamble', default: null, description: 'String to display at top of the page.' }, scale_width: { type: jsPsych.plugins.parameterType.INT, pretty_name: 'Scale width', default: null, description: 'Width of the likert scales in pixels.' }, button_label: { type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Button label', default: 'Continue', description: 'Label of the button.' }, autocomplete: { type: jsPsych.plugins.parameterType.BOOL, pretty_name: 'Allow autocomplete', default: false, description: "Setting this to true will enable browser auto-complete or auto-fill for the form." } } } plugin.trial = function(display_element, trial) { if(trial.scale_width !== null){ var w = trial.scale_width + 'px'; } else { var w = '100%'; } var html = ""; // inject CSS for trial html += ''; // show preamble text if(trial.preamble !== null){ html += '