This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
en:create:timer-submit [01.06.2016 14:28] – [Implementation] klaus-peter.speidel | en:create:timer-submit [28.04.2021 17:57] – [Display Countdown] sophia.schauer | ||
---|---|---|---|
Line 27: | Line 27: | ||
if (!isset($time0)) { | if (!isset($time0)) { | ||
$time0 = time(); | $time0 = time(); | ||
- | registerVariable(' | + | registerVariable(' |
} | } | ||
// Check if time has already expired | // Check if time has already expired | ||
Line 42: | Line 42: | ||
**Note:** If you want to use multiple, independent timers in the questionnaire, | **Note:** If you want to use multiple, independent timers in the questionnaire, | ||
- | **Different language versions** Use the translation support tool and copy-paste the suppression of the " | + | **Different language versions:** Use the translation support tool and copy-paste the suppression of the " |
If the participant is able to restart the timer by reloading the page or using the " | If the participant is able to restart the timer by reloading the page or using the " | ||
Line 50: | Line 50: | ||
</ | </ | ||
- | Create | + | For the actual timer, create |
+ | |||
+ | For the // | ||
<code javascript> | <code javascript> | ||
<script type=" | <script type=" | ||
<!-- | <!-- | ||
+ | |||
// 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, | SoSciTools.attachEvent(window, | ||
- | | + | |
- | SoSciTools.submitButtonsHide(); | + | |
// Start timer to forward automatically | // Start timer to forward automatically | ||
window.setTimeout(next, | window.setTimeout(next, | ||
Line 74: | Line 80: | ||
Some of the JavaScript sections are marked as // | Some of the JavaScript sections are marked as // | ||
+ | |||
+ | 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 '' | **Note:** If you want to display a message after the timer has expired using '' | ||
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, | ||
===== Display Countdown ===== | ===== Display Countdown ===== | ||
Line 99: | Line 109: | ||
<script type=" | <script type=" | ||
<!-- | <!-- | ||
+ | |||
// 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, | SoSciTools.attachEvent(window, | ||
- | | + | |
- | SoSciTools.submitButtonsHide(); | + | |
// Additional timer to update the countdown | // Additional timer to update the countdown | ||
window.setInterval(updateCountdown, | window.setInterval(updateCountdown, | ||
Line 138: | Line 153: | ||
window.setTimeout(next, | window.setTimeout(next, | ||
}); | }); | ||
+ | |||
// --> | // --> | ||
</ | </ |