Checking the quota - Qualtrics

Voxpopme help team -

The following code block can be added into a Qualtrics survey to check the video question quota, and direct the respondent if the quota has been hit on the video question.

  1. Before the video record page, add in a new survey page.
  2. Add a Multiple choice question on the page.
  3. Set the first option as "Active", and the second as "Inactive".
  4. Add in the skip logic, if "Active" is selected, route the respondent to the video question page. If "Inactive" is selected, route the respondent to the text question.
  5. Use the cog icon to add Javascript to the page.
  6. Make sure you replace just the "your_project_identifier_here" part of the url with your project identifier. 
  7. Paste in the Javascript below and hit save.

Qualtrics.SurveyEngine.addOnload(function() {

    //hide the next button
    this.hideNextButton();

    //hide the multiple choice 
    document.getElementsByClassName('ChoiceStructure')[0].style.visibility = 'hidden';

    function checkStatus(qualtricsThis) {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
            if (xhttp.readyState == 4 && xhttp.status == 200) {
                if (xhttp.responseText) {
                    var response = JSON.parse(xhttp.responseText);
                    //The question status is `active`
                    if (response.status && 'active' === response.status) {
                        qualtricsThis.setChoiceValue(1, true);
                        qualtricsThis.clickNextButton();
                    }
                    //The question status is `inactive` or `quota_full`
                    else {
                        qualtricsThis.setChoiceValue(2, true);
                        qualtricsThis.clickNextButton();
                    }
                }
            }
        };
        xhttp.open("GET", "https://www.voxpopme.com/recordStatus/your_project_identifier_here", true);
        xhttp.send();

    }

    var qualtricsThis = this;
    checkStatus(qualtricsThis);
});
Have more questions? Submit a request

0 Comments

Article is closed for comments.