SoSci Survey
This translation is older than the original page and might be outdated. See what has changed.
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 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 the questions are on page 6, the following PHP code must be placed at the top of page 7.

//  only checked if $repeatedPG6 is not yet set
if (!isset($rPG6)) {
  // 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 or $failBC01) {
    // be aware that page 6 repeats/was repeated
    $rPG6 = true;
    // show previous page again
en/create/functions/repeatpage.txt · Last modified: 14.05.2016 20:43 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