Question

Extends\LSActiveRecord

Class Question

inheritdoc
package

Default

Methods

Make sure we don't save a new question group while the survey is active.

beforeSave(): boolean

Response

boolean

Lists the behaviors of this model

behaviors(): array
inherited

Below is a list of all behaviors we register:

see \PluginEventBehavior\CTimestampBehavior

Response

array

Decrypt values from database

decrypt( $value = '')
inherited

Arguments

$value

Encrypt/decrypt values

decryptEncryptAttributes( $action = 'decrypt')
inherited

Arguments

$action

Decrypt single value

decryptSingle(string $value = '')
inheritedstatic

Arguments

$value

string

String value which needs to be decrypted

Deletes a question and ALL its relations (subquestions, answers, etc, etc)

delete(): boolean
Throws
\CDbException

Response

boolean

Delete all question and its subQuestion Answers

deleteAllAnswers(): void

deleteAllByAttributes

deleteAllByAttributes(array $attributes,string $condition = '',array $params = array()): integer
inherited
todo

This should also be moved to the behavior at some point. This method overrides the parent in order to raise PluginEvents for Bulk delete operations.

Filter Criteria are wrapped into a CDBCriteria instance so we have a single instance responsible for holding the filter criteria to be passed to the PluginEvent, this also enables us to pass the fully configured CDBCriteria instead of the original Parameters.

See {@link find()} for detailed explanation about $condition and $params.

Arguments

$attributes

array

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

parameters to be bound to an SQL statement.

Response

integer

number of rows affected by the execution.

Delete a bunch of questions in one go

deleteAllById(mixed $questionsIds): void
static

Arguments

$questionsIds

mixed

Delete all subquestions that belong to this question.

deleteAllSubquestions(): void
todo

Duplication from delete()

dispatchPluginModelEvent

dispatchPluginModelEvent(string $sEventName,\CDbCriteria $criteria = null,array $eventParams = []): \PluginEvent
inherited

Arguments

$sEventName

string

$criteria

\CDbCriteria

$eventParams

array

Response

\PluginEvent

Encrypt values

encrypt()
inherited

Attribute values are encrypted ( if needed )to be used for searching purposes

encryptAttributeValues(array $attributes = null, $bEncryptedOnly = false, $bReplaceValues = true): array
inherited

Arguments

$attributes

array

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

$bReplaceValues

Response

array

attributes array with encrypted atrribute values is returned

Encrypt values before saving to the database

encryptSave( $runValidation = false)
inherited

Arguments

$runValidation

Enrypt single value

encryptSingle(string $value = '')
inheritedstatic

Arguments

$value

string

String value which needs to be encrypted

Finds all active records satisfying the specified condition but returns them as array

findAllAsArray(mixed $condition = '',array $params = array()): array
inherited

See \find() for detailed explanation about $condition and $params.

Arguments

$condition

mixed

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

array

list of active records satisfying the specified condition. An empty array is returned if none is found.

Overriding of Yii's findAllByAttributes method to provide encrypted attribute value search

findAllByAttributes(array $attributes,mixed $condition = '',array $params = array()): array<mixed,static>
inherited

Arguments

$attributes

array

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

parameters to be bound to an SQL statement.

Response

array<mixed,static>

the records found. An empty array is returned if none is found.

Overriding of Yii's findByAttributes method to provide encrypted attribute value search

findByAttributes(array $attributes,mixed $condition = '',array $params = array()): static|null
inherited

Arguments

$attributes

array

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

parameters to be bound to an SQL statement.

Response

static|null

the record found. Null if none is found.

Fix sub question of a parent question Must be call after base language subquestion is set

fixSubQuestions(): void
todo

: move other fix here ?

This function returns an array of the advanced attributes for the particular question including their values set in the database

getAdvancedSettingsWithValues(string|null $sLanguage = null,string|null $sQuestionThemeOverride = null): array

Arguments

$sLanguage

string|null

If you give a language then only the attributes for that language are returned

$sQuestionThemeOverride

string|null

Name of the question theme to use instead of the question's current theme

Response

array

getAllEncryptedAttributes

getAllEncryptedAttributes(integer $iSurveyId,string $sClassName): array
inherited

