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:pagestop [12.12.2014 17:34] alexander.ritteren:create:functions:pagestop [29.01.2025 13:59] (current) robin.bodenberger
Line 5: Line 5:
 This function prevents further contents of a questionnaire page being shown or executed. This function prevents further contents of a questionnaire page being shown or executed.
  
 +If there are other commands within a PHP code element in the questionnaire, ''pageStop()'' also prevents their execution.
  
-===== Example =====+===== Example: Screenout =====
  
 In the following example, ''pageStop()'' is combined with a screen out filter. This means further content (e.g. questions) can still be put on the screen out page. In the following example, ''pageStop()'' is combined with a screen out filter. This means further content (e.g. questions) can still be put on the screen out page.
Line 16: Line 17:
 <code php> <code php>
 if ((value('SK01') == 1) or (value('SK01') == 7)) { if ((value('SK01') == 1) or (value('SK01') == 7)) {
-  text('screenout'); +  text('screenout'); // Display text for screen out 
-  buttonHide(); +  buttonHide(); // Hide the Next button 
-  pageStop();+  setStatus('screenout'); // Store the status in the data set 
 +  pageStop(); // Do not display or execute any further content on the page
 } }
 </code> </code>
Line 43: Line 45:
 } else { } else {
   goToPage('next');   goToPage('next');
 +}
 +</code>
 +
 +**Important:** The text "screenout" may only be integrated into the questionnaire page via the PHP code. Do __not__ drag the text into the page as well.
 +
 +===== Example:Time Restriction =====
 +
 +Sometimes the survey project uses several questionnaires -- and not all of them should be available for the same time period. At the same time, only one survey period can be defined for the entire survey project in the **Project Settings**.
 +
 +With a small PHP filter on the first page of the questionnaire, you can specify that only an error message is displayed outside a defined time period.
 +
 +Create a new text in the **List of Questions** in a section of your choice. The following example assumes that the text has the identifier TX02. The following PHP code ensures that the questionnaire can only be completed in the period between 01/04/2021 and 30/06/2021.
 +
 +<code php>
 +if ((time() < strtotime('2021-04-01')) || (time() >= strtotime('2021-07-01'))) {
 +  text('TX02');
 +  buttonHide();
 +  pageStop();
 +}
 +</code>
 +
 +The survey period specified in the project settings must start before 4/1/2021 and/or end after 6/30/2021 for the filter to be active.
 +
 +In the same way, you can restrict that the questionnaire can only be filled out in a certain time window. The following PHP code allows filling in only from 9 to 11 o'clock.
 +
 +<code php>
 +if ((date('h') < 9) || (date('h') > 11)) {
 +  text('TX02');
 +  buttonHide();
 +  pageStop();
 } }
 </code> </code>
en/create/functions/pagestop.1418402097.txt.gz · Last modified: by alexander.ritter
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki