Reply To: html code with embedded script

PennController for IBEX Forums Support html code with embedded script Reply To: html code with embedded script

#5866
abraver
Participant

For more context, here’s the trial in question. I can print the value I’m looking for to the JavaScript console (console.log(data.data.totalCorrect) but I figure out how to get that into the PCIBex log no matter where I put the .log() function, and no matter whether I try to use data.data.totalCorrect as an argument of .log directly, or if I try to set a new variable and call getVar inside of .log.

newTrial("headphonecheck",
    newButton("check", "Start Heaphone Check")
        .print()
    ,
    // This Canvas will contain the test itself
    newCanvas("headphonecheck", 500,500)
        .print()
    ,
    // The HeadphoneCheck module fills the element whose id is "hc-container"
    newFunction( () => getCanvas("headphonecheck")._element.jQueryElement.attr("id", "hc-container") ).call()
    ,
    getButton("check")
        .wait()
        .remove()
    ,
    // Create this Text element, but don't print it just yet
    newText("failure", "Sorry, you failed the heaphone check")
    ,
    // This is where it all happens
    newFunction( () => {
        $(document).on('hcHeadphoneCheckEnd', function(event, data) {
            getCanvas("headphonecheck").remove()._runPromises();
            
                getButton("dummy").click()._runPromises();
                
                console.log("totalCorrect");
                console.log(data.data.totalCorrect);

        });
        HeadphoneCheck.runHeadphoneCheck({totalTrials: 1,
            trialsPerPage: 1,
            doCalibration: false // we definitely want to change this for the real one
        })

    }).call()

    ,
    
    // This is an invisible button that's clicked in the function above upon success
    newButton("dummy").wait()
    
)