QuestionCreate

Extends\Question

Class Question

package

Default

Methods

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

beforeSave(): boolean
inherited

Response

boolean

Lists the behaviors of this model

behaviors(): array
inherited

Below is a list of all behaviors we register:

see \CTimestampBehavior\PluginEventBehavior

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
inherited
Throws
\CDbException

Response

boolean

Delete all question and its subQuestion Answers

deleteAllAnswers()
inherited

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
inheritedstatic

Arguments

$questionsIds

mixed

dispatchPluginModelEvent

dispatchPluginModelEvent(string $sEventName,\CDbCriteria $criteria = null,array $eventParams = array(): \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 decrypted

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
inherited
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(integer $iQuestionID,string $sQuestionType,integer $iSurveyID,string $sLanguage = null): array
inherited
access

public

Arguments

$iQuestionID

integer

The question ID - if 0 then all settings will use the default value

$sQuestionType

string

The question type

$iSurveyID

integer

$sLanguage

string

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

Response

array

getAllEncryptedAttributes

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

Arguments

$iSurveyId

integer

$sClassName

string

Response

array

getAllSubQuestionIds

getAllSubQuestionIds(): array
inherited

Response

array

getBasicFieldName

getBasicFieldName()
inherited

getbuttons

getbuttons()
inherited

getDataSetObject

getDataSetObject( $type = null)
inherited

Arguments

$type

getHasAnsweroptions

getHasAnsweroptions()
inherited

getHasSubquestions

getHasSubquestions()
inherited

getInstance

getInstance( $iSurveyId, $type)
static

Arguments

$iSurveyId

$type

getMandatoryIcon

getMandatoryIcon()
inherited

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
inherited

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)
inherited

Arguments

$scale_id

get subquestions fort the current question object in the right order

getOrderedSubQuestions( $scale_id = null): array
inherited

Arguments

$scale_id

Response

array

getOtherIcon

getOtherIcon()
inherited

getQuestionAttribute

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

Arguments

$sAttribute

Response

array<mixed,\QuestionAttribute>

getQuestionAttributes

getQuestionAttributes(): array<mixed,\QuestionAttribute>
inherited

Response

array<mixed,\QuestionAttribute>

This function return the class by question type

getQuestionClass( $sType): string
inheritedstatic

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>
inherited

Arguments

$surveyid

integer

Response

array<mixed,\Question>

getQuestionListColumns

getQuestionListColumns()
inherited

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

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

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
inherited

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
inheritedstatic

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
inherited

Response

null|\QuestionType

This function return the name by question type

getQuestionTypeName( $sType): string
inheritedstatic
deprecated

use $this->>questionType->description instead

Arguments

$sType

Response

string

Question type name

Maybe move class in typeList ?

getQuotableTypes

getQuotableTypes(): array<mixed,string>
inheritedstatic

Response

array<mixed,string>

getRenderererObject

getRenderererObject( $aFieldArray, $type = null)
inherited

Arguments

$aFieldArray

$type

getTypedesc

getTypedesc(): string
inherited

Response

string

getTypeGroup

getTypeGroup()
inherited

insertRecords

insertRecords(array $data): boolean|null
inherited

Arguments

$data

array

Response

boolean|null

model

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

Arguments

$class

Response

\Question

primaryKey

primaryKey()
inherited
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()
inherited
inheritdoc

remove question from lastVisited

removeFromLastVisited()
inherited

removeInvalidSubquestions

removeInvalidSubquestions()
inherited

rules

rules()
inherited
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

tableName

tableName()
inherited
inheritdoc

This function contains the question type definitions.

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

use QuestionType::modelsAttributes() 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)
inherited

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)
inherited

Arguments

$gid

integer

$startingOrder

integer

the starting question order.

Rewrites sort order for questions in a group

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

public

Arguments

$gid

integer

$surveyid

integer

Constants

QT_1_ARRAY_MULTISCALE

QT_1_ARRAY_MULTISCALE
inherited

QT_5_POINT_CHOICE

QT_5_POINT_CHOICE
inherited

QT_A_ARRAY_5_CHOICE_QUESTIONS

QT_A_ARRAY_5_CHOICE_QUESTIONS
inherited

QT_B_ARRAY_10_CHOICE_QUESTIONS

QT_B_ARRAY_10_CHOICE_QUESTIONS
inherited

QT_C_ARRAY_YES_UNCERTAIN_NO

QT_C_ARRAY_YES_UNCERTAIN_NO
inherited

QT_D_DATE

QT_D_DATE
inherited

QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS

QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS
inherited

QT_F_ARRAY_FLEXIBLE_ROW

QT_F_ARRAY_FLEXIBLE_ROW
inherited

QT_G_GENDER_DROPDOWN

QT_G_GENDER_DROPDOWN
inherited

