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 \CTimestampBehavior \PluginEventBehavior

Response

array

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

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

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

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

Arguments

$condition

\CDbCriteria

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.

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

Return all group of the active survey Used to render group filter in questions list

getAllGroups() 

This function is called from everywhere, which is quiet weird.

getAllRecords( $condition,  $order = false) 

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

Arguments

$condition

$order

getBasicFieldName

getBasicFieldName() 

getbuttons

getbuttons() 

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( $random,  $alpha) 

Arguments

$random

$alpha

get subquestions fort the current question object in the right order

getOrderedSubQuestions(integer $random, string $exclude_all_others = '') : array

Arguments

$random

integer

$exclude_all_others

string

Response

array

getOtherIcon

getOtherIcon() 

getQuestionAttributes

getQuestionAttributes() : array<mixed,\QuestionAttribute>

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 ?

getQuestionList

getQuestionList(integer $surveyid, string $language) : array

Arguments

$surveyid

integer

$language

string

Response

array

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

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

Arguments

$sid

integer

$gid

integer

$language

string

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

This function is only called from surveyadmin.php

getQuestionsWithSubQuestions(integer $iSurveyID, string $sLanguage, string|boolean $sCondition = false) : array

Arguments

$iSurveyID

integer

$sLanguage

string

$sCondition

string|boolean

Response

array

getQuestionTemplateAttributes

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

Arguments

$aAttributeNames

array

$aAttributeValues

array

$oQuestion

\Question

Response

mixed

This function return the name by question type

getQuestionTypeName( $sType) : string
static

Arguments

$sType

Response

string

Question type name

Maybe move class in typeList ?

getQuotableTypes

getQuotableTypes() : array<mixed,string>
static

Response

array<mixed,string>

getTypedesc

getTypedesc() : string

Response

string

getTypeGroup

getTypeGroup() 

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

rules

rules() 
inheritdoc

TODO: make it easy to read (if possible)

tableName

tableName() 
inheritdoc

This function contains the question type definitions.

typeList() : array
static

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

Fix sort order for questions in a group

updateQuestionOrder(integer $gid, string $language, integer $position) 

Arguments

$gid

integer

$language

string

$position

integer

Rewrites sort order for questions in a group

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

public

Arguments

$gid

integer

$surveyid

integer

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)

qid

qid : integer

Question ID. Note: Primary key is qid & language columns combined

Type(s)

integer

sid

sid : integer

Survey ID

Type(s)

integer

gid

gid : integer

QuestionGroup ID where question is diepolayed

Type(s)

integer

type

type : string

Type(s)

string

title

title : string

Question Code

Type(s)

string

question

question : string

Question dieplay text. The actual question.

Type(s)

string

preg

preg : string

Type(s)

string

help

help : string

Question help-text for display

Type(s)

string

other

other : string

Other option enabled for question (Y/N)

Type(s)

string

mandatory

mandatory : string

Whther question is mandatory (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

language

language : string

Question language code. Note: Primary key is qid & language columns combined

Type(s)

string

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

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>

quotableTypes

quotableTypes : array<mixed,string>

Question types that can be used for quotas

Type(s)

array<mixed,string>