Likert data format #1929
-
I am working with the Likert plugin on the Cognition platform, but I need the responses to be saved in separate variables, not an array. Can someone help me please. Sorry for my question, but I am starting to learn js. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @agarza7, this is something that some people find easier to do in the data processing stage, using a scripting language like R, Python, Matlab, etc. But if you want to do this in your jsPsych JavaScript code, you could do this in the trial's var trial = {
type: 'survey-likert',
questions: [
{prompt: "I like vegetables.", name: 'Vegetables', labels: scale, required: true}
],
on_finish: function(data) {
data.response_value = data.response.Vegetables;
}
} If your trials have more than one question on the same page, then you will need to create different variables to hold each of the different responses, like this: var trial = {
type: 'survey-likert',
questions: [
{prompt: "I like vegetables.", name: 'Vegetables', labels: scale, required: true},
{prompt: "I like fruit.", name: 'Fruit', labels: scale, required: true}
],
on_finish: function(data) {
data.response_veg = data.response.Vegetables;
data.response_fruit = data.response.Fruit;
}
} Does this solution work for you? |
Beta Was this translation helpful? Give feedback.
Hi @agarza7, this is something that some people find easier to do in the data processing stage, using a scripting language like R, Python, Matlab, etc.
But if you want to do this in your jsPsych JavaScript code, you could do this in the trial's
on_finish
function. Theon_finish
function gives you access to the trial data, and allows you to modify it. So if your survey-likert trials always have just one question on the page, then you could create a new variable (e.g. "response_value") in the trial data, and store the response inside of that. You can access the response withdata.response
, followed by the question name: