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
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
Fixed mode three, removed unneccessary comments and slight logic changes
  • Loading branch information
vzhang03 committed Nov 4, 2024
commit 241aac94bd7647d8b8089d46bcf86cdeb4970b07
53 changes: 17 additions & 36 deletions packages/plugin-spr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ class SprPlugin implements JsPsychPlugin<Info> {
private index: number = 0;
private inner_index: number = -1; // mode 1-2: initialized so that not shown if has an inner_index
private current_display_string: string[] = []; // mode 1-2: use this to save iterations
private displayed = false; // mode 3
private structured_reading_string: string[] | string[][] = [];
private mode: 1 | 2 | 3;
private results = [];
Expand All @@ -141,6 +140,7 @@ class SprPlugin implements JsPsychPlugin<Info> {
const blank = this.generateBlank(this.structured_reading_string[this.index]);
document.querySelector("p")!.innerHTML = blank;
this.addDataPoint(blank, this.index);
this.index = -1; // this initializes mode in way that allows to start at 0, might not be best way to do it
} else document.querySelector("p")!.innerHTML = this.updateDisplayString(); // update this, passing null for TS
}

Expand Down Expand Up @@ -238,6 +238,13 @@ class SprPlugin implements JsPsychPlugin<Info> {
newHtml = `<p>${this.updateDisplayString(info)}</p>`;
} else if (this.mode === 3) {
// might want to include incrementation here for consistency
this.index++;

if (this.index >= this.structured_reading_string.length) {
this.endTrial();
return;
}

newHtml = this.updateDisplayString(info);
}
// need to handle a keyboard press element where records how long until press a key
Expand Down Expand Up @@ -286,48 +293,22 @@ class SprPlugin implements JsPsychPlugin<Info> {
"</span>";

this.addDataPoint(this.current_display_string.join(" "), this.index, info.key);
// this.results[this.results.length - 1].push(
// this.structured_reading_string[this.index][this.inner_index],
// this.getElapsed(),
// info.key
// );
// this.results[this.results.length-1].push([this.getElapsed(), this.structured_reading_string[this.index][this.inner_index]]);
}
} else if (this.mode == 3) {
var newHtml = "";

if (!this.displayed) {
// accounts for bad user input (not necessary) and could move it up to input
if (typeof this.structured_reading_string[this.index] === "string")
newHtml = this.structured_reading_string[this.index] as string;
else {
for (const c of this.structured_reading_string[this.index]) {
newHtml += c + " ";
}
// accounts for bad user input (not necessary) and could move it up to input
if (typeof this.structured_reading_string[this.index] === "string")
newHtml = this.structured_reading_string[this.index] as string;
else {
for (const c of this.structured_reading_string[this.index]) {
newHtml += c + " ";
}
}

newHtml = "<p class='text-current-region'>" + newHtml + "</p>";
this.displayed = true;

this.addDataPoint(newHtml, this.index, info.key);
console.log("this is info.key:", info.key, "this is new Html", newHtml);
// this.results.push([this.getElapsed(), newHtml, info.key]); // pushes new list with time passed (time looking at blank)
} else {
this.index++;
this.displayed = false;

if (this.index >= this.structured_reading_string.length) {
this.endTrial();
} else {
newHtml =
"<p class='text-before-current-region'>" +
this.generateBlank(this.structured_reading_string[this.index]) +
"</p>";
}
newHtml = "<p class='text-current-region'>" + newHtml + "</p>";

this.addDataPoint(newHtml, this.index, info.key);
// this.results[this.results.length - 1].push(this.getElapsed(), info.key); // pushes second time spent looking at word
}
this.addDataPoint(newHtml, this.index, info.key);
return newHtml;
}

Expand Down