PennController for IBEX › Forums › Support › Get the previous row of a column › Reply To: Get the previous row of a column
May 30, 2023 at 3:28 pm
#10642
Larissa_Cury
Participant
We have to erase the counter if the answer is right in case a participant get 1 error followed by a correct answer (which is allowed), not in case we have two sequential errors, I wrote it wrong above.
My attempt in Pcibex was this, but I got stuck…
// CREATE an error count outside "loop" so that it doesn't gets erased whenever a trial starts
let errorNum = 0;
Template("newStimuliShort.csv", row =>
newTrial("listOfNumbers",
defaultText
.cssContainer({
padding: '0.5em',
'text-align': 'center',
"justify-content": 'center',
"align-items": 'center' ,
'font-size': '50px',
})
.center()
.print()
,
newMediaRecorder("recorder", "audio").log().record()
// ,
// newTimer("recording", 60000).log().start()
,
newText("words", row.sequence) // Display sequences
,
newAudio("audio", row.audio) // play corresponding audio (which is in Portuguese)
.play()
,
getAudio("audio").wait("first") // wait audio finishes
,
newAudio("beep", "beep.mp3")
.play()
,
getAudio("beep").wait("first") // wait audio finishes
,
newVar("currLen").set(row.lenNumeric) // get current i length of "sequence"
,
newKey("NEXT", "SK")
.wait()
.log()
,
getKey("NEXT")
.disable() // make sure we only have 1 answer - participant can only answer once
,
getKey("NEXT")
.test.pressed("S")
.success(
newText("success", 'yey'), // if the answer is right,
getVar("errorNum").set(0)) // make sure to erase the error count in case a participant get 1 error followed by a correct answer
.failure(
newVar("errorCount").set( errorNum + 1) // Increase error count by 1 ans store it in a variable called 'errorCount'
,
// I would need sth here to store the errors so that k + k generates errorCount = K , then I guess I could use .testIs() to see if errorCount === 2. If yes, then
we should check if the current length equals the last length and break the experiment in case it's TRUE. Otherwise just erase the error count again and the
experiment continues
// newText("lastLen", row.lenNumeric).map((w,i) => <code>${w[i - 1]}</code>) // get the last length ---- COULDN'T DO IT!!
// ,
newText("failure")
// .text( getVar("errorCount") ) // I was displaying just to see if it was working
.text(getVar("errorCount")) // I was displaying just to see if it was working
.cssContainer({"font-size":"30px", "text-align":"center", "margin-top":"255px","font-family":"Comic Sans MS", "color":"red","white-space":"nowrap"})
)
,
newTimer("wait-success",100) //timer for the success or failure messenge
.start()
.wait()
,
getText("success")
.remove()
,
getText("failure")
.remove()
// ,
// getTimer("recording").wait()
,
getMediaRecorder("recorder").stop()
)
);
PS: I tried to use 0 and 1 instead of letters for the keypress, but I couldn’t do it. I guess it was interpreting 0 and 1 as strings, not numbers, how would I overcome that as well ?
- This reply was modified 1 year, 4 months ago by Larissa_Cury. Reason: forgot to put block code