Arguments

$iSurveyId

integer

$sClassName

string

Response

array

TODO: Should be split into seperate functions in the appropiate model or helper class TODO: Make an interface for records that support encryption.

getAllSubQuestionIds

getAllSubQuestionIds(): array

Response

array

getBasicFieldName

getBasicFieldName()

getbuttons

getbuttons()

getDataSetObject

getDataSetObject( $type = null)

Arguments

$type

Used by question create form.

getEmptyAnswerOption(): \Answer

Response

\Answer

Used by question create form.

getEmptySubquestion(): \Question

Response

\Question

getHasAnsweroptions

getHasAnsweroptions()

getHasSubquestions

getHasSubquestions()

Returns the highest question_order value that exists for a questiongroup inside the related questions.

getHighestQuestionOrderNumberInGroup(integer $questionGroupId): integer|null
static

($question->question_order).

Arguments

$questionGroupId

integer

the question group id

Response

integer|null

question highest order number or null if there are no questions belonging to the group

getMandatoryIcon

getMandatoryIcon()

Return the max value for a field

getMaxId(string $field = null,boolean $forceRefresh = false): false|integer
inherited

This is a convenience method, that uses the primary key of the model to retrieve the highest value.

Throws
\Exception

Arguments

$field

string

The field that contains the Id, when null primary key is used if it is a single field

$forceRefresh

boolean

Don't use value from static cache but always requery the database

Response

false|integer

Return the min value for a field

getMinId(string $field = null,boolean $forceRefresh = false): false|integer
inherited

This is a convenience method, that uses the primary key of the model to retrieve the highest value.

Throws
\Exception

Arguments

$field

string

The field that contains the Id, when null primary key is used if it is a single field

$forceRefresh

boolean

Don't use value from static cache but always requery the database

Response

false|integer

Get an new title/code for a question

getNewTitle(integer $index): string|null

Arguments

$index

integer

base for question code (exemple : inde of question when survey import)

Response

string|null

: new title, null if impossible

getOrderedAnswers

getOrderedAnswers( $scale_id = null)

Arguments

$scale_id

get subquestions fort the current question object in the right order

getOrderedSubQuestions( $scale_id = null): array

Arguments

$scale_id

Response

array

getOtherIcon

getOtherIcon()

getQuestionAttribute

getQuestionAttribute( $sAttribute): array<mixed,\QuestionAttribute>

Arguments

$sAttribute

Response

array<mixed,\QuestionAttribute>

This function return the class by question type

getQuestionClass( $sType): string
static

Arguments

$sType

Response

string

Question class to be added to the container

Maybe move class in typeList ? //TODO move to QuestionType

getQuestionList

getQuestionList(integer $surveyid): array<mixed,\Question>

Arguments

$surveyid

integer

Response

array<mixed,\Question>

getQuestionListColumns

getQuestionListColumns()

TODO: replace this function call by $oSurvey->questions defining a relation in SurveyModel

getQuestions(integer $sid,integer $gid): \CDbDataReader

Arguments

$sid

integer

$gid

integer

Response

\CDbDataReader

TODO: replace it everywhere by Answer::model()->findAll([Critieria Object])

getQuestionsForStatistics(string $fields,mixed $condition,string $orderby = false): array

Arguments

$fields

string

$condition

mixed

$orderby

string

Response

array

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.

getQuestionTemplateAttributes(array $aAttributeNames,array $aAttributeValues,\Question $oQuestion): mixed
static
deprecated

use QuestionTheme::getAdditionalAttrFromExtendedTheme() to retrieve question theme attributes and QuestionAttributeHelper->mergeQuestionAttributes() to merge with base attributes.

Arguments

$aAttributeNames

array

the values from getQuestionAttributesSettings($sType)

$aAttributeValues

array

$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

Response

mixed

returns the incoming parameter $aAttributeNames or

getQuestionType

getQuestionType(): null|\QuestionType

Response

null|\QuestionType

This function return the name by question type

getQuestionTypeName( $sType): string
static
deprecated

use $this->>questionType->description instead

Arguments

$sType

Response

string

Question type name