QT_H_ARRAY_FLEXIBLE_COLUMN

QT_H_ARRAY_FLEXIBLE_COLUMN
inherited

QT_I_LANGUAGE

QT_I_LANGUAGE
inherited

QT_K_MULTIPLE_NUMERICAL_QUESTION

QT_K_MULTIPLE_NUMERICAL_QUESTION
inherited

QT_L_LIST_DROPDOWN

QT_L_LIST_DROPDOWN
inherited

QT_M_MULTIPLE_CHOICE

QT_M_MULTIPLE_CHOICE
inherited

QT_N_NUMERICAL

QT_N_NUMERICAL
inherited

QT_O_LIST_WITH_COMMENT

QT_O_LIST_WITH_COMMENT
inherited

QT_P_MULTIPLE_CHOICE_WITH_COMMENTS

QT_P_MULTIPLE_CHOICE_WITH_COMMENTS
inherited

QT_Q_MULTIPLE_SHORT_TEXT

QT_Q_MULTIPLE_SHORT_TEXT
inherited

QT_R_RANKING_STYLE

QT_R_RANKING_STYLE
inherited

QT_S_SHORT_FREE_TEXT

QT_S_SHORT_FREE_TEXT
inherited

QT_T_LONG_FREE_TEXT

QT_T_LONG_FREE_TEXT
inherited

QT_U_HUGE_FREE_TEXT

QT_U_HUGE_FREE_TEXT
inherited

QT_X_BOILERPLATE_QUESTION

QT_X_BOILERPLATE_QUESTION
inherited

QT_Y_YES_NO_RADIO

QT_Y_YES_NO_RADIO
inherited

QT_Z_LIST_RADIO_FLEXIBLE

QT_Z_LIST_RADIO_FLEXIBLE
inherited

QT_EXCLAMATION_LIST_DROPDOWN

QT_EXCLAMATION_LIST_DROPDOWN
inherited

QT_VERTICAL_FILE_UPLOAD

QT_VERTICAL_FILE_UPLOAD
inherited

QT_ASTERISK_EQUATION

QT_ASTERISK_EQUATION
inherited

QT_COLON_ARRAY_MULTI_FLEX_NUMBERS

QT_COLON_ARRAY_MULTI_FLEX_NUMBERS
inherited

QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT

QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT
inherited

Properties

Stock the active group_name for questions list filtering

group_name :string
inherited
var

Stock the active group_name for questions list filtering

Type(s)

string

gid

gid :
inherited

Type(s)

bEncryption

bEncryption :
inherited

Type(s)

qid

qid :integer
inherited

Question ID.

Type(s)

integer

sid

sid :integer
inherited

Survey ID

Type(s)

integer

gid

gid :integer
inherited

QuestionGroup ID where question is displayed

Type(s)

integer

type

type :string
inherited

Type(s)

string

title

title :string
inherited

Question Code

Type(s)

string

preg

preg :string
inherited

Type(s)

string

other

other :string
inherited

Other option enabled for question (Y/N)

Type(s)

string

mandatory

mandatory :string
inherited

Whether question is mandatory (Y/S/N)

Type(s)

string

encrypted

encrypted :string
inherited

Whether question is encrypted (Y/N)

Type(s)

string

question_order

question_order :integer
inherited

Question order in greoup

Type(s)

integer

parent_qid

parent_qid :integer
inherited

Questions parent question ID eg for subquestions

Type(s)

integer

scale_id

scale_id :integer
inherited

The scale ID

Type(s)

integer

same_default

same_default :integer
inherited

Saves if user set to use the same default value across languages in default options dialog

Type(s)

integer

relevance

relevance :string
inherited

Questions relevane equation

Type(s)

string

modulename

modulename :string
inherited

Type(s)

string

survey

survey :\Survey
inherited

Type(s)

\Survey

groups

groups :\QuestionGroup
inherited

//@TODO should be singular

Type(s)

\QuestionGroup

parents

parents :\Question
inherited

//@TODO should be singular

Type(s)

\Question

subquestions

subquestions :array<mixed,\Question>
inherited

Type(s)

array<mixed,\Question>

questionAttributes

questionAttributes :array<mixed,\QuestionAttribute>
inherited

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

Type(s)

array<mixed,\QuestionAttribute>

questionl10ns

questionl10ns :array<mixed,\QuestionL10n>
inherited

Question Languagesettings indexd by language code

Type(s)

array<mixed,\QuestionL10n>

quotableTypes

quotableTypes :array<mixed,string>
inherited

Question types that can be used for quotas

Type(s)

array<mixed,string>

answers

answers :array<mixed,\Answer>
inherited

Type(s)

array<mixed,\Answer>

questionType

questionType :\QuestionType
inherited

Type(s)

\QuestionType

allSubQuestionIds

allSubQuestionIds :array
inherited

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

Type(s)

array