PennController for IBEX › Forums › Support › html layout/event times/selector vs. scale/ compatibility › Reply To: html layout/event times/selector vs. scale/ compatibility
Hi,
Because now I get in the result something like:
blank1 = sy
blank2 = ient
blank3 = ding
This would be what you get from the code of the blank
function from your last message, right (eg blank-1
)? Because the code of the blank
function I proposed would look something like blank-12
, blank-36
and blank-43
(the numbers correspond to the index in the string of each first _
in a series)
I am trying to code in a variable the expected answer so that I can compile the accuracy within the script.
Unless you need to show some feedback based on whether the participant answered accurately, it generally is a better idea to log raw responses and compute accuracy post data-collection. Logging raw responses is always a good idea anyway, and computing accuracy add unnecessary load during runtime
Now, assuming you always have exactly three textboxes, you could use global Var elements to store their content (by regularly inspecting the HTML elements, eg every 50ms) and log them as extra columns:
blank = sentence => Object({html: sentence.replace(/_+/g, (t,i)=>`<textarea name='blank${i}' rows=1 cols=${t.length+1} style='max-height: 1.7em'></textarea>`) }); newTrial("blank", newVar("answer1","").global(),newVar("answer2","").global(),newVar("answer3","").global() , newTimer("loop", 50).callback( getVar("answer1").set(v=>(document.querySelectorAll("textarea[name^='blank']")[0]||{value:v}).value ), getVar("answer2").set(v=>(document.querySelectorAll("textarea[name^='blank']")[1]||{value:v}).value ), getVar("answer3").set(v=>(document.querySelectorAll("textarea[name^='blank']")[2]||{value:v}).value ) , getTimer("loop").start() ).start() , newController("Form", blank("It was so ea__ to get lost in an anc__ buil____")) .print() .wait() ) .log("answer1", getVar("answer1")) .log("answer2", getVar("answer2")) .log("answer3", getVar("answer3"))
Or, if you are using Template
and have the expected responses in columns named, say, “Correct1,” “Correct2” and “Correct3”:
Template( row => newTrial("blank", newVar("answer1","").global(),newVar("answer2","").global(),newVar("answer3","").global() , newTimer("loop", 50).callback( getVar("answer1").set(v=>(document.querySelectorAll("textarea[name^='blank']")[0]||{value:v}).value ), getVar("answer2").set(v=>(document.querySelectorAll("textarea[name^='blank']")[1]||{value:v}).value ), getVar("answer3").set(v=>(document.querySelectorAll("textarea[name^='blank']")[2]||{value:v}).value ) , getTimer("loop").start() ).start() , newController("Form", blank("It was so ea__ to get lost in an anc__ buil____")) .print() .wait() , newVar("correct1").global().set(getVar("answer1")).set( v=>v==row.Correct1 ), newVar("correct2").global().set(getVar("answer2")).set( v=>v==row.Correct2 ), newVar("correct3").global().set(getVar("answer3")).set( v=>v==row.Correct3 ) ) .log("answer1", getVar("answer1")) .log("answer2", getVar("answer2")) .log("answer3", getVar("answer3")) .log("correct1", getVar("correct1")) .log("correct2", getVar("correct2")) .log("correct3", getVar("correct3")) )
Jeremy