0

I'm trying to learn jsPsych and tried following along with a video tutorial and I ran into a problem.

The intention was to create a function that adds wether a given response to a stimulus was correct or incorrect to the data that is to be displayed when the paradigm is finished.

In the tutorial this function was written as

 on_finish: function(data){
            var acc = false;
            if (data.correct_response == data.key_press) {
                acc = true;
            }
        
            data.accuracy = acc;
        }

This should add the accuracy variable onto the data and show wether the given response was correct (true) or incorrect (false). Somehow it only returns 'false' for correct and incorrect responses.

In the tutorial they used jsPsych.pluginAPI.convertKeyCodeToKeyCharacter()

This doesn't work tho, I get the error:

lexical_decision.html:46 Uncaught TypeError: jsPsych.pluginAPI.convertKeyCodeToKeyCharacter is not a function

They used this to convert the key code into key characters, but this seemingly happens by default in the current version of jsPsych.

I'm sorry if this question is stupid, but I don't know why this isn't working.

Niyori
  • 1
  • 1

1 Answers1

0

If you are using jsPsych v6.3 or later then data.key_press is now called data.response. This was changed to help standardize the data variables across different plugin types.

This should work as an alternative to your current code:

on_finish: function(data){
    data.accuracy = data.correct_response == data.response
}
Josh
  • 2,105
  • 1
  • 14
  • 14