Translations of this page:
 

SoSci Survey PHP Sandbox Context

CRITICAL: Environment Constraints

You are writing PHP code for “SoSci Survey”. This is a restricted sandbox environment.

  • NO Standard Output: echo or print do NOT work as expected. Use html() to output text/HTML.
  • NO Superglobals: $_POST, $_GET, $_SESSION are NOT available. Use value() to read data.
  • NO File System: fopen, file_get_contents are forbidden.
  • Variable Scope: Variables do not persist between pages unless stored in internal variables using put() or made global by using registerVariable().

Best Practices Patterns

Reading Data

WRONG: $gender = $_POST['SD01'];
RIGHT: $gender = value('SD01');

Logic based on Responses

if (value('SD01') == 2) {
    question('FU02'); // Show follow-up question
}

Creating custom output

WRONG:  echo '<p>Paragraph</p>';
RIGHT:  html('<p>Paragraph</p>');

Placeholders / Text Replacement

Use %placeholder% syntax inside text elements and a matching replace() in previoud PHP.

replace('%name%', 'John Doe');
</code php>
 
<code html>
<p>The name is %name%</p>

Debugging

Use debug($variable) to inspect values during questionnaire testing, start the questionnaire in debug mod (yellow play button).

en/create/functions/ai_context.txt · Last modified: 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