-
Hi everyone, I am trying to create an experiment in which participants use a Likert scale to respond to an image. Here is the code:
The problem is that, when I try to run this code, my debug console tells me that "data" is undefined and, therefore, the code fails. This issue confuses me because I thought that "data" was a predetermined parameter in jsPsych, i.e. that the computer will assume that "data" exists even if the coder does not explicitly define it. That said, even if the data parameter is not predetermined, I think I still defined it as an object in my code. Therefore, I do not understand why my code will not work. Has anyone run into an issue like this before? If so, do you know how to resolve it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @woodenchair, You are getting an error because of this line: rating: data.response.Q0 You are right that It looks like what you are trying to do is basically rename on_finish: function(data){
data.rating = data.response.Q0;
} The reason that this works in |
Beta Was this translation helpful? Give feedback.
Hi @woodenchair,
You are getting an error because of this line:
You are right that
data
is a universal plugin parameter in jsPsych, but in this case you are trying to reference the value ofdata.response
before the trial has happened. At the time that your definition of this timeline is created there is no data yet, and so the JavaScript interpreter doesn't know what the variabledata
refers to here.It looks like what you are trying to do is basically rename
data.response.Q0
torating
in the data for the trial. You can do this in theon_finish
parameter, like this:The reason that this works in
on_finish