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

response data in canvas-button-response plugin #2342

Closed
chif56 opened this issue Nov 22, 2021 · 1 comment · Fixed by #2287
Closed

response data in canvas-button-response plugin #2342

chif56 opened this issue Nov 22, 2021 · 1 comment · Fixed by #2287
Labels

Comments

@chif56
Copy link

chif56 commented Nov 22, 2021

Hi, thank you very much for your great works on jsPsych plugins!
I just want to report that response data was not saved in canvas-button-response (both on my local PC and on demo on https://www.jspsych.org/7.0).
The current code:

// add event listeners to buttons
          for (var i = 0; i < trial.choices.length; i++) {
              display_element
                  .querySelector("#jspsych-canvas-button-response-button-" + i)
                  .addEventListener("click", function (e) {
                  var choice = e.currentTarget;
                  choice.getAttribute("data-choice"); // don't use dataset for jsdom compatibility
                  after_response(choice);
              });
          }

The problem was fixed with the following:

// add event listeners to buttons
          for (var i = 0; i < trial.choices.length; i++) {
              display_element
                  .querySelector("#jspsych-canvas-button-response-button-" + i)
                  .addEventListener("click", function (e) {
                  var btn_el = e.currentTarget;
                  var choice = btn_el.getAttribute("data-choice"); // don't use dataset for jsdom compatibility
                  after_response(choice);
              });
          }
@jodeleeuw
Copy link
Member

Thanks for reporting this @chif56!

I coincidentally caught this bug a few days ago in the work for #2287 and patched it already. It'll be fixed when that PR is merged.

@jodeleeuw jodeleeuw linked a pull request Nov 22, 2021 that will close this issue
44 tasks
@jodeleeuw jodeleeuw added the bug label Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants