Survey

Extends \LSActiveRecord

Class Survey

Methods

Set defaults

init() 
inheritdoc

attributeLabels

attributeLabels() 
inheritdoc

delete

delete() 
inheritdoc

The Survey languagesettings in currently active language. Falls back to the surveys' default language if the current language is not available.

getCurrentLanguageSettings() : \SurveyLanguageSetting

Return the language of the current survey It can be: - the selected language by user via the language selector (POST then Session) - the selected language via URL (GET then Session) - the survey default language

getLanguageForSurveyTaking() : string

Response

string

the correct language

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

expire(int $surveyId = null) : boolean|null

Arguments

$surveyId

int

Response

boolean|null

tableName

tableName() 
inheritdoc

primaryKey

primaryKey() 
inheritdoc

model

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

Arguments

$class

Response

\Survey

relations

relations() 
inheritdoc

scopes

scopes() 
inheritdoc

rules

rules() 
inheritdoc

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

afterFindSurvey() 

filterTemplateSave to fix some template name

filterTemplateSave(string $sTemplateName) : string

Arguments

$sTemplateName

string

Response

string

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

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

Return the name of survey tokens table

getTokensTableName() : string

Response

string

Return the name of survey timigs table

getTimingsTableName() : string

Response

string

Return the name of survey responses (the data) table name

getResponsesTableName() : string

Response

string

Returns true in a survey participants table exists for survey

getHasTokensTable() : boolean

Response

boolean

Wheteher the survey reponses (data) table exists in DB

getHasResponsesTable() : boolean

Response

boolean

Wheteher the survey reponses timings exists in DB

getHasTimingsTable() : boolean

Response

boolean

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

getGoogleanalyticsapikeysetting() : string

Response

string

setGoogleanalyticsapikeysetting

setGoogleanalyticsapikeysetting(string $value) 

Arguments

$value

string

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

getGoogleanalyticsapikey() : string

Response

string

getSurveyTemplateConfiguration

getSurveyTemplateConfiguration() 

__useTranslationForSurveymenu

__useTranslationForSurveymenu($entryData) 

Arguments

$entryData

_createSurveymenuArray

_createSurveymenuArray($oSurveyMenuObjects) 

Arguments

$oSurveyMenuObjects

_getSurveymenuSubmenus

_getSurveymenuSubmenus($oParentSurveymenu) 

Arguments

$oParentSurveymenu

_getDefaultSurveyMenus

_getDefaultSurveyMenus($position = '') 

Arguments

$position

Get surveymenu configuration This will be made bigger in future releases, but right now it only collects the default menu-entries

getSurveyMenus($position = '') 

Arguments

$position

Creates a new survey - with a random sid

insertNewSurvey(array $aData) : \Survey

Arguments

$aData

array

Array with fieldname=>fieldcontents data

Response

\Survey

Deletes a survey and all its data

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

public

Arguments

$iSurveyID

int

$recursive

bool

Response

boolean

findByPk

findByPk($pk, $condition = '', $params = array()) : \Survey
inheritdoc

Arguments

$pk

$condition

$params

Response

\Survey

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(string $value) 

Arguments

$value

string

getDateFormatted

getDateFormatted(string $attribute) : string

Arguments

$attribute

string

date attribute name

Response

string

formatted date

getCreationDate

getCreationDate() : string

Response

string

formatted date

getStartDateFormatted

getStartDateFormatted() : string

Response

string

formatted date

getExpiryDateFormatted

getExpiryDateFormatted() : string

Response

string

formatted date

getAnonymizedResponses

getAnonymizedResponses() : string

Response

string

getActiveWord

getActiveWord() : string

Response

string

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() : string
todo

Document code, please.

Response

string

getPartialAnswers

getPartialAnswers() : array|null

Response

array|null

getIsActive

getIsActive() : bool

Response

bool

getIsAnonymized

getIsAnonymized() : bool

Response

bool

getIsSaveTimings

getIsSaveTimings() : bool

Response

bool

getIsDateStamp

getIsDateStamp() : bool

Response

bool

getIsUseCookie

getIsUseCookie() : bool

Response

bool

getIsAllowRegister

getIsAllowRegister() : bool

Response

bool

getIsAllowSave

getIsAllowSave() : bool

Response

bool

getIsAutoRedirect

getIsAutoRedirect() : bool

Response

bool

getIsAllowPrev

