Trouble storing/printing value of selector element to results file

PennController for IBEX Forums Support Trouble storing/printing value of selector element to results file

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4335
    CBill
    Participant

    Hi,

    I would like to store the value of a Selector element in in a Variable and then have it logged on every row pertaining to each relevant item. I believe this is possible, however, when I try I get the following error: ‘Command ‘toJSON’ unknown on Image element ‘HappyFace’.’

    Any idea what might be going on? The code for the relevant items is the following:

    PennController.Template(PennController.GetTable( "training.csv" ),
        variable => PennController("training",
        newTimer(500)
            .start()
            .wait()
        ,
        newAudio("sentence", variable.AudioFile)
        ,
        newImage("image", variable.Image)
            .settings.size(250, 187.5)
        ,
        newImage("HappyFace", "HappyFace.png")
            .settings.size(133, 133)
        ,
        newImage("SadFace", "SadFace.png")
            .settings.size(133, 133)
        ,
        newImage("DogFace", "DogFace.png")
            .settings.size(71, 53)
        ,
        newCanvas("myCanvas", 450, 450)
            .settings.add("center at 50%", "middle at 25%", getImage("image"))
            .settings.add("center at 25%", "middle at 75%", getImage("HappyFace"))
            .settings.add("center at 75%", "middle at 75%", getImage("SadFace"))
            .settings.add("center at 50%", "middle at 100%", getImage("DogFace"))
            .print()
        ,
        newSelector()
            .settings.add(getImage("DogFace"))
            .settings.callback(getAudio("sentence")
                .play()
                .settings.log("play")
                .settings.log("end")
                .wait("first"))
        ,
        newVar("Response")
        ,
        newSelector("SelectedResponse")
            .settings.add(getImage("HappyFace"), getImage("SadFace"))
            .settings.log()
            .settings.once()
            .wait()
            .setVar("Response")
        ,
        newTimer(500)
            .start()
            .wait()
    )
        .log("ID" , getVar("ID") )
        .log("Type", variable.Type)
        .log("Condition", variable.Condition)
        .log("Item", variable.Item)
        .log("Response", getVar("Response"))
        .log("CorrectResponse", variable.CorrectResponse)
        .log("StartDet", variable.StartDet)
    );
    • This topic was modified 4 years, 4 months ago by CBill. Reason: Typos
    #4337
    Jeremy
    Keymaster

    Hi Cory,

    It’s a known bug of sorts: you are storing the image element itself in the variable, rather than the name of the element, which is presumably what you want to get in your log command. I’ll see if I can fix it in the next release of PennController, because I think what you’re doing makes total sense.

    In the meantime, here is what you can do:

    newVar("Response")
        .settings.global()
    ,
    newSelector("SelectedResponse")
        .settings.add(getImage("HappyFace"), getImage("SadFace"))
        .settings.log()
        .settings.once()
        .wait()
        .test.selected(getImage("HappyFace"))
        .success( getVar("Response").set("HappyFace") )
        .failure( getVar("Response").set("SadFace") )

    I’m making the Var element global because you are accessing it from outside PennController(), even though it seemed to be working even without the .settings.global() line…

    Jeremy

    #4338
    CBill
    Participant

    Hi Jeremy,

    Oh ok, that makes sense. And I’m ‘glad’ it is a bug as I was going crazy trying to figure out where I had gone wrong with the code.

    Thanks alot for that suggested work-around, it should work nicely.

    – Cory

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