Survey

Extends \LSActiveRecord

Class Survey

Methods

init to set default

init() 

attributeLabels

attributeLabels() 

Returns the title of the survey. Uses the current language and falls back to the surveys' default language if the current language is not available.

getLocalizedTitle() 

Expires a survey. If the object was invoked using find or new surveyId can be ommited.

expire(int $surveyId = null) : bool

Arguments

$surveyId

int

Response

bool

Returns the table's name

tableName() : string
access

public

Response

string

Returns the table's primary key

primaryKey() : string
access

public

Response

string

Returns the static model of Settings table

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

public

Arguments

$class

string

Response

\Survey

Returns this model's relations

relations() : array
access

public

Response

array

Returns this model's scopes

scopes() : array
access

public

Response

array

Returns this model's validation rules

rules() 

fixSurveyAttribute to fix and/or add some survey attribute - Fix template name to be sure template exist

fixSurveyAttribute($event) 

Arguments

$event

filterTemplateSave to fix some template name

filterTemplateSave($sTemplateName) 

Arguments

$sTemplateName

permission scope for this model Actually only test if user have minimal access to survey (read)

permission(int $loginID) : \CActiveRecord
access

public

Arguments

$loginID

int

Response

\CActiveRecord

TODO: replace this by a correct relation

Returns additional languages formatted into a string

getAdditionalLanguages() : array
access

public

Response

array

Returns all languages array

getAllLanguages() : array
access

public

Response

array

Returns the additional token attributes

getTokenAttributes() : array
access

public

Response

array

Returns true in a token table exists for the given $surveyId

hasTokens(int $iSurveyID) : boolean
staticvar

array $tokens

Arguments

$iSurveyID

int

Response

boolean

getHasTokens

getHasTokens() 

Returns the value for the SurveyEdit GoogleAnalytics API-Key UseGlobal Setting

getGoogleanalyticsapikeysetting() 

setGoogleanalyticsapikeysetting

setGoogleanalyticsapikeysetting($value) 

Arguments

$value

Returns the value for the SurveyEdit GoogleAnalytics API-Key UseGlobal Setting

getGoogleanalyticsapikey() 

Creates a new survey - does some basic checks of the suppplied data

insertNewSurvey(array $aData) : integer

Arguments

$aData

array

Array with fieldname=>fieldcontents data

Response

integer

The new survey id

Deletes a survey and all its data

deleteSurvey(int $iSurveyID, $recursive = true) : boolean
access

public

Arguments

$iSurveyID

int

$recursive

Response

boolean

findByPk

findByPk($pk, $condition = '', $params = array()) 

Arguments

$pk

$condition

$params

findByPk uses a cache to store a result. Use this method to force clearing that cache.

resetCache() 

Attribute renamed to questionindex in dbversion 169 Y maps to 1 otherwise 0;

setAllowjumps(\type $value) 

Arguments

$value

\type

getSurveyinfo

getSurveyinfo() : array

Response

array

getCreationDate

getCreationDate() 

getAnonymizedResponses

getAnonymizedResponses() 

getActiveWord

getActiveWord() 

Get state of survey, which can be one of five: 1. Not active 2. Expired 3. Will expire in the future (running now) 3. Will run in future 4. Running now (no expiration date)

getState() : string

Code copied from getRunning below.

Response

string

  • 'inactive', 'expired', 'willRun', 'willExpire' or 'running'

getRunning

getRunning() 
todo

Document code, please.

getPartialAnswers

getPartialAnswers() 

getIsActive

getIsActive() 

getFullAnswers

getFullAnswers() 

getCountFullAnswers

getCountFullAnswers() 

getCountPartialAnswers

getCountPartialAnswers() 

getCountTotalAnswers

getCountTotalAnswers() 

getbuttons

getbuttons() 

Transcribe from 3 checkboxes to 1 char for captcha usages Uses variables from $_POST

transcribeCaptchaOptions() : string
static

'A' = All three captcha enabled 'B' = All but save and load 'C' = All but registration 'D' = All but survey access 'X' = Only survey access 'R' = Only registration 'S' = Only save and load 'N' = None

todo

Should really be saved as three fields in the database!

Response

string

One character that corresponds to captcha usage

