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.
- Before the video record page, add in a new survey page.
- Add a Multiple choice question on the page.
- Set the first option as "Active", and the second as "Inactive".
- 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.
- Use the cog icon to add Javascript to the page.
- Make sure you replace just the "your_project_identifier_here" part of the url with your project identifier.
- 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);
});
Comments
0 comments
Article is closed for comments.