How to test whether multiple elements were selected?

PennController for IBEX Forums Support How to test whether multiple elements were selected?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #7453
    rhododendron
    Participant

    Hello,

    I am currently trying to implement three scales as a post-sentence comprehension task. Ideally, participants should not be able to proceed unless they made selections on each scale. So far, my implementation does only work for one scale, while all other scales are ignored. So far I have attempted to use a button press to check all three scales:

    newButton("validation", "Confirm")
         .settings.center()
         .print()
         .wait( getScale("comprehensibility_prac3","comprehensibility_prac2","comprehensibility_prac" ).test.selected()
               .failure(
                  newText("timedout","<b>Please rate the sentence using the scale!</b>")
                      .settings.css("font-size", "19px")
                      .settings.css("font-family","times-new")
                      .settings.color("red")
                      .settings.center()
                      .print() )
    )

    I have also tried to nest the tests, but it did not work:

    newButton("validation", "Confirm")
         .settings.center()
         .print()
         .wait( getScale("comprehensibility_prac3" ).test.selected()
               .failure(
                  newText("timedout","<b>Please rate the sentence using the scale!</b>")
                      .settings.css("font-size", "19px")
                      .settings.css("font-family","times-new")
                      .settings.color("red")
                      .settings.center()
                      .print() )
               .success(
                  getScale("comprehensibility_prac2").test.selected()
               .failure(
                  newText("timedout","<b>Please rate the sentence using the scale!</b>")
                      .settings.css("font-size", "19px")
                      .settings.css("font-family","times-new")
                      .settings.color("red")
                      .settings.center()
                      .print() )
    )
    )

    Any suggestions would be very much appreciated.

    Best,

    Ana-Maria

    #7463
    Jeremy
    Keymaster

    Hello Ana-Maria,

    Your reasoning is on the right track, but things work slightly differently: tests embedded in a success command won’t count as conjoined to the main test. For that, you have the and command. You can do this:

    newTrial(
        newScale("comprehensibility_prac1", 8).print(),
        newScale("comprehensibility_prac2", 8).print(),
        newScale("comprehensibility_prac3", 8).print()
        ,
        newButton("validation", "Confirm")
            .center()
            .print()
            .wait( 
                getScale("comprehensibility_prac3" ).test.selected()
                .and( getScale("comprehensibility_prac2").test.selected() )
                .and( getScale("comprehensibility_prac1").test.selected() )
                .failure(
                    newText("timedout","<b>Please use all the scales!</b>")
                        .css("font-size", "19px")
                        .css("font-family","times-new")
                        .color("red")
                        .center()
                        .print()     
                )
            )
    )

    Note that the error message will appear whenever any scale is unselected

    If you want scale-specific messages, you could conjoin all three tests to a main test, so you can apply test-specific failures:

    newTrial(
        newScale("comprehensibility_prac1", 8).print(),
        newScale("comprehensibility_prac2", 8).print(),
        newScale("comprehensibility_prac3", 8).print()
        ,
        defaultText
            .css("font-size", "19px")
            .css("font-family","times-new")
            .color("red")
            .center()
        ,
        newButton("validation", "Confirm")
            .center()
            .print()
            .wait( 
                newVar("dummy", 1).test.is(1)
                    .and( getScale("comprehensibility_prac3" ).test.selected().failure( 
                        newText("timedout3","<b>Please use scale 3!</b>").print()
                    ) )
                    .and( getScale("comprehensibility_prac2" ).test.selected().failure( 
                        newText("timedout2","<b>Please use scale 2!</b>").print()
                    ) )
                    .and( getScale("comprehensibility_prac1" ).test.selected().failure( 
                        newText("timedout1","<b>Please use scale 1!</b>").print()
                    ) )
            )
    )

    Jeremy

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.