Question

Extends \LSActiveRecord

Methods

Returns the static model of Settings table

model(string $class = __CLASS__) : \CActiveRecord
static
static
access

public

Arguments

$class

string

Response

\CActiveRecord

Returns the setting's table name to be used by the model

tableName() : string
access

public

Response

string

Returns the primary key of this table

primaryKey() : string[]
access

public

Response

string[]

Defines the relations for this model

relations() : array
access

public

Response

array

Returns this model's validation rules TODO: make it easy to read (if possible)

rules() 

Rewrites sort order for questions in a group

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

public

Arguments

$gid

int

$surveyid

int

Fixe sort order for questions in a group

updateQuestionOrder(int $gid, $language, $position) : void
static
access

public

Arguments

$gid

int

$language

$position

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

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

getQuestions($sid, $gid, $language) 

Arguments

$sid

$gid

$language

This function is only called from database.php TODO : create a relation to self called subquestion

getSubQuestions($parent_qid) 

Arguments

$parent_qid

This function is only called from surveyadmin.php TODO : create a relation to self called subquestion

getQuestionsWithSubQuestions($iSurveyID, $sLanguage, $sCondition = FALSE) 

Arguments

$iSurveyID

$sLanguage

$sCondition

Insert an array into the questions table Returns null if insertion fails, otherwise the new QID

insertRecords(array $data) 

This function is called from database.php and import_helper.php TODO: as said by Shnoulle, it must be replace by using validate and save from controller.

Arguments

$data

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

Arguments

$condition

$order

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

getQuestionsForStatistics($fields, $condition, $orderby = FALSE) 

Arguments

$fields

$condition

$orderby

getQuestionList

getQuestionList($surveyid, $language) 

Arguments

$surveyid

$language

getTypedesc

getTypedesc() 

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 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($random, $exclude_all_others = '') 

Arguments

$random

$exclude_all_others

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

Used in frontend helper, buildsurveysession.

getTotalQuestions(int $surveyid) : int
static

Arguments

$surveyid

int

Response

int

Used in frontend helper, buildsurveysession.

getNumberOfQuestions(int $surveyid) : array|\false???
static
todo

Rename

Arguments

$surveyid

int

Response

array|\false???

Return from CDbDataReader::read()

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

fixSubQuestions() : void
todo

: move other fix here ?

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

Response

mixed

the AR objects populated with the query result

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

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

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

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.

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.

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

mixed

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

integer

number of rows affected by the execution.

Properties

group_name

group_name : 

gid

gid :