Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision |
en:create:functions:looptopage [30.05.2016 14:05] – [1st example] info_familienwissenschaften | en:create:functions:looptopage [31.05.2016 09:33] – [2nd example] info_familienwissenschaften |
---|
''int **loopToPage**(string //pageID//, int //repititions//)'' | ''int **loopToPage**(string //pageID//, int //repititions//)'' |
| |
The function ''loopToPage()'' is used to show the pages from the current one to the page with the ID //pageID// multiple times, as often as the number of //repititions// are set. | The function ''loopToPage()'' is used to show the pages of the current page with the ID //pageID// multiple times, as often as the number of //repititions// are set. |
| |
This function specifies how often the pages have been repeated. On the first pass = 0, second pass = 1 etc. | This function specifies how often the pages have been repeated. In the first round = 0, second round = 1 etc. |
| |
**Important:** The function ''loopToPage()'' can not be used simultaneously with ''loopPage()'', ''setNextPage()'' or ''setPageOrder()''. | **Important:** The function ''loopToPage()'' can not be used simultaneously with ''loopPage()'', ''setNextPage()'' or ''setPageOrder()''. |
===== 1st example ===== | ===== 1st example ===== |
| |
You want to repeat page 5 to 8 of the survey 3 times. The page should show different questions each time. | You want to repeat page 5 to 8 of the survey 3 times with different questions each time. |
| |
* change the ID of page 8 to "loopend" (you can choose the ID as you wish) | * change the ID of page 8 to "loopend" (you can choose the ID as you wish) |
</code> | </code> |
| |
Now you want to have question ''A001'' to ''A005'' on the first pass. On the second pass you want question ''A101'' to ''A105'' to show on the page. And on the third pass question ''A201'' to ''A205'' | Now you want to have question ''A001'' to ''A005'' on the first round. On the second round you want question ''A101'' to ''A105'' to show up on the page. And on the third round question ''A201'' to ''A205'' |
| |
(the questions were made as section ''A0'' and the section has been copied two times by downloading it as a file and importing it again). | (the questions were created in section ''A0'' and the section has been copied twice by downloading it as a file and importing it again). |
| |
On page 5 you place the PHP-Code shown in the picture. It produces an array which contains a list of the questions and makes them available for the following pages via ''registerVariable()'' | On page 5 you place the PHP-Code shown in the picture. It produces an array which contains a list of the questions and makes them available for the following pages via ''registerVariable()'' |
</code> | </code> |
| |
To show the next questions on page 6 you have to place the following PHP-code on the page. The command ''loopPage()'' shows in which pass the page is revealed. The remaining code is equivalent to the code shown above. | To show the next questions on page 6 you have to place the following PHP-code on the page. The command ''loopPage()'' shows in which round the page is revealed. The remaining code is equivalent to the code shown above. |
| |
| |
Earlier on page 3 you asked a question with 10 possible //free mentions// as answers (''ON01''). You want to repeat the following pages for every answer given. | Earlier on page 3 you asked a question with 10 possible //free mentions// as answers (''ON01''). You want to repeat the following pages for every answer given. |
| |
You copy the section ''A0'' from the catalogue of questions nine times (section ''A1'' to ''A9''). With this the questions look like the following: | You copied the section ''A0'' from the catalogue of questions nine times (section ''A1'' to ''A9''). Accordingly the questions on page 5 are defined as follows: |
| |
| |
</code> | </code> |
| |
To make it more neat you can also use a FOR-loop. So as an alternative you could use the following PHP-code: | To make it more elegant you can also use a FOR-loop. Alternatively you can use the following PHP-code: |
| |
| |
</code> | </code> |
| |
It has to be specified how many "free mentions" the participant has given. With the command ''registerVariable()'' all answers are made available for the following pages. | Now it has to be specified how many "free mentions" the participant answered. With the command ''registerVariable()'' all answers are made available for the following pages. |
Along with that the length of the list is determined with the command ''count()''. The length of the list matches the loops of the pages. The command ''loopToPage()'' initializes the loops. | Along with that the length of the list is determined with the command ''count()''. The length of the list matches the loops of the pages. The command ''loopToPage()'' initializes the loops. |
| |