Difference between revisions of "Auto refresh answer sheet after time period"

From Catglobe Wiki
Jump to: navigation, search
(v1)
(Tag: visualeditor)
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
Here is a way that we can use to make this solution easily:
 
Here is a way that we can use to make this solution easily:
# Preparing JavaScript - Java Script code for questionnaire's Java Script.<syntaxhighlight lang="javascript" line="1">
+
 
 +
==== Preparing JavaScript Code for questionnaire's Java Script. ====
 +
<syntaxhighlight lang="javascript" line="1">
 
// IsTestMode : bool
 
// IsTestMode : bool
 
// Parameters: string : eg: &T=1
 
// Parameters: string : eg: &T=1
Line 9: Line 11:
 
   else document.location = "https://voxmeter.catglobe.com/Login.aspx?r=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&n=2&b=1" + Parameters;
 
   else document.location = "https://voxmeter.catglobe.com/Login.aspx?r=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&n=2&b=1" + Parameters;
 
}
 
}
</syntaxhighlight>Let's copy this code and replace the '''<nowiki/>'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'<nowiki/>''' 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 belowPlease see screenshot:[[File:Get GUID.png|none|thumb|1431x1431px]]  this screenshot will show you where you paste this script:[[File:Questionnaire js.png|none|thumb|1305x1305px]] - Java Script code for question's Java Script.
+
</syntaxhighlight>Let's copy this code and replace the '''<nowiki/>'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'<nowiki/>''' by your questionnaire GUID. Then paste it into Questionnaire's Java script tab on Questionnaire Template Editor.   
# Adding to questionnaire
+
 
# Testing
+
What is Questionnaire GUID? Don't worry, I will show you how to get it below.
 +
 
 +
Please see screenshot:[[File:Get GUID.png|none|thumb|1431x1431px]]  this screenshot will show you where you paste this script code:[[File:Questionnaire js.png|none|thumb|1305x1305px]]
 +
==== Preparing JavaScript Code for question's Java Script. ====
 +
<syntaxhighlight lang="javascript" line="1">
 +
Question.bind('afterShowQuestion', function(question, answerSheet, element) {
 +
var time = 10000; //(milisecond) this is the time period that QAS was created new, it need to be set by manual
 +
var isTestMode = {{getRPQTest()?2:1;}} == 1;
 +
var parameter = ""; // we can put our parameter here. eg: &t=1
 +
     
 +
var timer = setTimeout(function(){callWF(isTestMode,parameter)},time);
 +
$('.next:eq(0)').click(function(){
 +
        clearTimeout(timer);
 +
});
 +
});
 +
</syntaxhighlight>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.[[File:Question js.png|none|thumb|998x998px]]
 +
==== Testing. ====
 +
End of Documentation.
 +
[[Category:Questionnaire]]

Latest revision as of 10:06, 6 July 2017

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.