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:checks [15.01.2015 20:08] – [Probing] alexander.ritteren:create:checks [23.11.2020 15:35] (current) – [Example: All Items or None at All] sophia.schauer
Line 66: Line 66:
 ===== Customized Response Check ===== ===== Customized Response Check =====
  
-If the predefined checks are insufficient, you can program a customized response check using a filter and the [[:en:create:functions:repeatpage|repeatPage()]] function.+If the predefined checks are insufficient, you can program a customized response check using a [[en:create:php-filters|PHP-filter]] and the [[:en:create:functions:repeatpage|repeatPage()]] function.
  
-The PHP code used to check the answer must be put on the page __after__ the question at the top. Therefore, if the question that needs to be checked is on page 2 then the PHP code that checks the question must be put at the top on page 3. +A detailed explanation and examples can be found in the [[:en:create:checks-php]] manual.
- +
-**Tip:** Further details about programming filters can be found under [[:en:create:filters|Filter Questions and Filters]]. +
- +
-**Tip:** Use the function ''[[:en:create:functions:markfail|markFail()]]'' to highlight inputs with incorrect responses. +
- +
-You will receive an error message when you display a text element using [[:en:create:functions:text|text()]] when answers are missing/incorrect. When you set up the text element make sure the text is displayed in the style of a //warning// -- then it will have the same format as the standard error messages. +
- +
-==== Example: All Items or None at All ==== +
- +
-The following PHP code checks whether all items in a scale were answered -- or none at all. The question's ID (in example ''AB01'') must therefore be changed to reflect the actual question ID and the error message must be saved as a text element. If this text element's ID is not "error_AB01" then the ID must also be customized. +
- +
-<code php> +
-// Create a list of all items in the question +
-$items = getItems('AB01'); +
-// Determine items answered +
-$answered = getItems('AB01', '>', 0); +
-// Error and go back if not all or none were answered +
-if ((count($answered) > 0) and (count($answered) < count($items))) { +
-  text('error_AB01'); +
-  repeatPage(); +
-+
-</code>+
  
  
en/create/checks.txt · Last modified: 23.11.2020 15:35 by sophia.schauer
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki