From d685daa7ad1bbad869f5584ceb51df1bdc1bae99 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Wed, 3 Jan 2018 14:05:53 -0500 Subject: [PATCH] bug fixes on survey text plugin --- plugins/jspsych-survey-text.js | 53 ++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/plugins/jspsych-survey-text.js b/plugins/jspsych-survey-text.js index bedebd3e..7e536c1d 100644 --- a/plugins/jspsych-survey-text.js +++ b/plugins/jspsych-survey-text.js @@ -21,26 +21,35 @@ jsPsych.plugins['survey-text'] = (function() { type: jsPsych.plugins.parameterType.COMPLEX, array: true, pretty_name: 'Questions', + default: undefined, nested: { - prompt: {type: jsPsych.plugins.parameterType.STRING, - pretty_name: 'Prompt', - default: undefined, - description: 'Prompts for the subject to response'}, - value: {type: jsPsych.plugins.parameterType.STRING, - pretty_name: 'Value', - array: true, - default: null, - 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.'} + prompt: { + type: jsPsych.plugins.parameterType.STRING, + pretty_name: 'Prompt', + default: undefined, + description: 'Prompts for the subject to response' + }, + value: { + type: jsPsych.plugins.parameterType.STRING, + pretty_name: 'Value', + array: true, + default: null, + 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: { @@ -60,7 +69,6 @@ jsPsych.plugins['survey-text'] = (function() { plugin.trial = function(display_element, trial) { - if (typeof trial.questions[0].rows == 'undefined') { trial.questions[0].rows = []; for (var i = 0; i < trial.questions.length; i++) { @@ -80,16 +88,17 @@ jsPsych.plugins['survey-text'] = (function() { } } + var html = ''; // show preamble text if(trial.preamble !== null){ - var html = '
'+trial.preamble+'
'; + html += '
'+trial.preamble+'
'; } // add questions for (var i = 0; i < trial.questions.length; i++) { html += '
'; html += '

' + trial.questions[i].prompt + '

'; if(trial.questions[i].rows == 1){ - html += ''+trial.questions[i].value+''; + html += ''; } else { html += ''; }