Reply To: Need help implementing an “abort trial” option for a SPR design

PennController for IBEX Forums Support Need help implementing an “abort trial” option for a SPR design Reply To: Need help implementing an “abort trial” option for a SPR design

#10833
Jeremy
Keymaster

Hello,

Since you are using exclusively IBEX code, and no PennController code like the newKey you mention, it’s probably simpler to just edit the DashedSentence controller to add an abort key. Just edit the file DashedSentence.js from your project’s Modules folder:

1. Insert a new line between line 203 (}) and line 204 (else {) and paste this:

                else if (code == 81) {
                    t.sprResults[t.currentWord-1][0] = time;
                    t.sprResults[t.currentWord-1][1] = t.previousTime;
                    t.processSprResults(t.currentWord);
                    t.finishedCallback(t.resultsLines);
                }

2. Edit line 291 (previously line 285 before the aforementioned insertion) and change if from processSprResults: function () { to processSprResults: function (abortAt=-1) {

3. Just a couple lines below, you have a block of 10 lines that start with for and end with }. Replace them with this:

        for (var i = 0; i < nonSpaceWords.length; ++i) {
            if (i==abortAt)
                this.resultsLines.push([
                    ["Word number", i],
                    ["Word", "__ABORT__"],
                    ["Reading time", "NA"],
                    ["Newline?", false],
                    ["Sentence (or sentence MD5)", this.sentenceDesc]
                ]);
            this.resultsLines.push([
                ["Word number", i+1],
                ["Word", csv_url_encode(nonSpaceWords[i])],
                ["Reading time", abortAt>=0 && i>=abortAt ? "NA" : this.sprResults[i][0] - this.sprResults[i][1]],
                ["Newline?", (! this.display == "in place") &&
                             boolToInt(((i+1) < this.wordOSpans.length) &&
                             (this.wordOSpans[i].offset().top != this.wordOSpans[i+1].offset().top))],
                ["Sentence (or sentence MD5)", this.sentenceDesc]
            ]);
        }
        if (abortAt==nonSpaceWords.length)
            this.resultsLines.push([
                ["Word number", nonSpaceWords.length],
                ["Word", "__ABORT__"],
                ["Reading time", "NA"],
                ["Newline?", false],
                ["Sentence (or sentence MD5)", this.sentenceDesc]
            ]);

Now you can press Q to abort the self-paced reading instance. The results file will report a line that says “__ABORT__” for the last word shown on the screen, and the reaction times will be NA from there on (because the next words won’t have been displayed)

If you want to use a different key from Q, you can look up the event.which column from this table and replace 81 in the bit from step 1 above with the value of your choice (for example, 27 if you’d rather use the Escape key)

Jeremy