getIsAllowPrev() : bool

Response

bool

getIsPrintAnswers

getIsPrintAnswers() : bool

Response

bool

getIsIpAddr

getIsIpAddr() : bool

Response

bool

getIsRefUrl

getIsRefUrl() : bool

Response

bool

getIsPublicStatistics

getIsPublicStatistics() : bool

Response

bool

getIsPublicGraphs

getIsPublicGraphs() : bool

Response

bool

getIsListPublic

getIsListPublic() : bool

Response

bool

getIsHtmlEmail

getIsHtmlEmail() : bool

Response

bool

getIsSendConfirmation

getIsSendConfirmation() : bool

Response

bool

getIsTokenAnswersPersistence

getIsTokenAnswersPersistence() : bool

Response

bool

getIsAssessments

getIsAssessments() : bool

Response

bool

getIsShowXQuestions

getIsShowXQuestions() : bool

Response

bool

getIsShowGroupInfo

getIsShowGroupInfo() : bool

Response

bool

getIsShowNoAnswer

getIsShowNoAnswer() : bool

Response

bool

getIsShowQnumCode

getIsShowQnumCode() : bool

Response

bool

getIsShowWelcome

getIsShowWelcome() : bool

Response

bool

getIsShowProgress

getIsShowProgress() : bool

Response

bool

getIsNoKeyboard

getIsNoKeyboard() : bool

Response

bool

getIsAllowEditAfterCompletion

getIsAllowEditAfterCompletion() : bool

Response

bool

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

getFullAnswers

getFullAnswers() : array|null

Response

array|null

getCountFullAnswers

getCountFullAnswers() : int|string

Response

int|string

getCountPartialAnswers

getCountPartialAnswers() : int

Response

int

getCountTotalAnswers

getCountTotalAnswers() : int

Response

int

getbuttons

getbuttons() : string

Response

string

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

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

saveTranscribeCaptchaOptions(\Survey $oSurvey) : 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!

Arguments

$oSurvey

\Survey

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

getsSurveyUrl

getsSurveyUrl() 

getQuotableQuestions

getQuotableQuestions() : \Question[]

Response

\Question[]

Get the DB criteria to get questions as ordered in survey

getQuestionOrderCriteria() : \CDbCriteria

Response

\CDbCriteria

Gets number of groups inside a particular survey

getGroupsCount() 

getCountTotalQuestions

getCountTotalQuestions() : integer

Response

integer

Get the coutn of questions that do not need input (skipping text-display etc.)

getCountNoInputQuestions() : integer

Response

integer

Get the coutn of questions that need input (skipping text-display etc.)

getCountInputQuestions() : integer

Response

integer

Returns true if this survey has any question of type $type.

hasQuestionType(string $type, boolean $includeSubquestions = false) : boolean
throws

Arguments

$type

string

Question type, like 'L', 'T', etc.

$includeSubquestions

boolean

If true, will also check the types of subquestions.

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

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.

active

active() : mixed

Response

mixed

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

searched_value

searched_value : 

sSurveyUrl

sSurveyUrl : 

sid

sid : integer

Survey ID

Type(s)

integer

owner_id

owner_id : integer

Type(s)

integer

gsid

gsid : integer

Survey ID

Type(s)

integer

admin

admin : string

Survey Admin's full name

Type(s)

string

active

active : string

Whether survey is acive or not (Y/N)

Type(s)

string

expires

expires : string

Expiry date (YYYY-MM-DD hh:mm:ss)

Type(s)

string

startdate

startdate : string

Survey Start date (YYYY-MM-DD hh:mm:ss)

Type(s)

string

adminemail

adminemail : string

Survey administrator email address

Type(s)

string

anonymized

anonymized : string

Whether survey is anonymized or not (Y/N)

Type(s)

string

faxto

faxto : string

Type(s)

string

format

format : string

A : All in one, G : Group by group, Q : question by question

Type(s)

string

savetimings

savetimings : string

Whether survey timings are saved (Y/N)

Type(s)

string

template

template : string

Template name

Type(s)

string

language

language : string

Survey base language

Type(s)

string

additional_languages

additional_languages : string

Survey additional languages delimited by space ' '

Type(s)

string

datestamp

datestamp : string

Whether respondents' datestamps will be saved (Y/N)

Type(s)

string

usecookie

usecookie : string

