Question

Extends \LSActiveRecord

Class Question

inheritdoc

Methods

model

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

Arguments

$class

Response

\Question

tableName

tableName() 
inheritdoc

primaryKey

primaryKey() 
inheritdoc

relations

relations() 
inheritdoc

rules

rules() 
inheritdoc

TODO: make it easy to read (if possible)

Rewrites sort order for questions in a group

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

public

Arguments

$gid

int

$surveyid

int

Fix sort order for questions in a group

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

Arguments

$gid

int

$language

string

$position

int

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

getAdvancedSettingsWithValues(int $iQuestionID, string $sQuestionType, int $iSurveyID, string $sLanguage = null) : array
access

public

Arguments

$iQuestionID

int

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

$sQuestionType

string

The question type

$iSurveyID

int

$sLanguage

string

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

Response

array

getQuestionTemplateAttributes

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

Arguments

$aAttributeNames

array

$aAttributeValues

array

$oQuestion

\Question

Response

mixed

getTypeGroup

getTypeGroup() 

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

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

Delete a bunch of questions in one go

deleteAllById(mixed $questionsIds) : void
static

Arguments

$questionsIds

mixed

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

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

getQuestionList

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

Arguments

$surveyid

integer

$language

string

Response

array

getTypedesc

getTypedesc() : string

Response

string

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

This function return the name by question type

getQuestionTypeName($sType) : string
static

Arguments

$sType

Response

string

Question type name Maybe move class in typeList ?

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 ?

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

getAllGroups() 

getbuttons

getbuttons() 

getOrderedAnswers

getOrderedAnswers($random, $alpha) 

Arguments

$random

$alpha

get subquestions fort the current question object in the right order

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

Arguments

$random

int

$exclude_all_others

string

Response

array

getMandatoryIcon

getMandatoryIcon() 

getOtherIcon

getOtherIcon() 

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

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

beforeSave() : bool

Response

bool

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

fixSubQuestions() : void
todo

: move other fix here ?

getQuotableTypes

getQuotableTypes() : string[]
static

Response

string[]

getBasicFieldName

getBasicFieldName() 

getQuestionAttributes

getQuestionAttributes() : \QuestionAttribute[]

Response

\QuestionAttribute[]

Lists the behaviors of this model

behaviors() : array
inherited

Below is a list of all behaviors we register:

see \CTimestampBehavior \PluginEventBehavior

Response

array

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, bool $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

bool

Response

mixed

the AR objects populated with the query result

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

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

See {@link 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.

Return the max value for a field

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

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

throws

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

Return the min value for a field

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

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

throws

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

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.

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 : 

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 : \Question[]

Type(s)

\Question[]

questionAttributes

questionAttributes : \QuestionAttribute[]

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

Type(s)

\QuestionAttribute[]

quotableTypes

quotableTypes : string[]

Question types that can be used for quotas

Type(s)

string[]