Maybe move class in typeList ?

getQuotableTypes

getQuotableTypes(): array<mixed,string>
static

Response

array<mixed,string>

getRenderererObject

getRenderererObject( $aFieldArray, $type = null)

Arguments

$aFieldArray

$type

Get array of answers options, depending on scale count for this question type.

getScaledAnswerOptions(): array

Response

array

Like [0 => Answer[]] or [0 => Answer[], 1 => Answer[]]

Get array of subquestions, depending on scale count for this question type.

getScaledSubquestions(): array

Response

array

Like [0 => Question[]] or [0 => Question[], 1 => Question[]]

getTypedesc

getTypedesc(): string

Response

string

getTypeGroup

getTypeGroup()

Increases all question_order numbers for questions belonging to the group by +1

increaseAllOrderNumbersForGroup(integer $questionGroupId)
static

Arguments

$questionGroupId

integer

insertRecords

insertRecords(array $data): boolean|null

Arguments

$data

array

Response

boolean|null

model

model( $class = __CLASS__): \Question
static
inheritdoc

Arguments

$class

Response

\Question

primaryKey

primaryKey()
inheritdoc

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

query(\CDbCriteria $criteria,boolean $all = false,boolean $asAR = true): mixed
inherited

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.

since 1.1.7

Arguments

$criteria

\CDbCriteria

the query criteria

$all

boolean

whether to return all data

$asAR

boolean

Response

mixed

the AR objects populated with the query result

relations

relations()
inheritdoc

remove question from lastVisited

removeFromLastVisited()

removeInvalidSubquestions

removeInvalidSubquestions()

rules

rules()
inheritdoc

TODO: make it easy to read (if possible)

Function to show encryption symbol in gridview attribute header if value ois encrypted

setEncryptedAttributeLabel(integer $surveyId,string $className,string $attributeName): string
inherited
Throws
\CException

Arguments

$surveyId

integer

$className

string

$attributeName

string

Response

string

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.

setQuestionOrderForGroup( $questionGroupId): boolean
static

Arguments

$questionGroupId

Response

boolean

true if sort numbers had to be set, false otherwise

tableName

tableName()
inheritdoc

This function contains the question type definitions.

typeList(string $language = null): array
static
deprecated

use QuestionTheme::findQuestionMetaDataForAllTypes() instead

Arguments

$language

string

Language for translation

Response

array

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

Override update() method to "clean" subquestions after saving a parent question

update( $attributes = null)

Arguments

$attributes

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

updateQuestionOrder(integer $gid,integer $startingOrder = 1)

Arguments

$gid

integer

$startingOrder

integer

the starting question order.

Rewrites sort order for questions in a group

updateSortOrder(integer $gid,integer $surveyid): void
static
static
access

public

Arguments

$gid

integer

$surveyid

integer

Constants

QT_1_ARRAY_MULTISCALE

QT_1_ARRAY_MULTISCALE

QT_5_POINT_CHOICE

QT_5_POINT_CHOICE

QT_A_ARRAY_5_CHOICE_QUESTIONS

QT_A_ARRAY_5_CHOICE_QUESTIONS

QT_B_ARRAY_10_CHOICE_QUESTIONS

QT_B_ARRAY_10_CHOICE_QUESTIONS

QT_C_ARRAY_YES_UNCERTAIN_NO

QT_C_ARRAY_YES_UNCERTAIN_NO

QT_D_DATE

QT_D_DATE

QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS

QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS

QT_F_ARRAY_FLEXIBLE_ROW

QT_F_ARRAY_FLEXIBLE_ROW

QT_G_GENDER_DROPDOWN

QT_G_GENDER_DROPDOWN

QT_H_ARRAY_FLEXIBLE_COLUMN

QT_H_ARRAY_FLEXIBLE_COLUMN

QT_I_LANGUAGE

QT_I_LANGUAGE

QT_K_MULTIPLE_NUMERICAL_QUESTION

QT_K_MULTIPLE_NUMERICAL_QUESTION

QT_L_LIST_DROPDOWN

QT_L_LIST_DROPDOWN

QT_M_MULTIPLE_CHOICE

QT_M_MULTIPLE_CHOICE

