And logic in conditional statement

PennController for IBEX Forums Support And logic in conditional statement

This topic contains 1 reply, has 2 voices, and was last updated by Jeremy Jeremy 3 weeks, 1 day ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4877
    Avatar
    crtorma
    Participant

    Hi Jeremy,

    We have a study (SetSelection) where, for the practice trials, we do not want the participants to progress to the next trial until they get the current trial correct. The responses are collected as two separate variables, and in order for the trial to be considered ‘correct’, both variables must match the corresponding ‘correct’ numbers in the training items CSV. The problem I’m having is, I can’t make it so that the condition in the .wait() for the continue button only returns true (and therefore continues) if both variables are correct. The .test() function doesn’t seem conducive to && logic, and I’ve tried every other way I can think of — nesting, sequential, etc. Every way I’ve written it allows the participant to continue either a.) if only one variable is correct, or b.) after sufficient toggling of the items. Do you know why this is happening / what a solution might be?

    Thank you!

    #4879
    Jeremy
    Jeremy
    Keymaster

    Hi,
    There are two undocumented commands and and or that let you do just what you want, e.g:

    newTrial(
            newScale("score", 10).print()
            ,
            newSelector("text")
            ,
            newText("hello").print().selector("text")
            ,
            newText("world").print().selector("text")
            ,
            newButton("validate")
                .print()
                .wait( 
                    getScale("score").test.selected(5).and(
                        getSelector("text").test.selected( getText("hello") ) 
                    )  
                )
    )

    Be careful with selector.test.selected though, as it will crash if run when no element is selected. I’ll fix this bug in the next release, for the moment you should probably use a wait command on the selector before testing it.

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

You must be logged in to reply to this topic.