Reply To: html code with embedded script

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



You cannot directly send messages to the Logs (or Errors) tab of the Debug window. Your console.log commands will send messages to the javascript console.

Note that neither console.log nor a line appearing in the Logs tab of the Debug window means that the relevant event/value will be logged in the results file.

If you want to save totalCorrect in the results file, you will need to sort of “hack” into how PennController-native elements are handled. In practice, it basically just means adding ._runPromises() after the series of PennController commands (like the code’s already doing with the dummy Button element):

    newButton("check", "Start Heaphone Check")
    // This Canvas will contain the test itself
    newCanvas("headphonecheck", 500,500)
    // The HeadphoneCheck module fills the element whose id is "hc-container"
    newFunction( () => getCanvas("headphonecheck")._element.jQueryElement.attr("id", "hc-container") ).call()
    // 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) {
                getVar("totalCorrect").set( )._runPromises();
        HeadphoneCheck.runHeadphoneCheck({totalTrials: 1,
            trialsPerPage: 1,
            doCalibration: false // we definitely want to change this for the real one

    // This is an invisible button that's clicked in the function above upon success
.log( "totalCorrect" , getVar("totalCorrect") )

Note that you won’t get any reports of totalCorrect in your results file for participants who fail the headphone check, as the experiment will never move to the next trial, so nothing will get sent to the server.