Are cookies used to prevent repeated participation (Y/N)

Type(s)

string

allowregister

allowregister : string

Allow public registration (Y/N)

Type(s)

string

allowsave

allowsave : string

Is participant allowed save and resume later (Y/N)

Type(s)

string

autonumber_start

autonumber_start : integer

Type(s)

integer

tokenlength

tokenlength : integer

Token length: MIN:5 MAX:36

Type(s)

integer

autoredirect

autoredirect : string

Automatically load URL when survey complete: (Y/N)

Type(s)

string

allowprev

allowprev : string

Allow backwards navigation (Y/N)

Type(s)

string

printanswers

printanswers : string

Participants may print answers: (Y/N)

Type(s)

string

ipaddr

ipaddr : string

Whether Participants IP address will be saved: (Y/N)

Type(s)

string

refurl

refurl : string

Save referrer URL: (Y/N)

Type(s)

string

datecreated

datecreated : string

Date survey was created (YYYY-MM-DD hh:mm:ss)

Type(s)

string

publicstatistics

publicstatistics : string

Public statistics: (Y/N)

Type(s)

string

publicgraphs

publicgraphs : string

Show graphs in public statistics: (Y/N)

Type(s)

string

listpublic

listpublic : string

List survey publicly: (Y/N)

Type(s)

string

htmlemail

htmlemail : string

Use HTML format for token emails: (Y/N)

Type(s)

string

sendconfirmation

sendconfirmation : string

Send confirmation emails:(Y/N)

Type(s)

string

tokenanswerspersistence

tokenanswerspersistence : string

Enable token-based response persistence: (Y/N)

Type(s)

string

assessments

assessments : string

Enable assessment mode: (Y/N)

Type(s)

string

usecaptcha

usecaptcha : string

Type(s)

string

usetokens

usetokens : string

Type(s)

string

bounce_email

bounce_email : string

Bounce email address

Type(s)

string

attributedescriptions

attributedescriptions : string

Type(s)

string

emailresponseto

emailresponseto : string

e-mail address to send detailed admin notification email to

Type(s)

string

emailnotificationto

emailnotificationto : string

Email address to send basic admin notification email to

Type(s)

string

showxquestions

showxquestions : string

Show "There are X questions in this survey": (Y/N)

Type(s)

string

showgroupinfo

showgroupinfo : string

Show group name and/or group description: (Y/N)

Type(s)

string

shownoanswer

shownoanswer : string

Show "No answer": (Y/N)

Type(s)

string

showqnumcode

showqnumcode : string

Show question number and/or code: (Y/N)

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

Show welcome screen: (Y/N)

Type(s)

string

showprogress

showprogress : string

how progress bar: (Y/N)

Type(s)

string

questionindex

questionindex : integer

Show question index / allow jumping (0: diabled; 1: Incremental; 2: Full)

Type(s)

integer

navigationdelay

navigationdelay : integer

Navigation delay (seconds)

Type(s)

integer

nokeyboard

nokeyboard : string

Show on-screen keyboard: (Y/N)

Type(s)

string

alloweditaftercompletion

alloweditaftercompletion : string

Allow multiple responses or update responses with one token: (Y/N)

Type(s)

string

googleanalyticsstyle

googleanalyticsstyle : string

Google Analytics style: (0: off; 1:Default; 2:Survey-SID/Group)

Type(s)

string

googleanalyticsapikey

googleanalyticsapikey : string

Google Analytics Tracking ID

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

quotableQuestions

quotableQuestions : \Question[]

Type(s)

\Question[]

fullAnswers

fullAnswers : array

Type(s)

array

partialAnswers

partialAnswers : array

Type(s)

array

countFullAnswers

countFullAnswers : integer

Full-answers count

Type(s)

integer

countPartialAnswers

countPartialAnswers : integer

Full-answers count

Type(s)

integer

countTotalAnswers

countTotalAnswers : integer

Total-answers count

Type(s)

integer

groupsCount

groupsCount : integer

Number of groups in a survey (in base language)

Type(s)

integer

surveyinfo

surveyinfo : array

Type(s)

array

currentLanguageSettings

currentLanguageSettings : \SurveyLanguageSetting

Survey languagesettings in currently active language

Type(s)

\SurveyLanguageSetting

allLanguages

allLanguages : string[]

Type(s)

string[]

additionalLanguages

additionalLanguages : string[]

