PennController for IBEX › Forums › Support › Problems with test.text and selector.add in self-paced reading experiment
- This topic has 3 replies, 2 voices, and was last updated 3 years, 6 months ago by Jeremy.
-
AuthorPosts
-
April 1, 2021 at 12:06 pm #6797mschrumpfParticipant
Hello everyone.
I’m trying to implement a self-paced reading experiment with questions to test whether participants are actually comprehending the sentences.
My table contains questions and answers for a subset of the sentences. The rest of them only has a single blank space in each column.
I want my experiment to show a question and a selector element with the answers if there is a question.
If there is no question, I want to simply move on to the next prompt.
But I am running into two issues:1. No question or selector element is being shown in my current implementation. I more or less copied the code structure from the documentation on test.text, and I do not understand why this isn’t working.
2. The selector element does not show up, or if it does, the answers aren’t being shown. Again, I closely followed the doc pages and I cannot figure out what’s going wrong.Here is the relevant bit of code:
Template( "subco_english_acc2.csv" , row => newTrial( "experiment", newController("DashedSentence", {hideUnderscores: true, display: "dashed", s : row.Sentence}) .print() .log() .wait() .remove() , newText("Question", row.Question) .print() , getText("Question") .test.text( /\?$/ ) //Previously, this field contained " " and the instructions for failure and success were reversed .failure( newTimer(500).start().wait()) .success( newText("AnswerL", row.AnswerL) , newText("AnswerR", row.AnswerR) , newSelector("Answer") .add( getText("AnswerL").print() , getText("AnswerR").print() ) .keys( "F" , "J" ) .print() .log() ) ) )
Here are two lines from the table I’m using, as an example:
Experiment,Sentence,Item,Condition,Question,AnswerL,AnswerR,Correct MovingProc8,The architect/built/the monument/for two years/after/the city/had finally provided/the money for it.,1,1,"What did the city provide money for?","A monument","A gallery",L MovingProc8,The administrator/was installing/the program/for more than an hour/after/the new/computer pool/was set up.,29,3," "," "," ",N
For the first one, the question and the selector element should be displayed; for the second one, the trial should move on as soon as the self-paced reading is done.
Thank you for reading
MatthiasApril 1, 2021 at 1:17 pm #6801JeremyKeymasterHi Matthias,
You are not waiting for any interaction after your trial’s last command (
.log()
) so it moves on to the next trial before the participant can see anything. Simply stack.wait()
below that.log()
command and you will have ample time to read the question and press a key before your experiment moves on to the next trial 🙂Note however that your Text elements AnswerL/AsnwerR’s
.print()
commands are not executed in the scope ofselector.add
: that’s a bug, which I should fix, but anyway, you can move those.print()
commands onto thenewText
commands. Note also that the Selector element simply makes elements “selectable,” it does not control their position on the page (except, marginally, through theshuffle
command). If you want your two Text elements to be displayed on the same line, you can either use theafter
/before
commands, or place them on a Canvas element (or pass coordinates to theirprint
commands to position them relatively to the page, but in your case you probably want them to be printed below the preceding Text element “Question,” wherever that one ends up on the page)Jeremy
April 6, 2021 at 10:33 am #6838mschrumpfParticipantHi Jeremy,
thank you very much for your help. It’s those little details that slip through when I’m checking my own code. I have added the missing.wait()
command and a canvas for the selection task. The template looks like this now:Template( "subco_english_acc2.csv" , row => newTrial( "experiment", newController("DashedSentence", {hideUnderscores: true, display: "dashed", s : row.Sentence}) .print() .log() .wait() .remove() , newText("Question", row.Question) .center() .print() , getText("Question") .test.text( /\?$/ ) //Previously, this field contained " " and the instructions for failure and success were reversed .failure( newTimer(500).start().wait()) .success( newText("AnswerL", row.AnswerL).print() .after(newText("AnswerR", row.AnswerR).print()) , newText("F", "<b>F</b>") , newText ("J", "<b>J</b>") , newCanvas("Canvas", 600, 200) .add(0, 0, getText("AnswerL")) .add(400, 0, getText("AnswerR")) .add(0, 50, getText("F")) .add(400, 50, getText("J")) .print() , newSelector("Answer") .add( getText("AnswerL") , getText("AnswerR") ) .keys( "F" , "J" ) .print() .log() .wait() ) ) )
It doesn’t look great, but it works – just in case anyone is faced with a similar problem.
Best regards
MatthiasApril 6, 2021 at 11:57 am #6841JeremyKeymasterGlad to see that you got things to work!
Note that in this case, you have the alternative option to use the JavaScript ternary conditional rather than a
test
command, because the value you are checking (row.Question
) is already set at the beginning of your experiment and doesn’t change upon runtime. More information on this page of the documentationJeremy
-
AuthorPosts
- You must be logged in to reply to this topic.