Skip to content

Commit

Permalink
Run prettier on video-several-keyboard-responses plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoluc committed Dec 20, 2023
1 parent b2d06be commit e51a3be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ describe("video-several-keyboard-responses simulation", () => {
jest.runAllTimers();

await expectFinished();

const rt = getData().values()[0].rt;
const response = getData().values()[0].response;
const video_time = getData().values()[0].video_time;
expect(rt.every(value => value > 0)).toBe(true);
expect(response.every(value => typeof value === "string")).toBe(true);
expect(video_time.every(value => typeof value === "number")).toBe(true);
expect(rt.every((value) => value > 0)).toBe(true);
expect(response.every((value) => typeof value === "string")).toBe(true);
expect(video_time.every((value) => typeof value === "number")).toBe(true);
});
});
17 changes: 9 additions & 8 deletions packages/plugin-video-several-keyboard-responses/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class VideoSeveralKeyboardResponsesPlugin implements JsPsychPlugin<Info> {
var response = {
rt: null,
key: null,
video_time: null
video_time: null,
};

// function to end trial when it is time
Expand Down Expand Up @@ -291,18 +291,19 @@ class VideoSeveralKeyboardResponsesPlugin implements JsPsychPlugin<Info> {
var after_response = (info) => {
// after a valid response, the stimulus will have the CSS class 'responded'
// which can be used to provide visual feedback that a response was recorded
display_element.querySelector("#jspsych-video-several-keyboard-responses-stimulus").className +=
" responded";
display_element.querySelector(
"#jspsych-video-several-keyboard-responses-stimulus"
).className += " responded";

// by default only record the first response
if (response.key == null) {
if(!trial.multiple_responses_allowed){
if (!trial.multiple_responses_allowed) {
// Would make sense to add it to a list, but then it would not be backwards compatible?
response = {rt: info.rt, key: info.key, video_time: video_element.currentTime,};
}else{
response = {rt: [info.rt], key: [info.key], video_time: [video_element.currentTime]};
response = { rt: info.rt, key: info.key, video_time: video_element.currentTime };
} else {
response = { rt: [info.rt], key: [info.key], video_time: [video_element.currentTime] };
}
}else if (trial.multiple_responses_allowed){
} else if (trial.multiple_responses_allowed) {
response.rt.push(info.rt);
response.key.push(info.key);
response.video_time.push(video_element.currentTime);
Expand Down

0 comments on commit e51a3be

Please sign in to comment.