Method to make an approximation on how long a survey will last Approx is 3 questions each minute.

calculateEstimatedTime() : double

Response

double

Get all surveys that has participant table

getSurveysWithTokenTable() : \Survey[]
static

Response

\Survey[]

Fix invalid question in this survey

fixInvalidQuestions() 

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

This is a static cache, it lasts only during the active request. If you ever need to clear it, like on activation of a survey when in the same request a row is read, saved and read again you can use resetCache() method.

findByPkCache : array
var

Type(s)

array

format

format : 

htmlemail

htmlemail : 

searched_value

searched_value : 

fac

fac : 

pac

pac : 

sid

sid : integer

primary key

Type(s)

integer

owner_id

owner_id : integer

Type(s)

integer

admin

admin : string

Type(s)

string

active

active : string

Type(s)

string

expires

expires : string

Expiry date

Type(s)

string

startdate

startdate : string

Type(s)

string

adminemail

adminemail : string

Type(s)

string

anonymized

anonymized : string

Type(s)

string

faxto

faxto : string

Type(s)

string

format

format : string

Type(s)

string

savetimings

savetimings : string

Type(s)

string

template

template : string

Template name

Type(s)

string

language

language : string

Type(s)

string

additional_languages

additional_languages : string

Type(s)

string

datestamp

datestamp : string

Type(s)

string

usecookie

usecookie : string

Type(s)

string

allowsave

allowsave : string

Type(s)

string

autonumber_start

autonumber_start : integer

Type(s)

integer

autoredirect

autoredirect : string

Type(s)

string

allowprev

allowprev : string

Type(s)

string

printanswers

printanswers : string

Type(s)

string

ipaddr

ipaddr : string

Type(s)

string

refurl

refurl : string

Type(s)

string

datecreated

datecreated : string

Type(s)

string

publicstatistics

publicstatistics : string

Type(s)

string

publicgraphs

publicgraphs : string

Type(s)

string

listpublic

listpublic : string

Type(s)

string

htmlemail

htmlemail : string

Type(s)

string

sendconfirmation

sendconfirmation : string

Type(s)

string

tokenanswerspersistence

tokenanswerspersistence : string

Type(s)

string

assessments

assessments : string

Type(s)

string

usecaptcha

usecaptcha : string

Type(s)

string

usetokens

usetokens : string

Type(s)

string

bounce_email

bounce_email : string

Type(s)

string

attributedescriptions

attributedescriptions : string

Type(s)

string

emailresponseto

emailresponseto : string

Type(s)

string

emailnotificationto

emailnotificationto : integer

Type(s)

integer

showxquestions

showxquestions : string

Type(s)

string

showgroupinfo

showgroupinfo : string

Type(s)

string

shownoanswer

shownoanswer : string

Type(s)

string

showqnumcode

showqnumcode : string

Type(s)

string

bouncetime

bouncetime : integer

Type(s)

integer

bounceprocessing

bounceprocessing : string

Type(s)

string

bounceaccounttype

bounceaccounttype : string

Type(s)

string

bounceaccounthost

bounceaccounthost : string

Type(s)

string

bounceaccountpass

bounceaccountpass : string

Type(s)

string

bounceaccountencryption

bounceaccountencryption : string

Type(s)

string

bounceaccountuser

bounceaccountuser : string

Type(s)

string

showwelcome

showwelcome : string

Type(s)

string

showprogress

showprogress : string

Type(s)

string

questionindex

questionindex : integer

Type(s)

integer

navigationdelay

navigationdelay : integer

Type(s)

integer

nokeyboard

nokeyboard : string

Type(s)

string

alloweditaftercompletion

alloweditaftercompletion : string

Type(s)

string

googleanalyticsstyle

googleanalyticsstyle : string

Type(s)

string

googleanalyticsapikey

googleanalyticsapikey : string

Type(s)

string

permissions

permissions : \Permission[]

Type(s)

\Permission[]

languagesettings

languagesettings : \SurveyLanguageSetting[]

Type(s)

\SurveyLanguageSetting[]

owner

owner : \User

Type(s)

\User

groups

groups : \QuestionGroup[]

Type(s)

\QuestionGroup[]

quotas

quotas : \Quota[]

Type(s)

\Quota[]