Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:create:timer-submit [01.06.2016 14:28]
klaus-peter.speidel [Implementation]
en:create:timer-submit [28.04.2021 17:57]
sophia.schauer [Display Countdown]
Line 27: Line 27:
 if (!isset($time0)) { if (!isset($time0)) {
   $time0 = time();   $time0 = time();
-  registerVariable('time0');  // store variable $time0 after the end of the PHP code as well +  registerVariable('$time0');  // store variable $time0 after the end of the PHP code as well 
 } }
 // Check if time has already expired // Check if time has already expired
Line 50: Line 50:
 </code> </code>
  
-Create a new text element Iin **Text Elements and Labels** for the actual timer with the following contentDrag this text element directly below the PHP code on the questionnaire page.+For the actual timer, create a new text module in the **Question catalog** in a section with **New text** __or__ under **Text modules and labeling**. 
 + 
 +For the //Display//, please set "HTML code". Then insert the following content.
  
 <code javascript> <code javascript>
 <script type="text/javascript"> <script type="text/javascript">
 <!-- <!--
 +
 // Function to forward // Function to forward
 function next() { function next() {
Line 62: Line 65:
   SoSciTools.submitPage();   SoSciTools.submitPage();
 } }
 + 
 +// Hide next button (optional)
 +SoSciTools.submitButtonsHide();
 +
 // Initialization of forwarding // Initialization of forwarding
 SoSciTools.attachEvent(window, "load", function(evt) { SoSciTools.attachEvent(window, "load", function(evt) {
-  // Hide Next button (optional) +  
-  SoSciTools.submitButtonsHide();+
   // Start timer to forward automatically   // Start timer to forward automatically
   window.setTimeout(next, %remain% * 1000);   window.setTimeout(next, %remain% * 1000);
Line 74: Line 80:
  
 Some of the JavaScript sections are marked as //optional//. These sections can be removed where necessary. Some of the JavaScript sections are marked as //optional//. These sections can be removed where necessary.
 +
 +After saving, drag this text module directly below the PHP code onto the questionnaire page.
  
 **Note:** If you want to display a message after the timer has expired using ''alert()'', the time taken to close the message will appear in the dwell time in the data record. The dwell time that is saved is therefore higher than the timer actually for the participant to be on the page. **Note:** If you want to display a message after the timer has expired using ''alert()'', the time taken to close the message will appear in the dwell time in the data record. The dwell time that is saved is therefore higher than the timer actually for the participant to be on the page.
Line 84: Line 92:
  
 Now insert text elements and/or questions to be shown in the questionnaire underneath the PHP and JavaScript codes. Positioning them below the PHP code is important to ensure the filter works properly if time has already expired. Now insert text elements and/or questions to be shown in the questionnaire underneath the PHP and JavaScript codes. Positioning them below the PHP code is important to ensure the filter works properly if time has already expired.
 +
 +**Multilingual versions:** If you use different languages for the questionnaire, use the translation help tool (under language versions) and copy the code for the timer into the different language versions.
  
 ===== Display Countdown ===== ===== Display Countdown =====
Line 99: Line 109:
 <script type="text/javascript"> <script type="text/javascript">
 <!-- <!--
 +
 // Function to forward // Function to forward
 function weiter() { function weiter() {
Line 106: Line 117:
   SoSciTools.submitPage();   SoSciTools.submitPage();
 } }
 +
 // Display countdown // Display countdown
 var date0 = new Date(); var date0 = new Date();
Line 128: Line 140:
   out.appendChild(displayNode);   out.appendChild(displayNode);
 } }
 +
 +// Hide Next button (optional)
 +  SoSciTools.submitButtonsHide();
 +  
 // Initialize forwarding // Initialize forwarding
 SoSciTools.attachEvent(window, "load", function(evt) { SoSciTools.attachEvent(window, "load", function(evt) {
-  // Hide Next button (optional) +  
-  SoSciTools.submitButtonsHide();+
   // Additional timer to update the countdown   // Additional timer to update the countdown
   window.setInterval(updateCountdown, 1000);   window.setInterval(updateCountdown, 1000);
Line 138: Line 153:
   window.setTimeout(next, %remain% * 1000);   window.setTimeout(next, %remain% * 1000);
 }); });
 +
 // --> // -->
 </script> </script>
en/create/timer-submit.txt · Last modified: 28.04.2021 17:57 by sophia.schauer
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki