Auto refresh answer sheet after time period

From Catglobe Wiki
Jump to: navigation, search

This solution will help you refresh answer sheet after time period.

Here is a way that we can use to make this solution easily:

Preparing JavaScript Code for questionnaire's Java Script.

1 // IsTestMode : bool
2 // Parameters: string : eg: &T=1
3 window.callWF = function(IsTestMode, Parameters){
4   if(IsTestMode) document.location = "https://voxmeter.catglobe.com/Login.aspx?r=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&n=2&b=1&Test=1" + Parameters;
5   else		 	 document.location = "https://voxmeter.catglobe.com/Login.aspx?r=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&n=2&b=1" + Parameters;
6 }

Let's copy this code and replace the 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' by your questionnaire GUID. Then paste it into Questionnaire's Java script tab on Questionnaire Template Editor.

What is Questionnaire GUID? Don't worry, I will show you how to get it below.

Please see screenshot:

Get GUID.png

this screenshot will show you where you paste this script code:

Questionnaire js.png

Preparing JavaScript Code for question's Java Script.

 1 Question.bind('afterShowQuestion', function(question, answerSheet, element) {
 2  var time = 10000; //(milisecond) this is the time period that QAS was created new, it need to be set by manual
 3  var isTestMode = {{getRPQTest()?2:1;}} == 1;
 4  var parameter = ""; // we can put our parameter here. eg: &t=1
 5        
 6  var timer = setTimeout(function(){callWF(isTestMode,parameter)},time);
 7  $('.next:eq(0)').click(function(){
 8          clearTimeout(timer);
 9  });
10 });

When you finished with questionnaire java script code, let's continue with question java script code.

There are 2 variables that you must focus:

+ time: this is the time period that then we will refresh questionnaire answer sheet.(milisecond)

+ parameter: it is your parameter which you want to add more on the link of questionainare.

You also set to empty as default on above code.

When you completely finish the step preparing code for question java script, you must paste that code into the question which you use this solution.

Question js.png

Testing.

End of Documentation.