/** * 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; trial.required = typeof trial.required === 'undefined' ? false : trial.required; // 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 += ''; var cssstr = ".jspsych-survey-likert-statement { display:block; font-size: 18px; padding-top: 30px; margin-bottom:10px; }"+ ".jspsych-survey-likert-opts { list-style:none; width:100%; margin:0; padding:0 0 35px; display:block; font-size: 14px; line-height:1.1em; }"+ ".jspsych-survey-likert-opt-label { line-height: 1.1em; }"+ ".jspsych-survey-likert-opts:before { content: ''; position:relative; top:11px; /*left:9.5%;*/ display:block; background-color:#efefef; height:4px; width:100%; }"+ ".jspsych-survey-likert-opts:last-of-type { border-bottom: 0; }"+ ".jspsych-survey-likert-opts li { display:inline-block; /*width:19%;*/ text-align:center; vertical-align: top; }"+ ".jspsych-survey-likert-opts li input[type=radio] { display:block; position:relative; top:0; left:50%; margin-left:-6px; }" display_element.querySelector('#jspsych-survey-likert-css').innerHTML = cssstr; // show preamble text display_element.innerHTML += '