Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsPsych.pluginAPI.compareKeys handling null keys #1577

Closed
klanderson opened this issue Feb 27, 2021 · 3 comments
Closed

jsPsych.pluginAPI.compareKeys handling null keys #1577

klanderson opened this issue Feb 27, 2021 · 3 comments

Comments

@klanderson
Copy link
Contributor

Hi, just trying out jsPsych 6.3.0 (great update btw), and noticed that jsPsych.pluginAPI.compareKeys fails when one of the keys is null. Would you consider allowing null inputs? So the function would return false if any one input is null and true if both are null.

I'm handling null responses now as follows:

if (data.response != null) {
    data.hit = jsPsych.pluginAPI.compareKeys(data.response, data.correct_response);
} else {
    data.hit = false;
}
@becky-gilbert
Copy link
Collaborator

Hi @klanderson, thanks for the feedback, and for explaining the use case for null arguments here. This sounds like a very reasonable change to me.
@jodeleeuw I think this is a quick fix so I'm happy to do it, if you want to add this to 6.3.1?

@becky-gilbert
Copy link
Collaborator

Hi @klanderson, I've now changed this on the master branch version of jspsych.js, so jsPsych.pluginAPI.compareKeys will handle null values in the next release.

As of right now there haven't been any other changes to the master branch jspsych.js file since the 6.3.0 release on Feb 21. This means you could replace your v6.3.0 jspsych.js file with the master branch version to get this new functionality, without risking any compatibility issues. If you do this, it might be a good idea to double-check the jspsych.js commit history before downloading, to see if there have been any other changes made in the meantime.

@klanderson
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants