Question
extends LSActiveRecord
in package
Class Question
Tags
Table of Contents
Constants
- DEFAULT_QUESTION_THEME = 'core'
- QT_1_ARRAY_DUAL = '1'
- QT_5_POINT_CHOICE = '5'
- QT_A_ARRAY_5_POINT = 'A'
- QT_ASTERISK_EQUATION = '*'
- QT_B_ARRAY_10_CHOICE_QUESTIONS = 'B'
- QT_C_ARRAY_YES_UNCERTAIN_NO = 'C'
- QT_COLON_ARRAY_NUMBERS = ':'
- QT_D_DATE = 'D'
- QT_E_ARRAY_INC_SAME_DEC = 'E'
- QT_EXCLAMATION_LIST_DROPDOWN = '!'
- QT_F_ARRAY = 'F'
- QT_G_GENDER = 'G'
- QT_H_ARRAY_COLUMN = 'H'
- QT_I_LANGUAGE = 'I'
- QT_K_MULTIPLE_NUMERICAL = 'K'
- QT_L_LIST = 'L'
- QT_M_MULTIPLE_CHOICE = 'M'
- QT_N_NUMERICAL = 'N'
- QT_O_LIST_WITH_COMMENT = 'O'
- QT_P_MULTIPLE_CHOICE_WITH_COMMENTS = 'P'
- QT_Q_MULTIPLE_SHORT_TEXT = 'Q'
- QT_R_RANKING = 'R'
- QT_S_SHORT_FREE_TEXT = 'S'
- QT_SEMICOLON_ARRAY_TEXT = ';'
- QT_T_LONG_FREE_TEXT = 'T'
- QT_U_HUGE_FREE_TEXT = 'U'
- QT_VERTICAL_FILE_UPLOAD = '|'
- QT_X_TEXT_DISPLAY = 'X'
- QT_Y_YES_NO_RADIO = 'Y'
- START_SORTING_VALUE = 1
Properties
- $allSubQuestionIds : array<string|int, mixed>
- $answers : array<string|int, Answer>
- $bEncryption : mixed
- $encrypted : string
- $gid : int
- $gid : mixed
- $group : QuestionGroup
- $group_name : string
- $mandatory : string
- $modulename : string
- $other : string
- $parent : Question
- $parent_qid : int
- $preg : string
- $qid : int
- $question_order : int
- $question_theme_name : string
- $questionAttributes : array<string|int, QuestionAttribute>
- $questionl10ns : array<string|int, QuestionL10n>
- $questionType : QuestionType
- $quotableTypes : array<string|int, string>
- $relevance : string
- $relevance : mixed
- Defaut relevance *
- $same_default : int
- $same_script : int
- $same_script : mixed
- defaut same_script , avoid public break during update *
- $scale_id : int
- $sid : int
- $subquestions : array<string|int, Question>
- $survey : Survey
- $title : string
- $type : string
- $xssFilterAttributes : array<string|int, string>
- $relatedQuestionTheme : QuestionTheme
Methods
- behaviors() : array<string|int, mixed>
- Lists the behaviors of this model
- decrypt() : mixed
- Decrypt values from database
- decryptEncryptAttributes() : mixed
- Encrypt/decrypt values
- decryptSingle() : string
- Decrypt single value
- decryptSingleOld() : string
- Decrypt single value
- delete() : bool
- Deletes a question and ALL its relations (subquestions, answers, etc, etc)
- deleteAllAnswers() : void
- Delete all question and its subQuestion Answers
- deleteAllByAttributes() : int
- deleteAllById() : void
- Delete a bunch of questions in one go
- deleteAllSubquestions() : void
- Delete all subquestions that belong to this question.
- dispatchPluginModelEvent() : PluginEvent
- encrypt() : mixed
- Encrypt values
- encryptAttributeValues() : array<string|int, mixed>
- Attribute values are encrypted ( if needed )to be used for searching purposes
- encryptSave() : mixed
- Encrypt values before saving to the database
- encryptSingle() : mixed
- Enrypt single value
- findAllAsArray() : array<string|int, mixed>
- Finds all active records satisfying the specified condition but returns them as array
- findAllByAttributes() : array<string|int, static>
- Overriding of Yii's findAllByAttributes method to provide encrypted attribute value search
- findByAttributes() : static|null
- Overriding of Yii's findByAttributes method to provide encrypted attribute value search
- fixSubQuestions() : void
- Fix sub question of a parent question Must be call after base language subquestion is set
- getAdvancedSettingsWithValues() : array<string|int, mixed>
- This function returns an array of the advanced attributes for the particular question including their values set in the database
- getAllEncryptedAttributes() : array<string|int, mixed>
- getAllowOther() : bool
- Return if question allow other
- getAllowSubquestions() : bool
- Return if question has managed subquestions usage in rules : allow set other even if existing subquestions 'other' exist (but deleted after)
- getAllSubQuestionIds() : array<string|int, mixed>
- getBasicFieldName() : mixed
- getbuttons() : mixed
- getDataSetObject() : mixed
- getDualScaleTypes() : mixed
- Returns the question types that are dual scale.
- getEmptyAnswerOption() : Answer
- Used by question create form.
- getEmptySubquestion() : Question
- Used by question create form.
- getHasAnsweroptions() : mixed
- getHasOtherSubquestions() : bool
- Check if this question have subquestion with other code
- getHasSubquestions() : mixed
- getHighestQuestionOrderNumberInGroup() : int|null
- Returns the highest question_order value that exists for a questiongroup inside the related questions.
- getIsDualScale() : mixed
- Is it a dual scale type.
- getMandatoryIcon() : mixed
- getMaxId() : false|int
- Return the max value for a field
- getMinId() : false|int
- Return the min value for a field
- getNewTitle() : string|null
- Get an new title/code for a question
- getOrderedAnswers() : array<string|int, mixed>
- get the ordered answers
- getOrderedSubQuestions() : array<string|int, mixed>
- get subquestions fort the current question object in the right order
- getOtherIcon() : bool
- Return other icon according to state
- getQuestionAttribute() : array<string|int, QuestionAttribute>
- getQuestionClass() : string
- This function return the class by question type
- getQuestionList() : array<string|int, Question>
- getQuestionListColumns() : mixed
- getQuestions() : CDbDataReader
- TODO: replace this function call by $oSurvey->questions defining a relation in SurveyModel
- getQuestionsForStatistics() : array<string|int, mixed>
- TODO: replace it everywhere by Answer::model()->findAll([Critieria Object])
- getQuestionTemplateAttributes() : mixed
- Add custom attributes (if there are any custom attributes). It also removes all attributeNames where inputType is empty. Otherwise (not adding and removing anything)it returns the incoming parameter $aAttributeNames.
- getQuestionTheme() : QuestionTheme|null
- Returns the QuestionTheme related to this question.
- getQuestionType() : null|QuestionType
- getQuestionTypeName() : string
- This function return the name by question type
- getQuotableTypes() : array<string|int, string>
- getRenderererObject() : mixed
- getScaledAnswerOptions() : array<string|int, mixed>
- Get array of answers options, depending on scale count for this question type.
- getScaledSubquestions() : array<string|int, mixed>
- Get array of subquestions, depending on scale count for this question type.
- getTypedesc() : string
- getTypeGroup() : mixed
- increaseAllOrderNumbersForGroup() : mixed
- Increases all question_order numbers for questions belonging to the group by +1
- insertRecords() : bool|null
- model() : Question
- primaryKey() : mixed
- questionThemeNameValidator() : mixed
- Validates the question theme name, making sure it's not empty or 'core'
- relations() : mixed
- removeFromLastVisited() : mixed
- remove question from lastVisited
- rules() : mixed
- scopes() : mixed
- search() : mixed
- setEncryptedAttributeLabel() : string
- Function to show encryption symbol in gridview attribute header if value ois encrypted
- setQuestionOrderForGroup() : bool
- In some cases question have o wrong questio_sort=0, The sort number should always be greater then 0, starting with 1. For this reason, the question_order has to be checked for a specific group and question_sort has be set correctly.
- tableName() : mixed
- typeList() : array<string|int, mixed>
- This function contains the question type definitions.
- update() : mixed
- Override update() method to "clean" subquestions after saving a parent question
- updateAll() : int
- Updates records with the specified condition.
- updateQuestionOrder() : mixed
- Fix sort order for questions in a group All questions in the group will be assigned a sequential question order, starting in the specified value
- updateSortOrder() : void
- Rewrites sort order for questions in a group
- beforeSave() : bool
- Make sure we don't save a new question group while the survey is active.
- query() : mixed
- Modified version that default to do the same as the original, but allows via a third parameter to retrieve the result as array instead of active records. This solves a joining problem. Usage via findAllAsArray method
- removeInvalidSubquestions() : void
- Remove subquestion if needed when update question type
- rulesForActiveSurvey() : array<string|int, mixed>
- return rules specific for activated survey
- shouldOrderAnswersAlphabetically() : bool
- Returns true if the answer options should be ordered alphabetically.
- shouldOrderAnswersRandomly() : bool
- Returns true if the answer options should be ordered randomly.
- sortAnswerOptions() : array<int, array<string|int, Answer>>
- Returns the specified answer options sorted according to the question attributes.
Constants
DEFAULT_QUESTION_THEME
public
mixed
DEFAULT_QUESTION_THEME
= 'core'
QT_1_ARRAY_DUAL
public
mixed
QT_1_ARRAY_DUAL
= '1'
QT_5_POINT_CHOICE
public
mixed
QT_5_POINT_CHOICE
= '5'
QT_A_ARRAY_5_POINT
public
mixed
QT_A_ARRAY_5_POINT
= 'A'
QT_ASTERISK_EQUATION
public
mixed
QT_ASTERISK_EQUATION
= '*'
QT_B_ARRAY_10_CHOICE_QUESTIONS
public
mixed
QT_B_ARRAY_10_CHOICE_QUESTIONS
= 'B'
QT_C_ARRAY_YES_UNCERTAIN_NO
public
mixed
QT_C_ARRAY_YES_UNCERTAIN_NO
= 'C'
QT_COLON_ARRAY_NUMBERS
public
mixed
QT_COLON_ARRAY_NUMBERS
= ':'
QT_D_DATE
public
mixed
QT_D_DATE
= 'D'
QT_E_ARRAY_INC_SAME_DEC
public
mixed
QT_E_ARRAY_INC_SAME_DEC
= 'E'
QT_EXCLAMATION_LIST_DROPDOWN
public
mixed
QT_EXCLAMATION_LIST_DROPDOWN
= '!'
QT_F_ARRAY
public
mixed
QT_F_ARRAY
= 'F'
QT_G_GENDER
public
mixed
QT_G_GENDER
= 'G'
QT_H_ARRAY_COLUMN
public
mixed
QT_H_ARRAY_COLUMN
= 'H'
QT_I_LANGUAGE
public
mixed
QT_I_LANGUAGE
= 'I'
QT_K_MULTIPLE_NUMERICAL
public
mixed
QT_K_MULTIPLE_NUMERICAL
= 'K'
QT_L_LIST
public
mixed
QT_L_LIST
= 'L'
QT_M_MULTIPLE_CHOICE
public
mixed
QT_M_MULTIPLE_CHOICE
= 'M'
QT_N_NUMERICAL
public
mixed
QT_N_NUMERICAL
= 'N'
QT_O_LIST_WITH_COMMENT
public
mixed
QT_O_LIST_WITH_COMMENT
= 'O'
QT_P_MULTIPLE_CHOICE_WITH_COMMENTS
public
mixed
QT_P_MULTIPLE_CHOICE_WITH_COMMENTS
= 'P'
QT_Q_MULTIPLE_SHORT_TEXT
public
mixed
QT_Q_MULTIPLE_SHORT_TEXT
= 'Q'
QT_R_RANKING
public
mixed
QT_R_RANKING
= 'R'
QT_S_SHORT_FREE_TEXT
public
mixed
QT_S_SHORT_FREE_TEXT
= 'S'
QT_SEMICOLON_ARRAY_TEXT
public
mixed
QT_SEMICOLON_ARRAY_TEXT
= ';'
QT_T_LONG_FREE_TEXT
public
mixed
QT_T_LONG_FREE_TEXT
= 'T'
QT_U_HUGE_FREE_TEXT
public
mixed
QT_U_HUGE_FREE_TEXT
= 'U'
QT_VERTICAL_FILE_UPLOAD
public
mixed
QT_VERTICAL_FILE_UPLOAD
= '|'
QT_X_TEXT_DISPLAY
public
mixed
QT_X_TEXT_DISPLAY
= 'X'
QT_Y_YES_NO_RADIO
public
mixed
QT_Y_YES_NO_RADIO
= 'Y'
START_SORTING_VALUE
public
mixed
START_SORTING_VALUE
= 1
Properties
$allSubQuestionIds
public
array<string|int, mixed>
$allSubQuestionIds
QID-s of all question subquestions, empty array returned if no subquestions
$answers
public
array<string|int, Answer>
$answers
$bEncryption
public
mixed
$bEncryption
= \false
$encrypted
public
string
$encrypted
Whether question is encrypted (Y/N)
$gid
public
int
$gid
QuestionGroup ID where question is displayed
$gid
public
mixed
$gid
$group
public
QuestionGroup
$group
$group_name
public
string
$group_name
Stock the active group_name for questions list filtering
$mandatory
public
string
$mandatory
Whether question is mandatory (Y/S/N)
$modulename
public
string
$modulename
$other
public
string
$other
Other option enabled for question (Y/N)
$parent
public
Question
$parent
$parent_qid
public
int
$parent_qid
Questions parent question ID eg for subquestions
$preg
public
string
$preg
$qid
public
int
$qid
Question ID.
$question_order
public
int
$question_order
Question order in greoup
$question_theme_name
public
string
$question_theme_name
$questionAttributes
public
array<string|int, QuestionAttribute>
$questionAttributes
NB! returns all QuestionArrtibute Models fot this QID regardless of the specified language
$questionl10ns
public
array<string|int, QuestionL10n>
$questionl10ns
Question Languagesettings indexd by language code
$questionType
public
QuestionType
$questionType
$quotableTypes
public
array<string|int, string>
$quotableTypes
Question types that can be used for quotas
$relevance
public
string
$relevance
Questions relevane equation
$relevance
Defaut relevance *
public
mixed
$relevance
= ''
$same_default
public
int
$same_default
Saves if user set to use the same default value across languages in default options dialog ('Edit default answers')
$same_script
public
int
$same_script
Whether the same script should be used for all languages
$same_script
defaut same_script , avoid public break during update *
public
mixed
$same_script
= 0
$scale_id
public
int
$scale_id
The scale ID
$sid
public
int
$sid
Survey ID
$subquestions
public
array<string|int, Question>
$subquestions
$survey
public
Survey
$survey
$title
public
string
$title
Question Code
$type
public
string
$type
$xssFilterAttributes
protected
array<string|int, string>
$xssFilterAttributes
= []
Array of attributes that should be XSS filtered on mass updates
$relatedQuestionTheme
private
QuestionTheme
$relatedQuestionTheme
cached question theme
Methods
behaviors()
Lists the behaviors of this model
public
behaviors() : array<string|int, mixed>
Below is a list of all behaviors we register:
Tags
Return values
array<string|int, mixed>decrypt()
Decrypt values from database
public
decrypt([mixed $value = '' ]) : mixed
Parameters
- $value : mixed = ''
decryptEncryptAttributes()
Encrypt/decrypt values
public
decryptEncryptAttributes([mixed $action = 'decrypt' ]) : mixed
Parameters
- $action : mixed = 'decrypt'
decryptSingle()
Decrypt single value
public
static decryptSingle([string $value = '' ]) : string
Parameters
- $value : string = ''
-
String value which needs to be decrypted
Return values
string —the decrypted string
decryptSingleOld()
Decrypt single value
public
static decryptSingleOld([string $value = '' ]) : string
Parameters
- $value : string = ''
-
String value which needs to be decrypted
Return values
string —the decrypted string
delete()
Deletes a question and ALL its relations (subquestions, answers, etc, etc)
public
delete() : bool
Tags
Return values
booldeleteAllAnswers()
Delete all question and its subQuestion Answers
public
deleteAllAnswers([array<string|int, mixed> $exceptIds = [] ]) : void
Parameters
- $exceptIds : array<string|int, mixed> = []
-
Don't delete answers with these ids.
deleteAllByAttributes()
public
deleteAllByAttributes(array<string|int, mixed> $attributes[, string $condition = '' ][, array<string|int, mixed> $params = [] ]) : int
Parameters
- $attributes : array<string|int, mixed>
-
list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.
- $condition : string = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = []
-
parameters to be bound to an SQL statement.
Tags
Return values
int —number of rows affected by the execution.
deleteAllById()
Delete a bunch of questions in one go
public
static deleteAllById(mixed $questionsIds) : void
Parameters
- $questionsIds : mixed
deleteAllSubquestions()
Delete all subquestions that belong to this question.
public
deleteAllSubquestions([array<string|int, mixed>|null $exceptIds = [] ]) : void
Parameters
- $exceptIds : array<string|int, mixed>|null = []
-
Don't delete subquestions with these ids.
Tags
dispatchPluginModelEvent()
public
dispatchPluginModelEvent(string $sEventName, CDbCriteria $criteria = null, array<string|int, mixed> $eventParams = []) : PluginEvent
Parameters
- $sEventName : string
- $criteria = null : CDbCriteria
- $eventParams = [] : array<string|int, mixed>
Return values
PluginEventencrypt()
Encrypt values
public
encrypt() : mixed
encryptAttributeValues()
Attribute values are encrypted ( if needed )to be used for searching purposes
public
encryptAttributeValues([array<string|int, mixed> $attributes = null ][, mixed $bEncryptedOnly = false ][, mixed $bReplaceValues = true ]) : array<string|int, mixed>
Parameters
- $attributes : array<string|int, mixed> = null
-
list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.
- $bEncryptedOnly : mixed = false
- $bReplaceValues : mixed = true
Return values
array<string|int, mixed> —attributes array with encrypted atrribute values is returned
encryptSave()
Encrypt values before saving to the database
public
encryptSave([mixed $runValidation = false ]) : mixed
Parameters
- $runValidation : mixed = false
encryptSingle()
Enrypt single value
public
static encryptSingle([string $value = '' ]) : mixed
Parameters
- $value : string = ''
-
String value which needs to be encrypted
findAllAsArray()
Finds all active records satisfying the specified condition but returns them as array
public
findAllAsArray([mixed $condition = '' ][, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $condition : mixed = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = []
-
parameters to be bound to an SQL statement.
Return values
array<string|int, mixed> —list of active records satisfying the specified condition. An empty array is returned if none is found.
findAllByAttributes()
Overriding of Yii's findAllByAttributes method to provide encrypted attribute value search
public
findAllByAttributes(array<string|int, mixed> $attributes[, mixed $condition = '' ][, array<string|int, mixed> $params = [] ]) : array<string|int, static>
Parameters
- $attributes : array<string|int, mixed>
-
list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.
- $condition : mixed = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = []
-
parameters to be bound to an SQL statement.
Return values
array<string|int, static> —the records found. An empty array is returned if none is found.
findByAttributes()
Overriding of Yii's findByAttributes method to provide encrypted attribute value search
public
findByAttributes(array<string|int, mixed> $attributes[, mixed $condition = '' ][, array<string|int, mixed> $params = [] ]) : static|null
Parameters
- $attributes : array<string|int, mixed>
-
list of attribute values (indexed by attribute names) that the active record should match. An attribute value can be an array which will be used to generate an IN condition.
- $condition : mixed = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = []
-
parameters to be bound to an SQL statement.
Return values
static|null —the record found. Null if none is found.
fixSubQuestions()
Fix sub question of a parent question Must be call after base language subquestion is set
public
fixSubQuestions() : void
Tags
getAdvancedSettingsWithValues()
This function returns an array of the advanced attributes for the particular question including their values set in the database
public
getAdvancedSettingsWithValues([string|null $sLanguage = null ][, string|null $sQuestionThemeOverride = null ]) : array<string|int, mixed>
Parameters
- $sLanguage : string|null = null
-
If you give a language then only the attributes for that language are returned
- $sQuestionThemeOverride : string|null = null
-
Name of the question theme to use instead of the question's current theme
Return values
array<string|int, mixed>getAllEncryptedAttributes()
public
getAllEncryptedAttributes(int $iSurveyId, string $sClassName) : array<string|int, mixed>
Parameters
- $iSurveyId : int
- $sClassName : string
Return values
array<string|int, mixed> —TODO: Should be split into seperate functions in the appropiate model or helper class TODO: Make an interface for records that support encryption.
getAllowOther()
Return if question allow other
public
getAllowOther() : bool
Return values
boolgetAllowSubquestions()
Return if question has managed subquestions usage in rules : allow set other even if existing subquestions 'other' exist (but deleted after)
public
getAllowSubquestions() : bool
Return values
boolgetAllSubQuestionIds()
public
getAllSubQuestionIds() : array<string|int, mixed>
Return values
array<string|int, mixed>getBasicFieldName()
public
getBasicFieldName() : mixed
getbuttons()
public
getbuttons() : mixed
getDataSetObject()
public
getDataSetObject([mixed $type = null ]) : mixed
Parameters
- $type : mixed = null
getDualScaleTypes()
Returns the question types that are dual scale.
public
getDualScaleTypes() : mixed
getEmptyAnswerOption()
Used by question create form.
public
getEmptyAnswerOption() : Answer
Return values
AnswergetEmptySubquestion()
Used by question create form.
public
getEmptySubquestion() : Question
Return values
QuestiongetHasAnsweroptions()
public
getHasAnsweroptions() : mixed
Tags
getHasOtherSubquestions()
Check if this question have subquestion with other code
public
getHasOtherSubquestions() : bool
Return values
boolgetHasSubquestions()
public
getHasSubquestions() : mixed
Tags
getHighestQuestionOrderNumberInGroup()
Returns the highest question_order value that exists for a questiongroup inside the related questions.
public
static getHighestQuestionOrderNumberInGroup(int $questionGroupId) : int|null
($question->question_order).
Parameters
- $questionGroupId : int
-
the question group id
Return values
int|null —question highest order number or null if there are no questions belonging to the group
getIsDualScale()
Is it a dual scale type.
public
getIsDualScale() : mixed
getMandatoryIcon()
public
getMandatoryIcon() : mixed
getMaxId()
Return the max value for a field
public
getMaxId([string $field = null ][, bool $forceRefresh = false ]) : false|int
This is a convenience method, that uses the primary key of the model to retrieve the highest value.
Parameters
- $field : string = null
-
The field that contains the Id, when null primary key is used if it is a single field
- $forceRefresh : bool = false
-
Don't use value from static cache but always requery the database
Tags
Return values
false|intgetMinId()
Return the min value for a field
public
getMinId([string $field = null ][, bool $forceRefresh = false ]) : false|int
This is a convenience method, that uses the primary key of the model to retrieve the highest value.
Parameters
- $field : string = null
-
The field that contains the Id, when null primary key is used if it is a single field
- $forceRefresh : bool = false
-
Don't use value from static cache but always requery the database
Tags
Return values
false|intgetNewTitle()
Get an new title/code for a question
public
getNewTitle([int $index = 0 ]) : string|null
Parameters
- $index : int = 0
-
base for question code (example : inde of question when survey import)
Return values
string|null —: new title, null if impossible
getOrderedAnswers()
get the ordered answers
public
getOrderedAnswers([mixed $scale_id = null ][, null|string $language = null ]) : array<string|int, mixed>
Parameters
- $scale_id : mixed = null
- $language : null|string = null
Return values
array<string|int, mixed>getOrderedSubQuestions()
get subquestions fort the current question object in the right order
public
getOrderedSubQuestions([mixed $scale_id = null ]) : array<string|int, mixed>
Parameters
- $scale_id : mixed = null
Return values
array<string|int, mixed>getOtherIcon()
Return other icon according to state
public
getOtherIcon() : bool
Return values
boolgetQuestionAttribute()
public
getQuestionAttribute(mixed $sAttribute) : array<string|int, QuestionAttribute>
Parameters
- $sAttribute : mixed
Return values
array<string|int, QuestionAttribute>getQuestionClass()
This function return the class by question type
public
static getQuestionClass(mixed $sType) : string
Parameters
- $sType : mixed
Return values
string —Question class to be added to the container
Maybe move class in typeList ? //TODO move to QuestionType
getQuestionList()
public
getQuestionList(int $surveyid) : array<string|int, Question>
Parameters
- $surveyid : int
Return values
array<string|int, Question>getQuestionListColumns()
public
getQuestionListColumns() : mixed
getQuestions()
TODO: replace this function call by $oSurvey->questions defining a relation in SurveyModel
public
getQuestions(int $sid, int $gid) : CDbDataReader
Parameters
- $sid : int
- $gid : int
Return values
CDbDataReadergetQuestionsForStatistics()
TODO: replace it everywhere by Answer::model()->findAll([Critieria Object])
public
getQuestionsForStatistics(string $fields, mixed $condition[, string|false $orderby = false ]) : array<string|int, mixed>
Parameters
- $fields : string
- $condition : mixed
- $orderby : string|false = false
Return values
array<string|int, mixed>getQuestionTemplateAttributes()
Add custom attributes (if there are any custom attributes). It also removes all attributeNames where inputType is empty. Otherwise (not adding and removing anything)it returns the incoming parameter $aAttributeNames.
public
static getQuestionTemplateAttributes(array<string|int, mixed> $aAttributeNames, array<string|int, mixed> $aAttributeValues, Question $oQuestion) : mixed
Parameters
- $aAttributeNames : array<string|int, mixed>
-
the values from getQuestionAttributesSettings($sType)
- $aAttributeValues : array<string|int, mixed>
-
$attributeValues['question_template'] != 'core', only if this is true the function changes something
- $oQuestion : Question
-
this is needed to check if a questionTemplate has custom attributes
Tags
Return values
mixed —returns the incoming parameter $aAttributeNames or
getQuestionTheme()
Returns the QuestionTheme related to this question.
public
getQuestionTheme() : QuestionTheme|null
It's not implemented as a relation because relations only work on persisted models.
Return values
QuestionTheme|nullgetQuestionType()
public
getQuestionType() : null|QuestionType
Return values
null|QuestionTypegetQuestionTypeName()
This function return the name by question type
public
static getQuestionTypeName(mixed $sType) : string
Parameters
- $sType : mixed
Tags
Return values
string —Question type name
Maybe move class in typeList ?
getQuotableTypes()
public
static getQuotableTypes() : array<string|int, string>
Return values
array<string|int, string>getRenderererObject()
public
getRenderererObject(mixed $aFieldArray[, mixed $type = null ]) : mixed
Parameters
- $aFieldArray : mixed
- $type : mixed = null
getScaledAnswerOptions()
Get array of answers options, depending on scale count for this question type.
public
getScaledAnswerOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —Like [0 => Answer[]] or [0 => Answer[], 1 => Answer[]]
getScaledSubquestions()
Get array of subquestions, depending on scale count for this question type.
public
getScaledSubquestions() : array<string|int, mixed>
Return values
array<string|int, mixed> —Like [0 => Question[]] or [0 => Question[], 1 => Question[]]
getTypedesc()
public
getTypedesc() : string
Return values
string —NOTE: Not used anymore. Based on a deprecated method. Should be deprecated.
getTypeGroup()
public
getTypeGroup() : mixed
increaseAllOrderNumbersForGroup()
Increases all question_order numbers for questions belonging to the group by +1
public
static increaseAllOrderNumbersForGroup(int $questionGroupId) : mixed
Parameters
- $questionGroupId : int
insertRecords()
public
insertRecords(array<string|int, mixed> $data) : bool|null
Parameters
- $data : array<string|int, mixed>
Return values
bool|nullmodel()
public
static model([mixed $className = __CLASS__ ]) : Question
Parameters
- $className : mixed = __CLASS__
Tags
Return values
QuestionprimaryKey()
public
primaryKey() : mixed
Tags
questionThemeNameValidator()
Validates the question theme name, making sure it's not empty or 'core'
public
questionThemeNameValidator() : mixed
relations()
public
relations() : mixed
Tags
removeFromLastVisited()
remove question from lastVisited
public
removeFromLastVisited() : mixed
rules()
public
rules() : mixed
Tags
scopes()
public
scopes() : mixed
Tags
search()
public
search() : mixed
setEncryptedAttributeLabel()
Function to show encryption symbol in gridview attribute header if value ois encrypted
public
setEncryptedAttributeLabel(int $surveyId, string $className, string $attributeName) : string
Parameters
- $surveyId : int
- $className : string
- $attributeName : string
Tags
Return values
stringsetQuestionOrderForGroup()
In some cases question have o wrong questio_sort=0, The sort number should always be greater then 0, starting with 1. For this reason, the question_order has to be checked for a specific group and question_sort has be set correctly.
public
static setQuestionOrderForGroup( $questionGroupId) : bool
Parameters
Return values
bool —true if sort numbers had to be set, false otherwise
tableName()
public
tableName() : mixed
Tags
typeList()
This function contains the question type definitions.
public
static typeList([string $language = null ]) : array<string|int, mixed>
Parameters
- $language : string = null
-
Language for translation
Tags
Return values
array<string|int, mixed> —The question type definitions
Explanation of questiontype array:
description : Question description subquestions : 0= Does not support subquestions x=Number of subquestion scales answerscales : 0= Does not need answers x=Number of answer scales (usually 1, but e.g. for dual scale question set to 2) assessable : 0=Does not support assessment values when editing answerd 1=Support assessment values
update()
Override update() method to "clean" subquestions after saving a parent question
public
update([mixed $attributes = null ]) : mixed
Parameters
- $attributes : mixed = null
updateAll()
Updates records with the specified condition.
public
updateAll(array<string|int, mixed> $attributes[, mixed $condition = '' ][, array<string|int, mixed> $params = array() ]) : int
XSS filtering is enforced for attributes listed in model's $xssFilterAttributes property. See for detailed explanation about $condition and $params. Note, the attributes are not checked for safety and no validation is done.
Parameters
- $attributes : array<string|int, mixed>
-
list of attributes (name=>$value) to be updated
- $condition : mixed = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = array()
-
parameters to be bound to an SQL statement.
Return values
int —the number of rows being updated
updateQuestionOrder()
Fix sort order for questions in a group All questions in the group will be assigned a sequential question order, starting in the specified value
public
updateQuestionOrder(int $gid[, int $startingOrder = 1 ]) : mixed
Parameters
- $gid : int
- $startingOrder : int = 1
-
the starting question order.
updateSortOrder()
Rewrites sort order for questions in a group
public
static updateSortOrder(int $gid, int $surveyid) : void
Parameters
- $gid : int
- $surveyid : int
Tags
beforeSave()
Make sure we don't save a new question group while the survey is active.
protected
beforeSave() : bool
Return values
boolquery()
Modified version that default to do the same as the original, but allows via a third parameter to retrieve the result as array instead of active records. This solves a joining problem. Usage via findAllAsArray method
protected
query(CDbCriteria $criteria[, bool $all = false ][, bool $asAR = true ]) : mixed
Performs the actual DB query and populates the AR objects with the query result. This method is mainly internally used by other AR query methods.
Parameters
- $criteria : CDbCriteria
-
the query criteria
- $all : bool = false
-
whether to return all data
- $asAR : bool = true
Tags
Return values
mixed —the AR objects populated with the query result
removeInvalidSubquestions()
Remove subquestion if needed when update question type
protected
removeInvalidSubquestions() : void
rulesForActiveSurvey()
return rules specific for activated survey
private
rulesForActiveSurvey() : array<string|int, mixed>
Return values
array<string|int, mixed>shouldOrderAnswersAlphabetically()
Returns true if the answer options should be ordered alphabetically.
private
shouldOrderAnswersAlphabetically() : bool
Return values
boolshouldOrderAnswersRandomly()
Returns true if the answer options should be ordered randomly.
private
shouldOrderAnswersRandomly() : bool
Return values
boolsortAnswerOptions()
Returns the specified answer options sorted according to the question attributes.
private
sortAnswerOptions(mixed $answerOptions[, null|string $language = null ]) : array<int, array<string|int, Answer>>
Refactored from getOrderedAnswers();
Parameters
- $answerOptions : mixed
- $language : null|string = null