QT_N_NUMERICAL

QT_N_NUMERICAL

QT_O_LIST_WITH_COMMENT

QT_O_LIST_WITH_COMMENT

QT_P_MULTIPLE_CHOICE_WITH_COMMENTS

QT_P_MULTIPLE_CHOICE_WITH_COMMENTS

QT_Q_MULTIPLE_SHORT_TEXT

QT_Q_MULTIPLE_SHORT_TEXT

QT_R_RANKING_STYLE

QT_R_RANKING_STYLE

QT_S_SHORT_FREE_TEXT

QT_S_SHORT_FREE_TEXT

QT_T_LONG_FREE_TEXT

QT_T_LONG_FREE_TEXT

QT_U_HUGE_FREE_TEXT

QT_U_HUGE_FREE_TEXT

QT_X_BOILERPLATE_QUESTION

QT_X_BOILERPLATE_QUESTION

QT_Y_YES_NO_RADIO

QT_Y_YES_NO_RADIO

QT_Z_LIST_RADIO_FLEXIBLE

QT_Z_LIST_RADIO_FLEXIBLE

QT_EXCLAMATION_LIST_DROPDOWN

QT_EXCLAMATION_LIST_DROPDOWN

QT_VERTICAL_FILE_UPLOAD

QT_VERTICAL_FILE_UPLOAD

QT_ASTERISK_EQUATION

QT_ASTERISK_EQUATION

QT_COLON_ARRAY_MULTI_FLEX_NUMBERS

QT_COLON_ARRAY_MULTI_FLEX_NUMBERS

QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT

QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT

START_SORTING_VALUE

START_SORTING_VALUE

Properties

Stock the active group_name for questions list filtering

group_name :string
var

Stock the active group_name for questions list filtering

Type(s)

string

gid

gid :

Type(s)

Set defaut relevance *

relevance :

Type(s)

bEncryption

bEncryption :
inherited

Type(s)

qid

qid :integer

Question ID.

Type(s)

integer

sid

sid :integer

Survey ID

Type(s)

integer

gid

gid :integer

QuestionGroup ID where question is displayed

Type(s)

integer

type

type :string

Type(s)

string

title

title :string

Question Code

Type(s)

string

preg

preg :string

Type(s)

string

other

other :string

Other option enabled for question (Y/N)

Type(s)

string

mandatory

mandatory :string

Whether question is mandatory (Y/S/N)

Type(s)

string

encrypted

encrypted :string

Whether question is encrypted (Y/N)

Type(s)

string

question_order

question_order :integer

Question order in greoup

Type(s)

integer

parent_qid

parent_qid :integer

Questions parent question ID eg for subquestions

Type(s)

integer

scale_id

scale_id :integer

The scale ID

Type(s)

integer

same_default

same_default :integer

Saves if user set to use the same default value across languages in default options dialog ('Edit default answers')

Type(s)

integer

relevance

relevance :string

Questions relevane equation

Type(s)

string

modulename

modulename :string

Type(s)

string

survey

survey :\Survey

Type(s)

\Survey

groups

groups :\QuestionGroup

//@TODO should be singular

Type(s)

\QuestionGroup

parents

parents :\Question

//@TODO should be singular

Type(s)

\Question

subquestions

subquestions :array<mixed,\Question>

Type(s)

array<mixed,\Question>

questionAttributes

questionAttributes :array<mixed,\QuestionAttribute>

NB! returns all QuestionArrtibute Models fot this QID regardless of the specified language

Type(s)

array<mixed,\QuestionAttribute>

questionl10ns

questionl10ns :array<mixed,\QuestionL10n>

Question Languagesettings indexd by language code

Type(s)

array<mixed,\QuestionL10n>

quotableTypes

quotableTypes :array<mixed,string>

Question types that can be used for quotas

Type(s)

array<mixed,string>

answers

answers :array<mixed,\Answer>

Type(s)

array<mixed,\Answer>

questionType

questionType :\QuestionType

Type(s)

\QuestionType

allSubQuestionIds

allSubQuestionIds :array

QID-s of all question sub-questions, empty array returned if no sub-questions

Type(s)

array