Hi! I have adapted some code so that participants have to spend 5 minutes minimum total on a section of the survey. It is not working though---it is making it so that participants have to spend 5 minutes just on the last page alone. Could someone look at this line of code and see where I am going wrong? The three subtractions are their three times spent on each relevant page
Qualtrics.SurveyEngine.addOnReady(function() {
var qobj = this;
qobj.disableNextButton();
var msTimeRemain = (5*60*1000)-(Number("${q://QID22/ChoiceNumericEntryValue/3}")*1000) -(Number("${q://QID27/ChoiceNumericEntryValue/3}")*1000 -(Number("${q://QID174/ChoiceNumericEntryValue/3}")*1000))
// ^ Update QIDx to QID of timing question on previous page ^
if(msTimeRemain>0) setTimeout(function() { qobj.enableNextButton(); },msTimeRemain);
else qobj.enableNextButton();
});
Any reason for you to not use the timing question type?
I have those for the first two pages of the instructions, but the time I want them to spend on page 3 depends on how long they've spent on pages 1 and 2, so it's not always going to be the same
rma703
Try this; I have made slight modifications in QID change it as per your survey. It will be a text entry value and within survey make a content validation of it to be number. Add it in questions you want it to work.
Qualtrics.SurveyEngine.addOnReady(function() {
var qobj = this;
qobj.disableNextButton();
var msTimeRemain = (5*60*1000)-(Number("${q://QID13/ChoiceTextEntryValue/7}")*1000) -(Number("${q://QID15/ChoiceTextEntryValue/4}")*1000 -(Number("${q://QID14/ChoiceTextEntryValue/3}")*1000))
// ^ Update QIDx to QID of timing question on previous page ^
if(msTimeRemain>0) setTimeout(function() { qobj.enableNextButton(); },msTimeRemain);
else qobj.disableNextButton();
console.log(msTimeRemain)
});
Hope this helps!
It unfortunately didn't work. Do you know if I need to update this part of the code?
"ChoiceTextEntryValue/3}" Not sure where this value comes from
rma703
Yes, you need to update that you can get that value easily. By clicking on the piped text on any question text and pipe in that value in any question or also within survey flow in front of embedded data and once entered just copy it and paste in JavaScript.
I was able to make the code work with those piped text values.
Hope this helps!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.