[[replace()]]
This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:
 

This is an old revision of the document!


replace()

With the help of placeholders, text in the questionnaire (e.g. question titles, items, stimuli) can be dynamically adapted. For detailed instructions, please see the chapter Placeholders. The function replace() sets up a placeholder for use in the questionnaire.

void replace(string placeholder, string content, [string type])

  • placeholder
    The placeholder subsequently used. A placeholder is put between percentage signs (%). Please take the rules for customized placeholders into consideration.
  • content
    Normally the text used instead of the placeholder. Depending on the type specified afterwards, a variable ID could also be stated here.
  • type
    • 'text' – (default) The content is read as plain text.
    • 'html' – The content is read as HTML code. HTML special characters (such as < or >) are tranferred unmasked into the questionnaire's source code.
    • 'response' A variable ID is specified as the content. The placeholder should be replaced with the response of the participant to this variable. The way the response is determined is equivalent to value(..., 'text'). Note: The participant must first transmit the response to the server with “Next” before it can be called up with PHP code. Therefore, replace(…, 'response') must not be used on the same page as the question; on the following page at the earliest.
    • 'special' – Use one of the following IDs as content to employ dynamic data for the placeholder:
      • 'qn-' – The last number used for a question (e.g., to refer to the previous question in instructions).
      • 'qn+' – Create a new question number (e.g., to add a number to custom form inputs).

Examples

// Replace %brand% with "SoSci Survey" 
replace('%brand%', 'SoSci Survey');
 
// Replace %brand% with H20 (with 2 as a subscript with HTML code) 
replace('%brand%', 'H<sub>2</sub>O', 'html');
 
// Replace %response% with the response of the participant to the free text input AB01_01 
replace('%response%', 'AB01_01', 'response');
 
// Replace %response% with the response of the participant to the single selection question AB02 
replace('%response%', 'AB02', 'response');
en/create/functions/replace.1448727798.txt.gz · Last modified: 28.11.2015 17:23 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