E.Inshakova

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: Progress bar for each sentence? #10513
    E.Inshakova
    Participant

    Thank you again, Jeremy!

    Everything works now.

    Evgeniya Inshakova

    in reply to: Progress bar for each sentence? #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()
    ));

    Link to my demo:

    Evgeniya Inshakova

    in reply to: Progress bar for each sentence? #10508
    E.Inshakova
    Participant

    Thanks a lot, Jeremy, that was really very helpful!

    Evgeniya Inshakova

Viewing 3 posts - 1 through 3 (of 3 total)