QuestionCreate

Extends\Question

Class used when creating new 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 \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 = ''): string
inheritedstatic

Arguments

$value

string

String value which needs to be decrypted

Response

string

the decrypted string

Decrypt single value

decryptSingleOld(string $value = ''): string
inheritedstatic

Arguments

$value

string

String value which needs to be decrypted

Response

string

the decrypted string

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(): void
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

Delete all subquestions that belong to this question.

deleteAllSubquestions(): void
inherited
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 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

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(string|null $sLanguage = null,string|null $sQuestionThemeOverride = null): array
inherited

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.

Return if question allow other

getAllowOther(): boolean
inherited

Response

boolean

Return if question has managed subquestions usage in rules : allow set other even if existing subquestions 'other' exist (but deleted after)

getAllowSubquestions(): boolean
inherited

Response

boolean

getAllSubQuestionIds

getAllSubQuestionIds(): array
inherited

Response

array

getBasicFieldName

getBasicFieldName()
inherited

getbuttons

getbuttons()
inherited

getDataSetObject

getDataSetObject( $type = null)
inherited

Arguments

$type

Used by question create form.

getEmptyAnswerOption(): \Answer
inherited

Response

\Answer

Used by question create form.

getEmptySubquestion(): \Question
inherited

Response

\Question

getHasAnsweroptions

getHasAnsweroptions()
inherited
deprecated 5.3.x

unknow usage

Check if this question have subquestion with other code

getHasOtherSubquestions(): boolean
inherited

Response

boolean

getHasSubquestions

getHasSubquestions()
inherited
deprecated 5.3.x

unknow usage

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

getHighestQuestionOrderNumberInGroup(integer $questionGroupId): integer|null
inheritedstatic

($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

getInstance

getInstance( $iSurveyId, $type = null, $themeName = null)
static
todo

This is a factory method, not a singleton. Rename to make() or create().

Arguments

$iSurveyId

$type

$themeName

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 (example : 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

Return other icon according to state

getOtherIcon(): boolean
inherited

Response

boolean

getQuestionAttribute

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

Arguments

$sAttribute

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|false $orderby = false): array
inherited

Arguments

$fields

string

$condition

mixed

$orderby

string|false

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

Returns the QuestionTheme related to this question.

getQuestionTheme(): \QuestionTheme|null
inherited

It's not implemented as a relation because relations only work on persisted models.

Response

\QuestionTheme|null

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

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

getScaledAnswerOptions(): array
inherited

Response

array

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

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

getScaledSubquestions(): array
inherited

Response

array

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

getTypedesc

getTypedesc(): string
inherited

Response

string

NOTE: Not used anymore. Based on a deprecated method. Should be deprecated.

getTypeGroup

getTypeGroup()
inherited

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

increaseAllOrderNumbersForGroup(integer $questionGroupId)
inheritedstatic

Arguments

$questionGroupId

integer

insertRecords

insertRecords(array $data): boolean|null
inherited

Arguments

$data

array

Response

boolean|null

model

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

Arguments

$className

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

Validates the question theme name, making sure it's not empty or 'core'

questionThemeNameValidator()
inherited

relations

relations()
inherited
inheritdoc

remove question from lastVisited

removeFromLastVisited()
inherited

Remove subquestion if needed when update question type

removeInvalidSubquestions(): void
inherited

rules

rules()
inherited
inheritdoc

TODO: make it easy to read (if possible)

scopes

scopes()
inherited
inheritdoc

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
inheritedstatic

Arguments

$questionGroupId

Response

boolean

true if sort numbers had to be set, false otherwise

Returns true if the answer options should be ordered alphabetically.

shouldOrderAnswersAlphabetically(): boolean
inherited

Response

boolean

Returns true if the answer options should be ordered randomly.

shouldOrderAnswersRandomly(): boolean
inherited

Response

boolean

Returns the specified answer options sorted according to the question attributes.

sortAnswerOptions( $answerOptions): \array<int,Answer[]>
inherited

Refactored from getOrderedAnswers();

Arguments

$answerOptions

Response

\array

tableName

tableName()
inherited
inheritdoc

This function contains the question type definitions.

typeList(string $language = null): array
inheritedstatic
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)
inherited

Arguments

$attributes

Updates records with the specified condition.

updateAll(array $attributes,mixed $condition = '',array $params = array()): integer
inherited

XSS filtering is enforced for attributes listed in model's $xssFilterAttributes property. See \find() for detailed explanation about $condition and $params. Note, the attributes are not checked for safety and no validation is done.

Arguments

$attributes

array

list of attributes (name=>$value) to be updated

$condition

mixed

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

integer

the number of rows being updated

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_DUAL

QT_1_ARRAY_DUAL
inherited

QT_5_POINT_CHOICE

QT_5_POINT_CHOICE
inherited

QT_A_ARRAY_5_POINT

QT_A_ARRAY_5_POINT
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_INC_SAME_DEC

QT_E_ARRAY_INC_SAME_DEC
inherited

QT_F_ARRAY

QT_F_ARRAY
inherited

QT_G_GENDER

QT_G_GENDER
inherited

QT_H_ARRAY_COLUMN

QT_H_ARRAY_COLUMN
inherited

QT_I_LANGUAGE

QT_I_LANGUAGE
inherited

QT_K_MULTIPLE_NUMERICAL

QT_K_MULTIPLE_NUMERICAL
inherited

QT_L_LIST

QT_L_LIST
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

QT_R_RANKING
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_TEXT_DISPLAY

QT_X_TEXT_DISPLAY
inherited

QT_Y_YES_NO_RADIO

QT_Y_YES_NO_RADIO
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_NUMBERS

QT_COLON_ARRAY_NUMBERS
inherited

QT_SEMICOLON_ARRAY_TEXT

QT_SEMICOLON_ARRAY_TEXT
inherited

START_SORTING_VALUE

START_SORTING_VALUE
inherited

DEFAULT_QUESTION_THEME

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

Defaut relevance *

relevance :
inherited

Type(s)

defaut same_script , avoid public break during update *

same_script :
inherited

Type(s)

cached question theme

relatedQuestionTheme :\QuestionTheme
inherited
var

cached question theme

Type(s)

\QuestionTheme

Array of attributes that should be XSS filtered on mass updates

xssFilterAttributes :array<mixed,string>
inherited
var

Array of attributes that should be XSS filtered on mass updates

Type(s)

array<mixed,string>

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 ('Edit default answers')

Type(s)

integer

relevance

relevance :string
inherited

Questions relevane equation

Type(s)

string

modulename

modulename :string
inherited

Type(s)

string

same_script

same_script :integer
inherited

Whether the same script should be used for all languages

Type(s)

integer

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 subquestions, empty array returned if no subquestions

Type(s)

array