mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
bug fixes on survey text plugin
This commit is contained in:
parent
fa3cae1eea
commit
d685daa7ad
@ -21,26 +21,35 @@ jsPsych.plugins['survey-text'] = (function() {
|
|||||||
type: jsPsych.plugins.parameterType.COMPLEX,
|
type: jsPsych.plugins.parameterType.COMPLEX,
|
||||||
array: true,
|
array: true,
|
||||||
pretty_name: 'Questions',
|
pretty_name: 'Questions',
|
||||||
|
default: undefined,
|
||||||
nested: {
|
nested: {
|
||||||
prompt: {type: jsPsych.plugins.parameterType.STRING,
|
prompt: {
|
||||||
pretty_name: 'Prompt',
|
type: jsPsych.plugins.parameterType.STRING,
|
||||||
default: undefined,
|
pretty_name: 'Prompt',
|
||||||
description: 'Prompts for the subject to response'},
|
default: undefined,
|
||||||
value: {type: jsPsych.plugins.parameterType.STRING,
|
description: 'Prompts for the subject to response'
|
||||||
pretty_name: 'Value',
|
},
|
||||||
array: true,
|
value: {
|
||||||
default: null,
|
type: jsPsych.plugins.parameterType.STRING,
|
||||||
description: 'The strings will be used to populate the response fields with editable answers.'},
|
pretty_name: 'Value',
|
||||||
rows: {type: jsPsych.plugins.parameterType.INT,
|
array: true,
|
||||||
pretty_name: 'Rows',
|
default: null,
|
||||||
array: true,
|
description: 'The strings will be used to populate the response fields with editable answers.'
|
||||||
default: 1,
|
},
|
||||||
description: 'The number of rows for the response text box.'},
|
rows: {
|
||||||
columns: {type: jsPsych.plugins.parameterType.INT,
|
type: jsPsych.plugins.parameterType.INT,
|
||||||
pretty_name: 'Columns',
|
pretty_name: 'Rows',
|
||||||
array: true,
|
array: true,
|
||||||
default: 40,
|
default: 1,
|
||||||
description: 'The number of columns for the response text box.'}
|
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: {
|
preamble: {
|
||||||
@ -60,7 +69,6 @@ jsPsych.plugins['survey-text'] = (function() {
|
|||||||
|
|
||||||
plugin.trial = function(display_element, trial) {
|
plugin.trial = function(display_element, trial) {
|
||||||
|
|
||||||
|
|
||||||
if (typeof trial.questions[0].rows == 'undefined') {
|
if (typeof trial.questions[0].rows == 'undefined') {
|
||||||
trial.questions[0].rows = [];
|
trial.questions[0].rows = [];
|
||||||
for (var i = 0; i < trial.questions.length; i++) {
|
for (var i = 0; i < trial.questions.length; i++) {
|
||||||
@ -80,16 +88,17 @@ jsPsych.plugins['survey-text'] = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var html = '';
|
||||||
// show preamble text
|
// show preamble text
|
||||||
if(trial.preamble !== null){
|
if(trial.preamble !== null){
|
||||||
var html = '<div id="jspsych-survey-text-preamble" class="jspsych-survey-text-preamble">'+trial.preamble+'</div>';
|
html += '<div id="jspsych-survey-text-preamble" class="jspsych-survey-text-preamble">'+trial.preamble+'</div>';
|
||||||
}
|
}
|
||||||
// add questions
|
// add questions
|
||||||
for (var i = 0; i < trial.questions.length; i++) {
|
for (var i = 0; i < trial.questions.length; i++) {
|
||||||
html += '<div id="jspsych-survey-text-"'+i+'" class="jspsych-survey-text-question" style="margin: 2em 0em;">';
|
html += '<div id="jspsych-survey-text-"'+i+'" class="jspsych-survey-text-question" style="margin: 2em 0em;">';
|
||||||
html += '<p class="jspsych-survey-text">' + trial.questions[i].prompt + '</p>';
|
html += '<p class="jspsych-survey-text">' + trial.questions[i].prompt + '</p>';
|
||||||
if(trial.questions[i].rows == 1){
|
if(trial.questions[i].rows == 1){
|
||||||
html += '<input type="text" name="#jspsych-survey-text-response-' + i + '" size="'+trial.questions[i].columns+'">'+trial.questions[i].value+'</input>';
|
html += '<input type="text" name="#jspsych-survey-text-response-' + i + '" size="'+trial.questions[i].columns+'" value="'+trial.questions[i].value+'"></input>';
|
||||||
} else {
|
} else {
|
||||||
html += '<textarea name="#jspsych-survey-text-response-' + i + '" cols="' + trial.questions[i].columns + '" rows="' + trial.questions[i].rows + '">'+trial.questions[i].value+'</textarea>';
|
html += '<textarea name="#jspsych-survey-text-response-' + i + '" cols="' + trial.questions[i].columns + '" rows="' + trial.questions[i].rows + '">'+trial.questions[i].value+'</textarea>';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user