This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:create:functions:setpageorder [07.12.2017 22:57] – old revision restored (16.03.2016 17:19) admin | en:create:functions:setpageorder [28.07.2022 21:58] (current) – admin | ||
|---|---|---|---|
| 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 76: | Line 78: | ||
| $pages = array(' | $pages = array(' | ||
| shuffle($pages); | shuffle($pages); | ||
| - | | + | |
| - | registerVariable($pages); | + | registerVariable($pages, ' |
| } | } | ||
| setPageOrder($pages); | setPageOrder($pages); | ||
| Line 93: | Line 95: | ||
| $pages = array(' | $pages = array(' | ||
| shuffle($pages); | shuffle($pages); | ||
| - | $pages[] = ' | + | // Set the order of pages to use, and the page where to continue after that |
| - | setPageOrder($pages); | + | setPageOrder($pages, ' |
| </ | </ | ||
| + | ===== 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 '' | ||