Exit button

PennController for IBEX Forums Support Exit button

This topic contains 3 replies, has 2 voices, and was last updated by Avatar diyu 3 weeks, 1 day ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4699
    Avatar
    diyu
    Participant

    Hi Jeremy,

    I’m looking to add an exit button into my experiment. Currently, it has 30 trials, but we don’t have any guarantee that the participants will be able to complete all of them by the end of allotted time. Optimally, I’d like to be able to add a button at the bottom of the screen that stays there consistently throughout the course of the experiment that would allow for all text entry results logged up until that point to be saved, while bypassing the rest of the trials and hopefully going straight to a farewell/exit screen. Is this possible, and if so, how would I implement it?

    Thank you!
    Diane

    #4700
    Jeremy
    Jeremy
    Keymaster

    Hi Diane,

    Yes, it’s possible, but clicking that button would be a point of no return for the participant. Here is one way of doing it (some of this code is hard to make sense of if you’re not already familiar with the arcane of Ibex)

    PennController.ResetPrefix(null);
    
    PennController.AddTable("myTable", `Label,Text
    target,Hello
    filler,hello
    target,World
    filler,world`)
    
    PennController.Sequence("welcome", rshuffle("target","filler"))
    
    PennController.Header(
        newCanvas("confirmation", '75vw', '80vh')
            .settings.css("background-color", "floralwhite")
            .settings.add( "center at 50%", "middle at 25%" , newText("Are you sure you want to send your incomplete results now?") )
            .settings.add( "center at 50%", "middle at 75%" , newScale("quit", "Yes", "No").settings.button() )
        ,
        newButton("stop", "Stop").settings.callback(
            getCanvas("confirmation")
                .print("center at 50vw", "middle at 50vh")
            ,
            getScale("quit").wait()
            ,
            getCanvas("confirmation").remove()
            ,
            getScale("quit").test.selected("Yes")
                .success(
                    getButton("stop").remove()
                    ,
                    newFunction( () => {
                        let mainNode = $("p.PennController-PennController");
                        mainNode.empty();
                        let options = {
                            _finishedCallback: r=>console.log("sent",r) ,
                            _cssPrefix: '',
                            _utils: { setTimeout: ()=>null }
                        };
                        addSafeBindMethodPair('__SendResults__');
                        mainNode['__SendResults__'](options);
                    }).call()
                )
        )
        .print("bottom at 98vh","right at 98vw")
    )
    
    PennController( "welcome" , newButton("Start").print().wait() )
    .noHeader()
    
    PennController.Template( "myTable",
        row => PennController( newButton(row.Text).print().wait() )
    )

    I’ll try to implement a user-friendly option in the next release

    I’m also working on a new PCIbex Farm which will use a new engine, and I’m trying to see if it could try to regular send partial results after each trial

    Let me know if you have any questions

    Jeremy

    #4729
    Jeremy
    Jeremy
    Keymaster

    To follow-up on this, I just released PennController 1.7 which lets you use SendResults() as a command to… send the results. So one can replace the whole newFunction... bit in the code above (including call()) with SendResults()

    #4876
    Avatar
    diyu
    Participant

    Hi Jeremy,

    Apologies for the late reply, and thank you for the code! It’s working as intended!

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

You must be logged in to reply to this topic.