change responses to response in survey-text plugin #638

This commit is contained in:
Becky Gilbert 2021-02-17 15:58:54 -08:00
parent db2a2dc6bc
commit 8a9e1a655a
6 changed files with 6 additions and 6 deletions

View File

@ -128,7 +128,7 @@ var trial = {
prompt: function() {
// this question prompt is dynamic - the text that is shown
// will change based on the participant's earlier response
var favorite_city = jsPsych.data.getLastTrialData().values()[0].responses.fav_city;
var favorite_city = jsPsych.data.getLastTrialData().values()[0].response.fav_city;
var text = "Earlier you said your favorite city is "+favorite_city+". What do you like most about "+favorite_city+"?"
return text;
},

View File

@ -20,7 +20,7 @@ In addition to the [default data collected by all plugins](/overview/plugins#dat
Name | Type | Value
-----|------|------
responses | object | An object containing the response for each question. The object will have a separate key (variable) for each question, with the first question in the trial being recorded in `Q0`, the second in `Q1`, and so on. For each question, the response is a string containing whatever text was in the response box when the responses were submitted. If the `name` parameter is defined for the question, then the responses object will use the value of `name` as the key for each question. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. |
response | object | An object containing the response for each question. The object will have a separate key (variable) for each question, with the first question in the trial being recorded in `Q0`, the second in `Q1`, and so on. For each question, the response is a string containing whatever text was in the response box when the responses were submitted. If the `name` parameter is defined for the question, then the responses object will use the value of `name` as the key for each question. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. |
rt | numeric | The response time in milliseconds for the subject to make a response. The time is measured from when the questions first appear on the screen until the subject's response(s) were submitted. |
question_order | array | An array with the order of questions. For example `[2,0,1]` would indicate that the first question was `trial.questions[2]` (the third item in the `questions` parameter), the second question was `trial.questions[0]`, and the final question was `trial.questions[1]`. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. |

View File

@ -169,7 +169,7 @@ jsPsych.plugins['survey-text'] = (function() {
// save data
var trialdata = {
rt: response_time,
responses: question_data
response: question_data
};
display_element.innerHTML = '';

View File

@ -29,7 +29,7 @@ describe('data conversion to csv', function(){
utils.clickTarget(document.querySelector('#jspsych-survey-text-next'));
var csv_data = jsPsych.data.get().ignore(['rt','internal_node_id', 'time_elapsed', 'trial_type']).csv();
expect(csv_data).toBe('"responses","trial_index"\r\n"{""Q0"":""Response 1"",""Q1"":""Response 2""}","0"\r\n');
expect(csv_data).toBe('"response","trial_index"\r\n"{""Q0"":""Response 1"",""Q1"":""Response 2""}","0"\r\n');
})
test('same-different-html stimulus array is correctly converted', function(){

View File

@ -30,7 +30,7 @@ describe('data conversion to json', function(){
utils.clickTarget(document.querySelector('#jspsych-survey-text-next'));
var json_data = jsPsych.data.get().ignore(['rt','internal_node_id', 'time_elapsed', 'trial_type']).json();
expect(json_data).toBe(JSON.stringify([{responses: {Q0: "Response 1", Q1: "Response 2"}, trial_index: 0}]));
expect(json_data).toBe(JSON.stringify([{response: {Q0: "Response 1", Q1: "Response 2"}, trial_index: 0}]));
})
test('same-different-html stimulus array is correctly converted', function(){

View File

@ -104,7 +104,7 @@ describe('survey-text plugin', function(){
utils.clickTarget(document.querySelector('#jspsych-survey-text-next'));
var survey_data = jsPsych.data.get().values()[0].responses;
var survey_data = jsPsych.data.get().values()[0].response;
expect(survey_data.Q0).toBe('a0');
expect(survey_data.Q1).toBe('a1');
expect(survey_data.Q2).toBe('a2');