Additional survey languages

Type(s)

string[]

tokenAttributes

tokenAttributes : array

Additional token attribute names

Type(s)

array

creationDate

creationDate : string

Creation date formatted according to user format

Type(s)

string

startDateFormatted

startDateFormatted : string

Start date formatted according to user format

Type(s)

string

expiryDateFormatted

expiryDateFormatted : string

Expiry date formatted according to user format

Type(s)

string

tokensTableName

tokensTableName : string

Name of survey tokens table

Type(s)

string

responsesTableName

responsesTableName : string

Name of survey resonses table

Type(s)

string

timingsTableName

timingsTableName : string

Name of survey timings table

Type(s)

string

hasTokensTable

hasTokensTable : boolean

Whether survey has a tokens table or not

Type(s)

boolean

hasResponsesTable

hasResponsesTable : boolean

Wheteher the survey reponses (data) table exists in DB

Type(s)

boolean

hasTimingsTable

hasTimingsTable : boolean

Wheteher the survey timings table exists in DB

Type(s)

boolean

googleanalyticsapikeysetting

googleanalyticsapikeysetting : string

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

Type(s)

string

countTotalQuestions

countTotalQuestions : integer

Count of questions (in that language, without subquestions)

Type(s)

integer

countInputQuestions

countInputQuestions : integer

Count of questions that need input (skipping text-display etc.)

Type(s)

integer

countNoInputQuestions

countNoInputQuestions : integer

Count of questions that DO NOT need input (skipping text-display etc.) All Y/N columns in the model can be accessed as boolean values:

Type(s)

integer

isActive

isActive : bool

Whether Survey is active

Type(s)

bool

isAnonymized

isAnonymized : bool

Whether survey is anonymized or not

Type(s)

bool

isSaveTimings

isSaveTimings : bool

Whether survey timings are saved

Type(s)

bool

isDateStamp

isDateStamp : bool

Whether respondents' datestamps will be saved

Type(s)

bool

isUseCookie

isUseCookie : bool

Are cookies used to prevent repeated participation

Type(s)

bool

isAllowRegister

isAllowRegister : bool

Allow public registration

Type(s)

bool

isAllowSave

isAllowSave : bool

Is participant allowed save and resume later

Type(s)

bool

isAutoRedirect

isAutoRedirect : bool

Automatically load URL when survey complete

Type(s)

bool

isAllowPrev

isAllowPrev : bool

Allow backwards navigation

Type(s)

bool

isPrintAnswers

isPrintAnswers : bool

Participants may print answers

Type(s)

bool

isIpAddr

isIpAddr : bool

Whether Participants IP address will be saved

Type(s)

bool

isRefUrl

isRefUrl : bool

Save referrer URL

Type(s)

bool

isPublicStatistics

isPublicStatistics : bool

Public statistics

Type(s)

bool

isPublicGraphs

isPublicGraphs : bool

Show graphs in public statistics

Type(s)

bool

isListPublic

isListPublic : bool

List survey publicly

Type(s)

bool

isHtmlEmail

isHtmlEmail : bool

Use HTML format for token emails

Type(s)

bool

isSendConfirmation

isSendConfirmation : bool

Send confirmation emails

Type(s)

bool

isTokenAnswersPersistence

isTokenAnswersPersistence : bool

Enable token-based response persistence

Type(s)

bool

isAssessments

isAssessments : bool

Enable assessment mode

Type(s)

bool

isShowXQuestions

isShowXQuestions : bool

Show "There are X questions in this survey"

Type(s)

bool

isShowGroupInfo

isShowGroupInfo : bool

Show group name and/or group description

Type(s)

bool

isShowNoAnswer

isShowNoAnswer : bool

Show "No answer"

Type(s)

bool

isShowQnumCode

isShowQnumCode : bool

Show question number and/or code

Type(s)

bool

isShowWelcome

isShowWelcome : bool

Show welcome screen

Type(s)

bool

isShowProgress

isShowProgress : bool

how progress bar

Type(s)

bool

isNoKeyboard

isNoKeyboard : bool

Show on-screen keyboard

Type(s)

bool

isAllowEditAfterCompletion

isAllowEditAfterCompletion : bool

Allow multiple responses or update responses with one token

Type(s)

bool

defaultlanguage

defaultlanguage : \SurveyLanguageSetting

Type(s)

\SurveyLanguageSetting