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:functions:setpageorder [07.12.2017 17:28] – [PHP-Code] janinejulianerp | en:create:functions:setpageorder [29.09.2020 17:49] – sophia.schauer | ||
---|---|---|---|
Line 27: | Line 27: | ||
**Note:** Filters can be inserted within the page order by using '' | **Note:** Filters can be inserted within the page order by using '' | ||
- | ===== Example 1 ===== | + | In the following the use of '' |
+ | |||
+ | ===== Two possible processes | ||
The following scenario should be implemented using '' | The following scenario should be implemented using '' | ||
Line 60: | Line 62: | ||
- | ===== Example 2 ===== | + | ===== Random sequence I ===== |
The questionnaire contains 5 pages that shall be displayed in random order. | The questionnaire contains 5 pages that shall be displayed in random order. | ||
Line 74: | Line 76: | ||
<code php> | <code php> | ||
if (!isset($pages)) { | if (!isset($pages)) { | ||
- | $pages = array(' | + | $pages = array(' |
shuffle($pages); | shuffle($pages); | ||
- | $pages[] = 'EM'; | + | $pages[] = 'PX'; |
registerVariable($pages); | registerVariable($pages); | ||
} | } | ||
Line 97: | Line 99: | ||
</ | </ | ||
+ | ===== Random sequence II ===== | ||
+ | In this example there are 3 blocks (A, B, C) with 3 to 5 pages (A1, A2, A3, B1, ...). The order of the blocks should be shuffled randomly and additionally the pages should be shuffled within each block -- only the first one should always stay at the beginning. | ||
+ | |||
+ | **Note:** See also the example under Rotation -> [[: | ||
+ | |||
+ | ==== Preparation ==== | ||
+ | |||
+ | If the individual pages are to be rotated, each page requires its own [[:en: glossary# | ||
+ | |||
+ | ==== PHP-Code ==== | ||
+ | |||
+ | <code php> | ||
+ | // First save the page labels as array | ||
+ | $rotation = array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | // Mix each block individually | ||
+ | foreach ($rotation as $key => $pages) { | ||
+ | // Remove the first page from the array $pages | ||
+ | $first = array_shift($pages); | ||
+ | // Mix the rest | ||
+ | shuffle($pages); | ||
+ | // Put the two back together again | ||
+ | array_unshift($pages, | ||
+ | // And save back to the $rotation array | ||
+ | $rotation[$key] = $pages; | ||
+ | } | ||
+ | |||
+ | // Now mix the order of the blocks randomly | ||
+ | shuffle($rotation); | ||
+ | |||
+ | // Now set the result as page sequence | ||
+ | // Continue with page ' | ||
+ | setPageOrder($rotation, | ||
+ | </ | ||
- | ===== Example 3 ===== | + | ===== Save sequence |
In the survey project there are five topical question blocks. To simplify matters, these are put in sections '' | In the survey project there are five topical question blocks. To simplify matters, these are put in sections '' |