Translations of this page:

Table of Contents


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.

  • textelement (optional)
    If the ID of a text element is specified (created in Text Elements and Labels), this text element is displayed as information at the beginning of the repeated page. The text element is formatted in exactly the same way as other notifications regarding missing/incorrect data.

This function is particularly useful if the data submitted by the respondent is being assessed for validity. Many checks can be activated directly in the question or item (e.g. check whether all items in a scale were filled in, or if a certain text format was adhered to), but sometimes the check has to be programmed using PHP code. If this check turns out to be negative, a text element with a more suitable error message can be displayed using text() and the participant sent back to the previous page with repeatPage().

Note: In order for repeatPage() to work correctly, the check for invalid answers must be put at the beginning of the questionnaire page which follows the question checked!

Example 1

In the following example, the respondent should fill in just one of three text inputs (AB01_01, AB01_02 or AB01_03) on page 5 of the questionnaire. This is stated again in the text element “error_1of3”. On the following page (no. 6), the following PHP code is inserted for the check:

$answered = getItems('AB01', 'valid');
if (count($answered) != 1) {

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.

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 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.

//  only checked if IV01_01 is not yet set
if (value('IV01_01', 'code:ifany') != 2) {
  // check, if the answer is missing (code -9) in the selection BB01
  $failBB01 = (value('BB01') == -9);
  // check, if items in scale BC01 are unanswered
  $failBC01 = (count(getItems('BC01', 'missing')) > 0);
  if ($failBB01 || $failBC01) {
    // be aware that page 6 repeats/was repeated
    put('IV01_01', 2);
    // show previous page again
en/create/functions/repeatpage.txt · Last modified: 10.07.2024 12:34 by mokitul.fh-erfurt
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki