Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:create:functions:repeatpage [14.05.2016 20:43] – [repeatPage()] adminen:create:functions:repeatpage [10.07.2024 12:34] (current) – [Example 2] mokitul.fh-erfurt
Line 1: Line 1:
 ====== repeatPage() ====== ====== repeatPage() ======
  
-''void **repeatPage**([string //textelement//])''+''void **repeatPage** ([string //textelement//])''
  
 The function ''repeatPage()'' shows the previous page again. There is the option to display the text element in the style of an error message. The function ''repeatPage()'' shows the previous page again. There is the option to display the text element in the style of an error message.
Line 26: Line 26:
 ===== Example 2 ===== ===== Example 2 =====
  
-A onetime probe is also possible if the respondent does not answer a question with the help of //repeatPage()//. In the following example, it is checked if a valid option in the selection question ''BB01'' was selected and if the items in the scale ''BC01'' were answered in full.+A onetime probe is also possible if the respondent does not answer a question with the help of ''repeatPage()''. In the following example, it is checked if a valid option in the selection question ''BB01'' was selected and if the items in the scale ''BC01'' were answered in full.
  
-If one of the questions was not answered in full, the text element "error_missing" is displayed and the page repeated. However only once, as was ensured with ''registerVariable()'', variable ''$rPG6'' and ''isset()'' at the beginning+If one of the questions has not been answered completely, the text module "error_missing" is displayed and the page is repeated. But only once. This is achieved by setting an internal variable "IV01_01" to the value 2 for the first repetition. Please create the [[:en:create:questions:internal|internal variable]] in advance in the question catalogue and use the identifier of your internal variable instead of "IV01_01" in the code. If the page is called up again and the variable has the value 2, the response check is no longer triggered.
  
 If the questions are on page 6, the following PHP code must be placed at the top of page 7. If the questions are on page 6, the following PHP code must be placed at the top of page 7.
  
 <code php> <code php>
-//  only checked if $repeatedPG6 is not yet set +//  only checked if IV01_01 is not yet set 
-if (!isset($rPG6)) {+if (value('IV01_01', 'code:ifany'!= 2) {
   // check, if the answer is missing (code -9) in the selection BB01   // check, if the answer is missing (code -9) in the selection BB01
   $failBB01 = (value('BB01') == -9);   $failBB01 = (value('BB01') == -9);
Line 40: Line 40:
   $failBC01 = (count(getItems('BC01', 'missing')) > 0);   $failBC01 = (count(getItems('BC01', 'missing')) > 0);
  
-  if ($failBB01 or $failBC01) {+  if ($failBB01 || $failBC01) {
     // be aware that page 6 repeats/was repeated     // be aware that page 6 repeats/was repeated
-    $rPG6 = true; +    put('IV01_01', 2);
-    registerVariable('rPG6');+
     // show previous page again     // show previous page again
     repeatPage('error_missing');     repeatPage('error_missing');
en/create/functions/repeatpage.1463251433.txt.gz · Last modified: by admin
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki