Qualtrics Go/NoGo Task: Issue with Response Recording | XM Community
Skip to main content

I'm encountering an issue with a Qualtrics Go/NoGo task where participant responses aren't being recorded despite implementing JavaScript for response tracking. In the script, I initialize the score, determine the correct color for the "go" condition, and set the stimulus color accordingly. The script listens for spacebar key presses and updates embedded data with the score based on the trial's correctness. Despite these efforts, no response data is recorded in the survey results. 

 

JavaScript code:
```javascript
Qualtrics.SurveyEngine.addOnload(function() {
    Qualtrics.SurveyEngine.setEmbeddedData('score', -1); // Initialize score

    let color = "${e://Field/Color}";
    let condition = "${e://Field/Condition}";

    // Define the correct color for the "go" condition
    var correctGoColor = (condition === 'go') ? 'yellow' : 'blue'; 

    // Set the color of the gngstim element for the "go" condition
    jQuery("#gngstim").css('color', (correctGoColor === 'yellow') ? 'yellow' : 'blue');

    document.addEventListener("keydown", function(event) {
        // Check if the pressed key is the spacebar (key code 32)
        if (event.keyCode === 32) {
            // Determine if the current trial is a "go" or "no-go" trial based on the color
            var isGoTrial = (color === correctGoColor);

            // Check if the spacebar was pressed in a "go" trial (indicating a correct response)
            if (isGoTrial) {
                // Set embedded data to indicate correct response
                Qualtrics.SurveyEngine.setEmbeddedData('score', 1);
            } else {
                // Set embedded data to indicate incorrect response
                Qualtrics.SurveyEngine.setEmbeddedData('score', 0);
            }

            // Log information for debugging
            console.log("Color: " + color + ", Correct Go Color: " + correctGoColor + ", Is Go Trial: " + isGoTrial + ", Score: " + '${e://Field/score}');

            // Proceed to the next question
            this.clickNextButton();
        }
    });
});

Qualtrics.SurveyEngine.addOnUnload(function() {
    /* Place your JavaScript here to run when the page is unloaded */
});
```

Any insights on what might be causing this issue and how to resolve it would be greatly appreciated. Thank you for your help!

 

Which layout are you using?


 

I am unable to click on the layout option in the Look & Feel section.


Leave a Reply