Conditional training phase

PennController for IBEX Forums Support Conditional training phase

This topic contains 4 replies, has 2 voices, and was last updated by Avatar suz 5 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6382
    Avatar
    suz
    Participant

    Dear all,

    I was wondering, following up on this topic, whether (or how) I can make the training phase in a maze task such that training trial only ends when the participant has completed N sentences successfully. Background: the maze task is quite unnatural, so if the training phase only has two or three items, but the participant fails on all of them, that’s hardly a successful training phase; in turn, if a participant is quick on the uptake, having to go through five or six items might be unnecessary.

    So in other words, I was wondering if there was a way to add a conditional loop that counts the numbers of “successes”, and aborts the trial when it equals two, but as long as that condition is not met, it continues to loop through the file “training.csv”, allowing to present, say, four training items continually until success = 2 (I guess once I know how this can be done in principle, I’d be fine to add a condition that aborts the trial after 10 unsuccessful attempts to avoid infinite looping):

    
    Template("training.csv", row =>
        newTrial("training",
    
            newController("Maze", {s: row.Sentence, a: row.Distractor})
                .css("font-size", "1.5em")
                .css("font-family", "Verdana")
                .print()
                .log()
                .wait()
                .remove()
                .test.passed()
                .failure(newText("<br/>oops!").css("font-size", "1.5em").css("color", "red").print())
                .success(newText("<br/>great!").css("font-size", "1.5em").css("color", "green").print())
    
            ,
            newTimer(500).start().wait()
        )
    )
    
    

    From what I understand, I need to know where “success” is stored. Is this task possible in this code or would I need a separate function elsewhere? Is there a topic that addresses this? Afaik, it’s a rather commonly desired property, but I couldn’t find anything in the forum or the doc files (given my inexperience with JS).

    Any help much appreciated, as always.

    Best,
    Susanne

    • This topic was modified 5 months, 2 weeks ago by Avatar suz.
    • This topic was modified 5 months, 2 weeks ago by Avatar suz.
    #6385
    Jeremy
    Jeremy
    Keymaster

    Hi Susanne,

    You can increment a Var element upon success, check the value of that Var element at the beginning of your trials and only run them if it’s below 2. No need to resort to plain javascript:

    Template("training.csv", row =>
        newTrial("training",
            newVar("training_successes", 0)
                .global()
                .test.is( v => v > 2 )
                .success( end() )
            ,
            newController("Maze", {s: row.Sentence, a: row.Distractor})
                .css("font-size", "1.5em")
                .css("font-family", "Verdana")
                .print()
                .log()
                .wait()
                .remove()
                .test.passed()
                .failure( newText("<br/>oops!").css("font-size", "1.5em").css("color", "red").print() )
                .success(
                    getVar("training_successes").set( v => v+1 ),
                    newText("<br/>great!").css("font-size", "1.5em").css("color", "green").print()
                )
            ,
            newTimer(500).start().wait()
        )
    )

    Let me know if you have questions

    Jeremy

    #6386
    Avatar
    suz
    Participant

    Hi Jeremy,

    This is brilliant, thanks! So I gather that at failure it cannot re-use or re-loop through trainings.csv (judging from this topic I just found here)? That’s fine, I’ll just have 10 or so training items then, that should do the trick. (The progress bar is relative to the full number of possible items, so for early-finishers this will ‘jump’ a little, but that’s not a problem.)

    Again, thanks a lot for your swift response, I’m getting the hang of things!

    Best,
    Susanne

    #6387
    Jeremy
    Jeremy
    Keymaster

    Hi Susanne,

    Sorry, I hadn’t understood your question. You are correct, it’s not possible to re-loop through training.csv using PCIbex at the moment.

    Let me know if you have more questions

    Jeremy

    #6388
    Avatar
    suz
    Participant

    Hi Jeremy,

    Nah, that’s all for now, and exactly what I needed for the intended primary purpose. Thanks!

    —Susanne

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

You must be logged in to reply to this topic.