Adding an F/J key instead of a YES/NO scale

PennController for IBEX Forums Support Adding an F/J key instead of a YES/NO scale

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7049
    UgurcanVurgun
    Participant

    Hi Jeremy,

    I am just showing participants a picture and ask a question. I had a YES/NO scale for the answer, then we decided to replace it with an F/J key (F for YES and J for NO). When I try to insert a newKey instead of a scale, all the canvas gets mixed up. How can I insert the newKey without disrupting the flow?

    Thanks!

    Ugurcan Vurgun

    // Question 2
        newImage("Q1Image", "https:" + row.ImageURL1)
            .size(703,398)
            .print()
    ,
    	newText("Q1", "<p style=font-size:22px;>Did you see this image in the video?</p>")
    	    .print()
    ,
        newScale("Q1resp","<p style=font-size:22;><strong>Yes</strong></p>", 
                "<p style=font-size:22;><strong>No</strong></p>")
            .settings.labelsPosition("left")
            .print()
    ,
    	newButton("Q1Submit", "Submit")
    	    .print()
    ,
    	getCanvas("testcanv")
    		.remove(getVideo("eventTest"))
    		.add("center at 50%","center at 50%", getImage("Q1Image"))
    		.add("center at 50%",475, getText("Q1"))
    		.add("center at 50%",525, getScale("Q1resp"))
    		.add("center at 50%",675, getButton("Q1Submit"))
    ,
        getButton("Q1Submit")
            .wait()
    ,
        newVar("TQ1")
            .set(getScale("Q1resp"))
    ,
        getScale("Q1resp")
            .test.selected()
                .success()
                .failure(newText("Q1NoResp", "<p style=font-size:22px;>Please make a selection.</p>").color("red").bold().print().log()
                    ,
                    getButton("Q1Submit")
                        .wait(getScale("Q2resp").test.selected())
                    ,
                    getVar("TQ1")
                        .set(getScale("Q1resp"))
                    ,
                    getText("Q1NoResp").remove())
    
    #7050
    Jeremy
    Keymaster

    Hi Ugurcan,

    Using a Key element drastically simplifies the logic: you just print a Text element that says “F: Yes, J: No” and create and wait for a Key element:

    newImage("Q1Image", "https:" + row.ImageURL1).size(703,398)
    ,
    newText("Q1", "<p style=font-size:22px;>Did you see this image in the video?</p>")
    ,
    newText("Q1instr","<strong>F: Yes</strong> &nbsp; &nbsp; <strong>J: No</strong>")
    ,
    getCanvas("testcanv")
        .remove(getVideo("eventTest"))
        .add("center at 50%","middle at 50%", getImage("Q1Image"))
        .add("center at 50%",475, getText("Q1"))
        .add("center at 50%",525, getText("Q1instr"))
    ,
    newKey("Q1resp", "FJ").wait()
    ,
    newVar("TQ1")
        .set(getKey("Q1resp"))

    Jeremy

    #7051
    UgurcanVurgun
    Participant

    Hi Jeremy,

    Thank you. It works great!

    ugurcan

    #7052
    UgurcanVurgun
    Participant

    Hi Jeremy,

    I have just noticed that the result files show the selected keys as ‘undefined’. Do I have an error on the specific location of the setVar element? It seems like it doesn’t save the selection of the participant (A or L keys).

    Thanks for your help.

    Template("test.csv" ,
    	row => newTrial("test"
    ,
    	newVideo("eventTest", "https:" + row.VideoURL)
    		.size(703,398)
    		.disable(0.01)
    ,
        newCanvas("testcanv",1366, 550)
    	.add("center at 50%","center at 50%", getVideo("eventTest"))
    	.center()
    	.print()
    ,
        newButton("testvideo","Play")
    	.center()
    	.print()
    	.log()
    	.wait()
    ,	    
        getButton("testvideo")
    	.remove()
    ,
        getVideo("eventTest")
    	.center()
    	.play()
    	.log()
    ,
        getVideo("eventTest")
            .wait()
    ,
     
    //Question1
    
        newImage("Q1Image", "https:" + row.ImageURL1).size(703,398)
    ,
        newText("Q1", "<p style=font-size:22px;>Did you see this image in the video?</p>")
    ,
        newText("Q1instr","<strong>A: Yes</strong> &nbsp; &nbsp; <strong>L: No</strong>")
    ,
        getCanvas("testcanv")
            .remove(getVideo("eventTest"))
            .add("center at 50%","middle at 50%", getImage("Q1Image"))
            .add("center at 50%",475, getText("Q1"))
            .add("center at 50%",525, getText("Q1instr"))
    ,
        newKey("Q1resp", "AL")
            .wait()
    ,
        newVar("TQ1")
            .set(getKey("Q1resp"))
    ,
        newButton("Q1Submit", "Submit")
    	.center()
    	.print()
    	   	
    
    ,   getButton("Q1Submit")
            .wait()
            .remove()
    ,
    //Question2
        newImage("Q2Image", "https:" + row.ImageURL2).size(703,398)
    ,
        newText("Q2", "<p style=font-size:22px;>Did you see this image in the video?</p>")
    ,
        newText("Q2instr","<strong>A: Yes</strong> &nbsp; &nbsp; <strong>L: No</strong>")
    ,
        getCanvas("testcanv")
            .remove(getImage("Q1Image"))
            .remove(getText("Q1"))
            .remove(getText("Q1instr"))
            .add("center at 50%","middle at 50%", getImage("Q2Image"))
            .add("center at 50%",475, getText("Q2"))
            .add("center at 50%",525, getText("Q2instr"))
    ,
        newKey("Q2resp", "AL")
            .wait()
    ,
        newVar("TQ2")
            .set(getKey("Q2resp"))
    
    , 
        newButton("Q2Submit","Submit")
    	.center()
    	.print()
    	.wait()
            .remove()
    ,
    //Question3
        newImage("Q3Image", "https:" + row.ImageURL3).size(703,398)
    ,
        newText("Q3", "<p style=font-size:22px;>Did you see this image in the video?</p>")
    ,
        newText("Q3instr","<strong>A: Yes</strong> &nbsp; &nbsp; <strong>L: No</strong>")
    ,
        getCanvas("testcanv")
            .remove(getImage("Q2Image"))
            .remove(getText("Q2"))
            .remove(getText("Q2instr"))
            .add("center at 50%","middle at 50%", getImage("Q3Image"))
            .add("center at 50%",475, getText("Q3"))
            .add("center at 50%",525, getText("Q3instr"))
    ,
        newKey("Q3resp", "AL")
            .wait()
    ,
        newVar("TQ3")
            .set(getKey("Q3resp"))
    
    ,   newButton("Q3Submit","Submit and Continue")
    	.center()
    	.print()
    	.wait()
            .remove()
    	    
    ,	    
        ).setOption("hideProgressBar",true)
        .log("ID", getVar("ID"))
        .log("Q1Response", getVar("TQ1"))
        .log("Q2Response", getVar("TQ2"))
        .log("Q3Response", getVar("TQ3"))
        .log("Group",row.Group)
        .log("Condition", row.Condition)
        .log("Item", row.Item)
        .log("Video", row.Video)
        .log("Source", row.Source)
        .log("Truncated", row.Truncated)
        .log("Image1", row.Image1)
        .log("CorrectResp1", row.CorrectResp1)
        .log("Image2", row.Image2)
        .log("CorrectResp2", row.CorrectResp2)
        .log("Image3", row.Image3)
        .log("CorrectResp3", row.CorrectResp3)
      
    )
    #7053
    Jeremy
    Keymaster

    Hi Ugurcan,

    Your Var elements are not .global() so you cannot access them outside the parentheses of the containing newTrial command. Make sure to call .global() on them before calling .set

    Jeremy

    #7054
    UgurcanVurgun
    Participant

    Hi Jeremy,

    thanks a lot for your help!

    ugurcan

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