Differences

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

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
en:create:checks-php [22.07.2019 16:36] – created johannes.jungilligensen:create:checks-php [13.05.2022 18:47] saskia.mueller.577
Line 15: Line 15:
 You can display an error message if you enter the ID of a text module as an argument in the ''repeatPage()'' function (see below). Alternatively, you can also display a corresponding text block using [[:en:create:functions:text|text()]]. For the second variant, when creating the text module, select that the text is displayed in the style of a //warning// -- then it receives the same formatting as the standard error messages. You can display an error message if you enter the ID of a text module as an argument in the ''repeatPage()'' function (see below). Alternatively, you can also display a corresponding text block using [[:en:create:functions:text|text()]]. For the second variant, when creating the text module, select that the text is displayed in the style of a //warning// -- then it receives the same formatting as the standard error messages.
  
 +Below are some sample applications for individual response checks including the required PHP code.
  
-===== Example: Multiple Selection Matrix =======+===== Multiple Selection Matrix =======
  
 In an ordinary scale you can easily check whether the participant has selected an option in each line. But if you use a [[:en:create:combine|combined question]], which allows the participant several crosses per line (multiple choice matrix), then you need some PHP code to check if really something was selected in each line. In an ordinary scale you can easily check whether the participant has selected an option in each line. But if you use a [[:en:create:combine|combined question]], which allows the participant several crosses per line (multiple choice matrix), then you need some PHP code to check if really something was selected in each line.
Line 84: Line 85:
  
  
-===== Example: All Items or None at All ======+===== All Items or None at All ======
  
 The following PHP code checks whether all items on a scale were answered -- or none at all. The question identifier (in this example ''AB01'') must be changed according to the actual question identifier, the error message must be saved as a text module. If the identifier of this text module is not "error_AB01", this identifier must also be changed. The following PHP code checks whether all items on a scale were answered -- or none at all. The question identifier (in this example ''AB01'') must be changed according to the actual question identifier, the error message must be saved as a text module. If the identifier of this text module is not "error_AB01", this identifier must also be changed.
Line 99: Line 100:
 </code> </code>
  
 +===== Consistency check text input =====
 +
 +Open text inputs can be set to accept numbers only ([[:en:create:checks#input_of_numbers|Check_answers: input_of_numbers]]). The following is to check whether consistent values were entered in three input fields.
 +
 +* TX01_01 -- Number of people in the company
 +* TY02_01 -- Number of managers in the company
 +* TY02_02 -- Number of employees who are close to retirement
 +
 +It should now be ensured that the values for TY02_01 and TY02_02 are not higher than the total number of employees (TX01_01). If they are, the text with identifier TX02 should be displayed as an error message.
 +
 +The values retrieved by ''value()'' can be easily compared using the less-than (''<'') or greater-than (''>'') operator. The logical OR (''||'') checks if at least one of the two conditions is violated.
 +
 +
 +<code php>
 +if (
 +  (value('TY02_01') > value('TX01_01')) ||
 +  (value('TY02_02') > value('TX01_01'))
 +) {
 +  repeatPage('TX02');
 +}
 +</code>
en/create/checks-php.txt · Last modified: 13.05.2022 19:14 by saskia.mueller.577
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki