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

Plugin corsi blocks issue 141 #142

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/mighty-shrimps-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@jspsych-contrib/extension-countdown": patch
"@jspsych-contrib/extension-device-motion": patch
"@jspsych-contrib/extension-mediapipe-face-mesh": patch
"@jspsych-contrib/extension-touchscreen-buttons": patch
"@jspsych-contrib/plugin-corsi-blocks": minor
---

Plugin corsi blocks issue 141
In this updated version, the trial only ends when the response length matches the sequence length, regardless of whether the clicks were correct or not. This allows the user to register an incorrect sequence without ending the trial immediately.
4 changes: 2 additions & 2 deletions packages/plugin-corsi-blocks/examples/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@

timeline.push({
type: jsPsychCorsiBlocks,
sequence: [3,1],
sequence: [3,1,2],
mode: 'display'
});

timeline.push({
type: jsPsychCorsiBlocks,
sequence: [3,1],
sequence: [3,1,2],
mode: 'input'
});

Expand Down
9 changes: 4 additions & 5 deletions packages/plugin-corsi-blocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,14 @@ class CorsiBlocksPlugin implements JsPsychPlugin<Info> {
display_element
.querySelector(`.jspsych-corsi-block[data-id="${id}"]`)
.animate(correct_animation, animation_timing);
if (trial_data.response.length == trial.sequence.length) {
trial_data.correct = true;
setTimeout(end_trial, trial.response_animation_duration); // allows animation to finish
}
} else {
display_element
.querySelector(`.jspsych-corsi-block[data-id="${id}"]`)
.animate(incorrect_animation, animation_timing);
trial_data.correct = false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Pavel6625 for working on this? I was about to work on this feature as well. This helps our use case as well. I am wondering if this needs to be an optional feature (turned on or off via a feature flag). The old behavior might still be useful under certain circumstances.

// Only end the trial when the response length matches the sequence length
if (trial_data.response.length == trial.sequence.length) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: trial_data.response.length === trial.sequence.length

trial_data.correct = JSON.stringify(trial_data.response) === JSON.stringify(trial.sequence);
setTimeout(end_trial, trial.response_animation_duration); // allows animation to finish
}
};
Expand Down