x

Main chapters

  1. LimeSurvey Cloud vs LimeSurvey CE
  2. LimeSurvey Cloud - Quick start guide
  3. LimeSurvey CE - Installation
  4. How to design a good survey (Guide)
  5. Getting started
  6. LimeSurvey configuration
  7. Introduction - Surveys
  8. View survey settings
  9. View survey menu
  10. View survey structure
  11. Introduction - Questions
  12. Introduction - Question Groups
  13. Introduction - Surveys - Management
  14. Survey toolbar options
  15. Multilingual survey
  16. Quick start guide - ExpressionScript
  17. Advanced features
  18. General FAQ
  19. Troubleshooting
  20. Workarounds
  21. License
  22. Version change log
  23. Plugins - Advanced
 Actions

Question Objects

From LimeSurvey Manual

Revision as of 03:29, 28 July 2012 by Admin (talk | contribs)

As of LimeSurvey 2.0, questions type were internally identified by a single character. That is, a display question was represented by 'X' while a list question was represented by 'L' etc. Unfortunately, this made adding and altering question types incredibly difficult since code for each question type was spread across literally dozens of files. To make it easier for independent developers to add and modify question types, each question will have it's own class in the application/modules folder. These classes will contain all question-type-specific code. This will both allow developers to easily create custom question types by extending any of the existing question types.

There are 3 abstract question classes: QuestionModule, ArrayQuestion, and TextQuestion. All the question classes (including Array and Text) extend QuestionModule and end in "Question." Below is a list of class names and descriptions.

Description Class Prefix Legacy Character Code Parent (if blank assume QuestionModule)
5 point choice FiveList 5
List (dropdown) Select ! List
List (radio) List L
List with comment CommentList O List
Array RadioArray F Array
Array (10 point choice) TenRadioArray B RadioArray
Array (5 point choice) FiveRadioArray A RadioArray
Array (Increase/Same/Decrease) IDRadioArray E RadioArray
Array (Numbers) NumberArray : Array
Array (Texts) TextArray ; Array
Array (Yes/No/Uncertain) YNRadioArray C RadioArray
Array by column ColumnRadioArray H RadioArray
Array dual scale DualRadioArray 1 RadioArray
Date/Time Date D
Equation Equation *
File upload File pipe character
Gender Gender G
Language switch Language I
Multiple numerical input Multinumerical K
Numerical input Numerical N
Ranking Ranking R
Text display Display X
Yes/No YN Y
Huge free text HugeText U Text
Long free text LongText T Text
Multiple short text Multitext Q
Short free text ShortText S Text
Multiple choice Check M
Multiple choice with comments CommentCheck P Check

Each of these classes contains (or inherits) a number of public methods that are abstracted by the QuestionModule class. To execute this question specific code, the question class is loaded out of the database, the object is dynamically instantiated and the relevant function is called. The question objects store question id, group id, survey id, question text, and other relevant data. Question objects then become a very useful way to pass around data instead of the previously used arrays.

These question objects come with two new database tables. First, a question types table stores a list of type ids, group ids, description, and legacy character code. There is a new int tid column in the questions table that replaces the type column and maps to the tid column in the new question types table. In addition, there is a new question type groups table that contains a group id, a description, and an order. This configuration will allow for backend configuration in the future, and ultimately, custom question types that can be shared among the community.