Thanks for the nice reply.
what I want is: set the time of each questionnaire, such as 1 min. after 1 min, it turns to next page.
what I did: first, random questions in different pages. second: set the limited time, such as 60s. third: show 'time is out'.
but it always failed.
here is the code I used:
first PHP code:
// PHP code on page 1
// shuffle list just once
if (!isset($questions)) {
// make a list of question IDs
$questions = array(
'S401', 'S409',
'S411', 'S412'
);
// shuffle list randomly
shuffle($questions);
// make lists available on all pages
registerVariable('questions');
}
$i = loopPage(count($questions));
question($questions[$i]);
second PHP code:
if (!isset($time0)) {
$time0 = time();
registerVariable('time0'); // store variable $time0 after the end of the PHP code as well
}
// Check if time has already expired
// (e.g. because the participant reloaded the page)
$timer = 60; // participant has 1 minute (6 seconds) to work through the page
if (time() >= $time0 + $timer) {
goToPage('next');
}
// JavaScript code has to be told the time remaining
$remain = $time0 + $timer - time();
replace('%remain%', $remain);
third code:
<script type="text/javascript">
<!--
// Function to forward
function next() {
// Display message (optional)
alert("Time's up.");
// Forward participant onto the next page
SoSciTools.submitPage();
}
// Initialization of forwarding
SoSciTools.attachEvent(window, "load", function(evt) {
// Hide Next button (optional)
SoSciTools.submitButtonsHide();
// Start timer to forward automatically
window.setTimeout(next, %remain% * 1000);
});
// -->
</script>