Class QuestionAttribute
todo | Should probably change question_attributes table to question_attribute_values |
---|---|
see | and participant_attribute_values |
package | Default |
addAdditionalAttributesFromExtendedTheme(array $aAttributeNames,\Question $oQuestion): array|mixed
array
array of attributes (see getQuestionAttributesSettings())
\Question
array|mixed
returns $aAttributeNames with appended additional attributes
behaviors(): array
Below is a list of all behaviors we register:
see | \PluginEventBehavior\CTimestampBehavior |
---|---|
array
decrypt( $value = '')
decryptEncryptAttributes( $action = 'decrypt')
decryptSingle(string $value = ''): string
string
String value which needs to be decrypted
string
the decrypted string
decryptSingleOld(string $value = ''): string
string
String value which needs to be decrypted
string
the decrypted string
defaultScope(): array
In that case disable the defaultScope by using MyModel::model()->resetScope()->findAll();
array
Scope that indexes the records by their attribute bane
deleteAllByAttributes(array $attributes,string $condition = '',array $params = array()): integer
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. |
---|
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.
string
query condition or criteria.
array
parameters to be bound to an SQL statement.
integer
number of rows affected by the execution.
dispatchPluginModelEvent(string $sEventName,\CDbCriteria $criteria = null,array $eventParams = []): \PluginEvent
string
\CDbCriteria
array
\PluginEvent
encrypt()
encryptAttributeValues(array $attributes = null, $bEncryptedOnly = false, $bReplaceValues = true): array
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.
array
attributes array with encrypted atrribute values is returned
encryptSave( $runValidation = false)
encryptSingle(string $value = '')
string
String value which needs to be encrypted
filterXss(string $attribute,\array<mixed> $params): void
string
the name of the attribute to be validated.
\array
additional parameters passed with rule when being executed.
findAllAsArray(mixed $condition = '',array $params = array()): array
See \find() for detailed explanation about $condition and $params.
mixed
query condition or criteria.
array
parameters to be bound to an SQL statement.
array
list of active records satisfying the specified condition. An empty array is returned if none is found.
findAllByAttributes(array $attributes,mixed $condition = '',array $params = array()): array<mixed,static>
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.
mixed
query condition or criteria.
array
parameters to be bound to an SQL statement.
array<mixed,static>
the records found. An empty array is returned if none is found.
findByAttributes(array $attributes,mixed $condition = '',array $params = array()): static|null
array
list of attribute values (indexed by attribute names) that the active record should match. An attribute value can be an array which will be used to generate an IN condition.
mixed
query condition or criteria.
array
parameters to be bound to an SQL statement.
static|null
the record found. Null if none is found.
getAdvancedAttributesFromXml(string $sXmlFilePath): \?array
string
Path to XML
\?array
The advanced attribute settings for this question type
getAllEncryptedAttributes(integer $iSurveyId,string $sClassName): array
integer
string
array
TODO: Should be split into seperate functions in the appropiate model or helper class TODO: Make an interface for records that support encryption.
getAttributesAsArrayFromDB(integer $iQuestionID): array
integer
the question id
array
the returning array structure will be like $aAttributeValues[$oAttributeValue->attribute][$oAttributeValue->language] $aAttributeValues[$oAttributeValue->attribute]['']
getDefaultSettings(): \array<string,
todo | Move to static property? |
---|---|
\arraymixed>
getGeneralAttibutesFromXml(string $sXmlFilePath): \?array
todo | What's the opposite of a "general" attribute? How many types of attributes are there? |
---|
string
Path to XML
\?array
The general attribute settings for this question type
getMaxId(string $field = null,boolean $forceRefresh = false): false|integer
This is a convenience method, that uses the primary key of the model to retrieve the highest value.
Throws |
|
---|
string
The field that contains the Id, when null primary key is used if it is a single field
boolean
Don't use value from static cache but always requery the database
false|integer
getMinId(string $field = null,boolean $forceRefresh = false): false|integer
This is a convenience method, that uses the primary key of the model to retrieve the highest value.
Throws |
|
---|
string
The field that contains the Id, when null primary key is used if it is a single field
boolean
Don't use value from static cache but always requery the database
false|integer
getOwnQuestionAttributesViaPlugin(): array
Using $event->append('questionAttributes', $questionAttributes);
$questionAttributes=[ attributeName=>[ 'types' : Apply to this question type 'category' : Where to put it 'sortorder' : Qort order in this category 'inputtype' : type of input 'expression' : 2 to force Expression Manager when see the survey logic file (add { } and validate, 1 : allow it : validate in survey logic file 'options' : optional options if input type need it 'default' : the default value 'caption' : the label 'help' : an help ]
array
the event attributes as array or an empty array
getQuestionAttributes(integer $iQuestionID,string $sLanguage = null): array|false
--get attributes from XML-Files --get additional attributes from extended theme --prepare an easier/smaller array to return
access | public |
---|---|
Throws |
|
integer
string
restrict to this language (if null $oQuestion->survey->allLanguages will be used)
array|false
getQuestionAttributesSettings(string $sType,boolean $advancedOnly = false): array
Throws |
|
---|
string
: type of question (this is the attribute 'question_type' in table question_theme)
boolean
If true, only fetch advanced attributes
array
: the attribute settings for this question type returns values from getGeneralAttributesFromXml and getAdvancedAttributesFromXml if this fails getAttributesDefinition and getDefaultSettings are returned
getQuestionsForStatistics(string $fields,mixed $condition,string|false $orderby = false): array
string
mixed
string|false
array
getQuestionTemplateValue( $questionID): string
Fetches the question_template from a question model.
Be carefull this attribute is not present in all questions. Even more, standard question types where question theme are not used (or custom question theme are not used), the attribute is missing. In those cases, the deault "core" is used.
deprecated | use $question->question_theme_name instead (Question model) |
---|---|
string
question_template or 'core' if it not exists
model( $className = __CLASS__): static
static
primaryKey()
inheritdoc | |
---|---|
query(\CDbCriteria $criteria,boolean $all = false,boolean $asAR = true): mixed
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 |
---|
\CDbCriteria
the query criteria
boolean
whether to return all data
boolean
mixed
the AR objects populated with the query result
relations()
inheritdoc | |
---|---|
todo | Remove? |
rules()
inheritdoc | |
---|---|
setEncryptedAttributeLabel(integer $surveyId,string $className,string $attributeName): string
Throws |
|
---|
integer
string
string
string
setMultiple( $iSid, $aQids, $aAttributesToUpdate, $aValidQuestionTypes)
NOTE: We can't use self::setQuestionAttribute() because it doesn't check for question types first. TODO: the question type check should be done via rules, or via a call to a question method
var | the sid to update (only to check permission) an array containing the list of primary keys for questions array containing the list of attributes to update the question types we can update for those attributes |
---|---|
todo | Missign noun in function name - set multiple what? |
setQuestionAttribute(integer $iQuestionID,string $sAttributeName,string $sValue): \CDbDataReader|boolean
todo | A function should not both set and get something; split into two functions |
---|
integer
string
string
\CDbDataReader|boolean
setQuestionAttributeWithLanguage(integer $iQuestionID,string $sAttributeName,string $sValue,string $sLanguage): \CDbDataReader
todo | A function should not both set and get something; split into two functions |
---|
integer
string
string
string
\CDbDataReader
tableName()
inheritdoc | |
---|---|
updateAll(array $attributes,mixed $condition = '',array $params = array()): integer
XSS filtering is enforced for attributes listed in model's $xssFilterAttributes property. See \find() for detailed explanation about $condition and $params. Note, the attributes are not checked for safety and no validation is done.
array
list of attributes (name=>$value) to be updated
mixed
query condition or criteria.
array
parameters to be bound to an SQL statement.
integer
the number of rows being updated
questionAttributesSettings :
xssFilterAttributes :array<mixed,string>
var | Array of attributes that should be XSS filtered on mass updates |
---|
array<mixed,string>
bEncryption :
qaid :integer
ID Primary key
integer
qid :integer
Question ID
integer
attribute :string
attribute name (max 50 chars)
string
value :string
Attribute value
string
language :string
Language code eg:'en'
string
question :\Question
\Question
survey :\Survey
\Survey