/** * jspsych-survey-text * a jspsych plugin for free response survey questions * * Josh de Leeuw * * documentation: docs.jspsych.org * */ jsPsych.plugins['survey-text'] = (function() { var plugin = {}; plugin.info = { name: 'survey-text', description: '', parameters: { nested: { type: jsPsych.plugins.parameterType.COMPLEX, array:true, question: {type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Questions', default: undefined, description: 'Prompts for the the subject to response'}, value: {type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Value', array: true, default: '', description: 'The strings will be used to populate the response fields with editable answers.'}, rows: {type: jsPsych.plugins.parameterType.INT, pretty_name: 'Rows', array: true, default: 1, description: 'The number of rows for the response text box.'}, columns: {type: jsPsych.plugins.parameterType.INT, pretty_name: 'Columns', array: true, default: 40, description: 'The number of columns for the response text box.'} }, preamble: { type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Preamble', default: '', description: 'HTML formatted string to display at the top of the page above all the questions.' }, button_label: { type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Button label', default: 'Next', description: 'The text that appears on the button to finish the trial.' } } } plugin.trial = function(display_element, trial) { if (typeof trial.nested[0].rows == 'undefined') { trial.nested[0].rows = []; for (var i = 0; i < trial.nested.length; i++) { trial.nested[i].rows.push(1); } } if (typeof trial.nested[0].columns == 'undefined') { trial.nested[0].columns = []; for (var i = 0; i < trial.nested.length; i++) { trial.nested[i].columns.push(40); } } if (typeof trial.nested[0].value == 'undefined') { trial.nested[0].value = []; for (var i = 0; i < trial.nested.length; i++) { trial.nested[i].value.push(""); } } // show preamble text var html = '
' + trial.nested[i].question + '
'; if(trial.nested[i].rows == 1){ html += ''+trial.nested[i].value+''; } else { html += ''; } html += '