Danke,
vor allem die Erklärung dass loopPage() die Seitenabfolge unterbricht war hilfreich.
Die Idee mit der Wiederholung der Seite habe ich nicht ganz verstanden, doch ich habe es jetzt so geregelt, dass am Ende jeder loopPage() ein neues setPageOrder() kommt. Scheint zu funktionieren.
{<?xml version="1.0"?>
<questionnaire>
<!-- Page 1 -->
<page intID="1">
<php intID="2"><![CDATA[
// define list of tasks
$order_tasks = array('EmoRate', 'SexRate');
shuffle($order_tasks);
if (!isset($order_pages)) {
// define list of pages
if ($order_tasks[0] == 'EmoRate') {
$order_pages = array('One', 'FirstCounter', 'Three', 'Three', 'Two', 'SecondCounter', 'Four', 'Four');
registerVariable($order_pages);
} else if ($order_tasks[0] == 'SexRate') {
$order_pages = array('Two', 'SecondCounter', 'Three', 'Three','One', 'FirstCounter', 'Four', 'Four');
registerVariable($order_pages);
}
}
setPageOrder($order_pages);
// register var
registerVariable($my_first_counter);
registerVariable($my_second_counter);
$task_counter = 0;
registerVariable($task_counter);
html('<h1>the order is '.$order_pages[0].' , '.$order_pages[1].' , '.$order_pages[2].' , '.$order_pages[3].' , '.$order_pages[4].'</h1>');
]]></php>
</page>
<!-- Page 2 -->
<page ident="One" intID="3">
<php intID="6"><![CDATA[
html('<h1>One</h1>');
]]></php>
</page>
<!-- Page 3 -->
<page ident="Two" intID="4">
<php intID="7"><![CDATA[
html('<h1>Two</h1>');
]]></php>
</page>
<!-- Page 4 -->
<page ident="Three" intID="5">
<php intID="8"><![CDATA[
html('<h1>Three</h1>');
]]></php>
</page>
<!-- Page 5 -->
<page ident="FirstCounter" intID="11">
<php intID="12"><![CDATA[
$i = loopPage(1,2);
option('progress', $i/2*100);
if ($i == $my_first_counter){
option('progress', $i/$my_first_counter*100);
$my_first_counter++;
}
html('<h1> my First counter is '.(string)$my_first_counter.'</h1>');
// when finished, set new page order if this was the second task (or do nothing, and the pages continue in the default order)
if ($i == 2 & $task_counter == 1) {
$task_counter++; // add 1
$order_pages_2 = array( 'Four');
registerVariable($order_pages_2);
setPageOrder($order_pages_2);
} else if ($i == 2 & $task_counter == 0) {
$task_counter++; // add 1
}
]]></php>
</page>
<!-- Page 6 -->
<page ident="SecondCounter" intID="13">
<php intID="14"><![CDATA[
$i = loopPage(1,2);
option('progress', $i/2*100);
if ($i == $my_second_counter){
option('progress', $i/$my_second_counter*100);
$my_second_counter++;
}
html('<h1> my Second counter is '.(string)$my_second_counter.'</h1>');
// when finished, set new page order if this was the first task (or do nothing, and the pages continue in the default order)
if ($i == 2 & $task_counter == 0) {
$task_counter++; // add 1
$order_pages_2 = array( 'Three','One', 'FirstCounter', 'Four', 'Four');
registerVariable($order_pages_2);
setPageOrder($order_pages_2);
}
]]></php>
</page>
<!-- Page 7 -->
<page ident="Four" intID="9">
<php intID="10"><![CDATA[
html('<h1>Four</h1>');
]]></php>
</page>
</questionnaire>}