Translations of this page:
 

PHP-Functions

This chapter shows you the main functions of PHP-Code Elements which can be used. The Introduction in PHP-Code will help you to integrate all PHP functions for your questionnaire.

At the very end of this page will be a helpful information how the documentation of the PHP-functions can be read: Function in Detail

Basic Fuctions for Filtering, Questions and Text

See also filter questions und filters.

  • value() – Use answer of participant, e.g. for a filter question
  • goToPage() – Jump to another page immediately
  • repeatPage() – Show recent page again
  • redirect() – Redirect the respondent to a different website
  • question() – Display a question within the questionnaire
  • text() – Display a text element within the questionnaire
  • show() – Display a question, combined question or text or activate a feature element
  • debug() – Show content of a data or PHP variable

Modify How to Display a Questionnaire Page

  • option() – Modify page display settings (buttons, progress bar)
  • preset() – Preset a response for a question
  • markFail() – Set the marker “response missing” for an input
  • html() – Output of HTML-Code within questionnaire
  • textlink() – Create a hyperlink that shows a text element in a pop-up window
  • buttonToPage() – Button to jump within the questionnaire
  • buttonCode() – Create-HTML-Code for next/back button
  • buttonHide() – Do not show back/next buttons at the page's bottom
  • library() – Make a JavaScript or PHP library available
  • pageCSS() – Add CSS instructions to a single questionnaire page
  • pageHead() – Store meta-information about the questionnaire page

Functions for Randomization

SoSci Survey supports several functions for special random selections and random group assignments. For a simple experimental variation, we recommend a Random Generator (Randomization).

  • put() – Save a value in the data set
  • random() – Dice a random number (with replacement)
  • random_p() – Random number in correlation to likelihood
  • random_items() – Randomly select items from a list
  • randomUse() – Storing slips of paper from a random number generator
  • urnDraw() – Draw out from urn (random selection without replacement)
  • urnPutAway() – Put away the chit drawn via urnDraw()
  • urnStatus() – Retrieve current status of an urn

Advanced Programming

Runtime Information

  • info() – Meta informationen int the current case or output configuration
  • infoVars() – Information on variables in the dataset
  • getRoute() – Tell if the next or back button was hit previously
  • caseNumber() – Number of actual interviews
  • caseSerial() – Serial number used in interview
  • caseTime() – Show length of stay on one or more sites
  • caseToken() – Identification of interview
  • caseData() – Get all data collected in the current interview
  • reference() – Ask for reference (within link to questionnaires)
  • getAnswerMissing() – Information for site repeat if questions was obligated
  • listFails() – List of not responded obligation questions
  • getLanguage() – Determine language

Coordination of Several Questionnaires

Databank for Contents

  • dbGet() – Read data from date base
  • dbKeys() – List key for data base
  • dbLoad() – Call all entries with defined prefix from the contents database
  • dbRetrieve() – Get data from the data base (associative, nested array)
  • dbSet() – Safe data in data base
  • dbStore() – Store data in the data base (associative, nested array)
  • dbTouch() – Refresh time-stamp for data base entry
  • dbDelete() – Delete entries from the data base, selected by a prefix

Record Control

  • dropValue() – Delete a single variable from the current interview
  • dropUpload() – Delete a file uploaded by the respondent
  • dropCase() – Mark the current interview for deletion
  • dropHistory() – Delete the page history of the current interview

Analyses and Access Further Records

  • statistic() – Simple statistical analysis of all data
  • diagram() – Simple diagram (e. g. frequency) for all analyzed data
  • panelRecords() – Access other records with the same person ID (SERIAL)

Analyses and Data Handling During an Interview

  • answers() – Show a question including the respondent's answers
  • answersOption() – Adjust display of answers via answers() or answersPrint()
  • answersPrint() – Display all questions of a questionnaire segment including the respondent's answers
  • valueSum() – Compute sum over scale or variables
  • valueMean() – Compute mean over scale or variable
  • valueSD() – Compute standard deviation over scale or variable
  • valueVar() – Compute variance over scale or variable
  • valueList() – Get multiple responses to multiple items in a question as array
  • convertDateTime() – Convert date/time texts (strings) and timestamps
  • calcMean(), calcSD(), ... – Simple calcuations based on the current interview's responses
  • uploadAsTable() – Get am Excel or CSV table uploaded by the respondent as array
  • uploadRawData() – Get an uploaded file as binary string

Data Visualization

Respondent and Mailing Management

  • mailResume() – Resume an interview after a given delay
  • mailSchedule() – Schedule to send a mailing to a single recipient
  • mailRevoke() – Cancel continuation mail(s) or a scheduled mailing
  • mailSend() – Send an email to an address that is not in the list of contacts
  • panelAdd() – Create a new address record
  • panelData() – Get information from an existing address entry
  • panelUpdate() – Update information on the address record
  • panelDelete() – Delete records from the address list
  • accessCount() – Limit trial to enter a code
  • setStatus() – Set the interview status and eventually trigger panel redirects

PHP's Own Functions

Furthermore, PHP itself provides numerous functions, some of which can be very helpful in the questionnaire. These functions are documented in the PHP Manual.

Restricted Functions

Some functions pose a security risk or do not work as expected in the context of the questionnaire. Alternatives are listed below. If you need additional features, please let SoSci Survey know.

Detailed Functions

Reference-syntax for each function, e.g.:

void set(mixed Value, [string Memory])

This reference-syntax describes the argumentation of functions and it's data type.

  • At the beginning return function of data type is shown void, meaning: function is acting but does not return values.
  • Arguments listed in braces. Optional arguments in angled braces. Function set() has o have at least one argument Value than it is allowed to use another (second) argument Memory .
  • Type of data stands in front of argument:
    • mixed means different types of data are allowed
    • int is a number
    • string text with inverted comma
    • array List of values (Arrays)
en/create/functions.txt · Last modified: by 127.0.0.1
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki