Reply To: Choosing subet of items to present

PennController for IBEX Forums Support Choosing subet of items to present Reply To: Choosing subet of items to present

#6233
Jeremy
Keymaster

Hi Maria,

I think the two problems are related. All the commands in the success and failure blocks of a test are still part of the trial, even though upon runtime only one of the two blocks will effectively be run. Accordingly, all the new* declarations from either block are processed, which means that the code you’ve posted creates duplicates of sg_picture, pl_picture, sg_voicing and pl_voicing. That’s why when you try to .remove a picture, it can sometimes point to the wrong one (the one from the other block) and fail to effectively take it off the page. Regarding the Audio elements, I’m not sure why you see this specific problem, but I suspect problems will go away if you avoid creating the element twice.

Here is what your code looks like after factoring the creation of the elements:

const alt_test_trial = variable => [
    newImage("sg_picture", variable.SgPictureFile),
    newImage("pl_picture", variable.PlPictureFile),
    newAudio("sg_voicing", variable.SgVoicingFile),
    newAudio("pl_voicing", variable.PlVoicingFile)
    ,
    getVar("target").test.is("sg")
        .success( 
            newTimer(500)
                .start()
                .wait()
            ,
            getImage("pl_picture").print()
            ,
            newTimer(200)
                .start()
                .wait()
            ,
            getAudio("pl_voicing").play()
            ,
            newTimer(2000)
                .start()
                .wait()
            ,
            getImage("pl_picture").remove()
            ,
            getImage("sg_picture").print()
            ,
            newTimer(200)
                .start()
                .wait()
            ,
            newAudio("sg_devoicing", variable.SgDevoicingFile)
            ,
            newSelector("target")
                .log()
                .add( getAudio("sg_voicing"),getAudio("sg_devoicing") )
                .shuffle()
                .test.index( getAudio("sg_voicing"), 0 )
                .success(
                    getAudio("sg_voicing").play().wait(),
                    getAudio("sg_devoicing").play().wait(),
                    getSelector("target").keys("1","2").wait()
                )
                .failure( 
                    getAudio("sg_devoicing").play().wait(),
                    getAudio("sg_voicing").play().wait(),
                    getSelector("target").keys("2","1").wait()
                )
            ,
            newTimer(500)
                .start()
                .wait()
        )
        .failure( 
            newTimer(500)
                .start()
                .wait()
            ,
            getImage("sg_picture").print()
            ,
            newTimer(200)
                .start()
                .wait()
            ,
            getAudio("sg_voicing").play()
            ,
            newTimer(2000)
                .start()
                .wait()
            ,
            getImage("sg_picture").remove()
            ,
            getImage("pl_picture").print()
            ,
            newTimer(200)
                .start()
                .wait()
            ,
            newAudio("pl_devoicing", variable.PlDevoicingFile)
            ,
            newSelector("target")
                .log()
                .add( getAudio("pl_voicing"),getAudio("pl_devoicing") )
                .shuffle()
                .test.index( getAudio("pl_voicing"), 0 )
                .success(
                    getAudio("pl_voicing").play().wait(),
                    getAudio("pl_devoicing").play().wait(),
                    getSelector("target").keys("1","2").wait()

                )
                .failure( 
                    getAudio("pl_devoicing").play().wait(),
                    getAudio("pl_voicing").play().wait(),
                    getSelector("target").keys("2","1").wait()

                )
        )
]

Don’t forget to also update the other const declarations along the same lines, and don’t hesitate to ask questions

Jeremy