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

Addition of a self-paced reading plugin #145

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7841109
Setup inital spr template
vzhang03 Oct 7, 2024
ea27f01
Inital working version of SPR complete
vzhang03 Oct 7, 2024
4d4e9f3
Working version of SPR with multiple words
vzhang03 Oct 7, 2024
6c169d4
Commited working fix to us styling using span, need to finalize update
vzhang03 Oct 7, 2024
c3f5323
All modes working, need to work on error handling and making code mor…
vzhang03 Oct 13, 2024
e866583
Successfully added JsPsych integrated keyboard listener
vzhang03 Oct 13, 2024
b302f12
Successfully refactored mode 1 and 2 to be simpler and more efficient
vzhang03 Oct 13, 2024
2c321e4
Completed mode 3, moving onto ending the trial and data handling
vzhang03 Oct 13, 2024
af9dcd2
working data collection and end trial, updated examples to showfinal …
vzhang03 Oct 13, 2024
ebd4b0d
Documentation updates and fixing the modes refactoring code
vzhang03 Oct 18, 2024
51c1a67
Updated generateBlanks to account for chunks including multiple words
vzhang03 Oct 18, 2024
e1c16fc
Finished splitting parameters, finalizing documentation
vzhang03 Oct 18, 2024
4c57593
Tested styling to be workign
vzhang03 Oct 18, 2024
c44db43
Finished up documentation for the SPR md file
vzhang03 Oct 18, 2024
273ed1a
Finishing up documentation within the trial parameters
vzhang03 Oct 18, 2024
30769b4
Pushing changeset
vzhang03 Oct 18, 2024
7e7303b
Added initial data model, missing docuemntation
vzhang03 Oct 21, 2024
66a5ab4
Initial delimiter model
vzhang03 Oct 21, 2024
fb8d507
fix desc and update to v8
jadeddelta Oct 23, 2024
39c28de
flesh out docs and add choices param
jadeddelta Oct 26, 2024
23e839b
remove delimiter param, added logic to handle it instead
jadeddelta Oct 26, 2024
bcfa327
Finished up majority of data saving - issues with extra and keypress …
vzhang03 Nov 1, 2024
ca8830e
Key press is working, time elapsed since last is working, only now is…
vzhang03 Nov 2, 2024
57bb8f2
document data types, fix stimulus data issue
jadeddelta Nov 3, 2024
241aac9
Fixed mode three, removed unneccessary comments and slight logic changes
vzhang03 Nov 4, 2024
644436f
cleanup code, add some error handling, revise docs
jadeddelta Feb 1, 2025
88cd637
code rewrite, consolidate text input and remove `line_size`
jadeddelta Feb 2, 2025
617aa02
cleanup docs, handle edge cases in mode 2 and 3
jadeddelta Feb 2, 2025
44373fc
fix sentence presentation to match size of words
jadeddelta Feb 4, 2025
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
Prev Previous commit
Next Next commit
Updated generateBlanks to account for chunks including multiple words
  • Loading branch information
vzhang03 committed Oct 18, 2024
commit 51c1a67dec1f14cb8a2ac414b9e29f1203222f0e
2 changes: 1 addition & 1 deletion packages/plugin-spr/examples/mode2.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
const trial = {
type: jsPsychSpr,
reading_string: "this is the reading string",
structured_reading_string: [["first", "second", "third"], ["fith", "sixth", "seventh"], ["eighth", "ninth", "tenth"]],
structured_reading_string: [["first and second", "second and fourth", "third"], ["fith", "sixth", "seventh"], ["eighth", "ninth", "tenth"]],
mode: 2
};

Expand Down
39 changes: 23 additions & 16 deletions packages/plugin-spr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ class SprPlugin implements JsPsychPlugin<Info> {
this.structured_reading_string[this.index]
);
else document.querySelector("p")!.innerHTML = this.updateDisplayString();

this.jsPsych.pluginAPI.getKeyboardResponse({
callback_function: (info) => this.onSpacebarPress(info),
valid_responses: [" "],
rt_method: "performance",
persist: true,
allow_held_key: false,
});
}

private endTrial() {
Expand All @@ -107,6 +99,14 @@ class SprPlugin implements JsPsychPlugin<Info> {
this.structured_reading_string = trial.structured_reading_string;
else
this.structured_reading_string = this.createReadingString(trial.unstructured_reading_string);

this.jsPsych.pluginAPI.getKeyboardResponse({
callback_function: (info) => this.onSpacebarPress(info),
valid_responses: [" "],
rt_method: "performance",
persist: true,
allow_held_key: false,
});
}

// TODO: create a method that takes an entire string and uses a list of parameters to generate a "structured reading string"
Expand Down Expand Up @@ -222,20 +222,27 @@ class SprPlugin implements JsPsychPlugin<Info> {
private generateBlank(text: string | string[]): string {
// todo: make sure to split on individual words
const length = text.length;
var res = "";

// type of string (in context of plugin: chunk)
if (typeof text === "string") {
console.log(text.split(" "));
const split = text.split(" "); // checks for spaces to break up underscores

return "_".repeat(length);
} else {
// type of array
var res = "";
if (split.length > 1) {
for (var i = 0; i < split.length; i++) {
res += "_".repeat(split[i].length) + " ";
}
} else res = "_".repeat(length);
}
// type of array (in context of plugin: line)
else {
// var res = "";
for (var i = 0; i < length; i++) {
const word_length = text[i].length;
res += "_".repeat(word_length) + " ";
res += this.generateBlank(text[i]) + " ";
}
return res;
}

return res;
}
}

Expand Down