PennController for IBEX › Forums › Support › Progress bar for each sentence? › Reply To: Progress bar for each sentence?
May 4, 2023 at 2:31 pm
#10509
E.Inshakova
Participant
Hello Jeremy,
I added your piece of code into my script, but no progress bar appeared in the preview. Did I do something wrong?
PennController.ResetPrefix(null); const PROGRESS_SIZE = {w: 100, h: 20}; newTrial( newCanvas("progressContainer", PROGRESS_SIZE.w, PROGRESS_SIZE.h) .add(0,0,newCanvas("progress", PROGRESS_SIZE.w, PROGRESS_SIZE.h).color("green")) .css("border","solid 1px black") .center() .print() , newVar("timerInfo").set(()=>[Date.now(),15000]) // set the duration here , newFunction( "updateProgress", ()=>{ const [s,d] = getVar("timerInfo")._element.value; const p = (Date.now()-s) / d; if (p>1) return; getCanvas("progress").size((1-p)*PROGRESS_SIZE.w,PROGRESS_SIZE.h)._runPromises(); window.requestAnimationFrame( getFunction("updateProgress")._element.function ); } ).call() , // Experimental trial Template("items_pilot.csv", row => newTrial("pilot_experiment", defaultText .cssContainer({"margin-bottom":"1em"}) .css({"font-size": "large"}) .center() .print() , newTimer("break", 1000) //пауза между предложениями = 1 с .start() .wait() , newText("context", row.context) .css({"background-color": "LightCyan"}) , newText("sentence", row.sentence) , newScale("natural", "1", "2", "3", "4", "5", "6", "7") .before( newText("left", "Полностью неприемлемо ") ) .after( newText("right", " Полностью приемлемо") ) .log("last") .print() .callback(getTimer("timeout").stop()) , newVar("rating") .global() .set(getScale("natural")) , newTimer("timeout", 15000) .start() .wait() // , // getTimer("timeout") // .wait() ) .log("group", row.group) .log( "rating" , getVar("rating") ) .log("condition", row.condition) .log("item", row.item) .log("exp_number",row.exp_number) .log("construction", row.construction) .log("governor", row.governor) .log("noun", row.noun) .log("pr_n", row.pr_n) , getCanvas("progressContainer").remove() ));
Evgeniya Inshakova