Skip to content

Commit

Permalink
implements jspsych#627
Browse files Browse the repository at this point in the history
  • Loading branch information
jodeleeuw committed Jul 2, 2019
1 parent d094d1d commit cd82ddf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/plugins/jspsych-survey-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Parameters with a default value of *undefined* must be specified. Other paramete

Parameter | Type | Default Value | Description
----------|------|---------------|------------
questions | array | *undefined* | An array of objects, each object represents a question that appears on the screen. Each object contains a prompt, value, required, rows, and columns parameter that will be applied to the question. See examples below for further clarification. `prompt`: Type string, default value of *undefined*. The string is the prompt for the subject to respond to. Each question gets its own response field. `value`: Type string, default value of `""`. The string will be used to populate the response field with editable answer. `required`: Boolean; if `true` then the user must enter a response to submit. `rows`: Type integer, default value of 1. The number of rows for the response text box. `columns`: Type integer, default value of 40. The number of columns for the response text box.
questions | array | *undefined* | An array of objects, each object represents a question that appears on the screen. Each object contains a prompt, value, required, rows, and columns parameter that will be applied to the question. See examples below for further clarification. `prompt`: Type string, default value of *undefined*. The string is the prompt for the subject to respond to. Each question gets its own response field. `placeholder`: Type string, default value of `""`. The string will create placeholder text in the text field. `required`: Boolean; if `true` then the user must enter a response to submit. `rows`: Type integer, default value of 1. The number of rows for the response text box. `columns`: Type integer, default value of 40. The number of columns for the response text box.
randomize_question_order | boolean | `false` | If true, the display order of `questions` is randomly determined at the start of the trial. In the data object, `Q0` will still refer to the first question in the array, regardless of where it was presented visually.
preamble | string | empty string | HTML formatted string to display at the top of the page above all the questions.
button_label | string | 'Continue' | The text that appears on the button to finish the trial.
Expand Down
8 changes: 4 additions & 4 deletions plugins/jspsych-survey-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jsPsych.plugins['survey-text'] = (function() {
default: undefined,
description: 'Prompt for the subject to response'
},
value: {
placeholder: {
type: jsPsych.plugins.parameterType.STRING,
pretty_name: 'Value',
default: "",
description: 'The string will be used to populate the response field with editable answer.'
description: 'Placeholder text in the textfield.'
},
rows: {
type: jsPsych.plugins.parameterType.INT,
Expand Down Expand Up @@ -114,9 +114,9 @@ jsPsych.plugins['survey-text'] = (function() {
var autofocus = i == 0 ? "autofocus" : "";
var req = question.required ? "required" : "";
if(question.rows == 1){
html += '<input id="input-'+question_index+'" type="text" name="#jspsych-survey-text-response-' + question_index + '" size="'+question.columns+'" value="'+question.value+'" '+autofocus+' '+req+'></input>';
html += '<input id="input-'+question_index+'" type="text" name="#jspsych-survey-text-response-' + question_index + '" size="'+question.columns+'" value="'+question.value+'" '+autofocus+' '+req+' placeholder="'+question.value+'"></input>';
} else {
html += '<textarea id="input-'+question_index+'" name="#jspsych-survey-text-response-' + question_index + '" cols="' + question.columns + '" rows="' + question.rows + '" '+autofocus+' '+req+'>'+question.value+'</textarea>';
html += '<textarea id="input-'+question_index+'" name="#jspsych-survey-text-response-' + question_index + '" cols="' + question.columns + '" rows="' + question.rows + '" '+autofocus+' '+req+' placeholder="'+question.value+'"></textarea>';
}
html += '</div>';
}
Expand Down

0 comments on commit cd82ddf

Please sign in to comment.