OpHandlerQuestionCondition
in package
implements
OpHandlerInterface
Uses
OpHandlerSurveyTrait, OpHandlerValidationTrait, OpHandlerExceptionTrait
Tags
Table of Contents
Interfaces
Properties
- $entity : string
- $permissionMap : array<string|int, mixed>
- $surveyCondition : SurveyCondition
Methods
- __construct() : mixed
- Constructor
- addErrorToValidationData() : array<string|int, mixed>
- Adds the error message to the validationData array
- canHandle() : bool
- Detemines whether the action can be handled
- extractTempId() : int|mixed
- returns and removes tempId from dataset
- getSurveyIdFromContext() : int
- Extracts and returns surveyId from context
- getValidationReturn() : array<string|int, mixed>|array<string|int, array<string|int, ValidationErrorItem>>
- handle() : array<string|int, mixed>
- Updates multiple attributes for a single question. Format is exactly the same as in Question create, so they share the prepare function.
- setFlashMessage() : void
- Since the service class depends on an output functionality due to legacy reasons, we have here a message function that will be used as a callback
- validateCollection() : array<string|int, mixed>
- checks incoming props if it's a collection otherwise adds error to validationData.
- validateCollectionIndex() : array<string|int, mixed>
- validates for collection first and then checks the indexes to be numeric or alphabetic dependent on the alphabetic flag
- validateEntityId() : array<string|int, mixed>
- checks for entity id being there, otherwise adds error to validationData
- validateOperation() : array<string|int, mixed>
- Checks if patch is valid for this operation.
- validateSurveyIdFromContext() : array<string|int, mixed>
- checks for survey ID being there, otherwise adds error to validationData
- validateConditionScript() : bool
- Validates the conditionScript action
- validateCopyConditions() : bool
- Validates the copyConditions action
- validateDeleteAllConditions() : bool
- Validates the deleteAllConditions action
- validateDeleteAllConditionsOfSurvey() : bool
- Validates the deleteAllConditionsOfSurvey action
- validateDeleteCondition() : bool
- Validates the deleteCondition action
- validateDeleteScenario() : bool
- Validates the deleteScenario action
- validateInsertCondition() : bool
- Validates the insertCondition action
- validateRenumberScenarios() : bool
- Validates the renumberScenarios action
- validateUpdateCondition() : bool
- Validates the updateCondition action
- validateUpdateScenario() : bool
- Validates the updateScenario action
- throwNoValuesException() : never
Properties
$entity
protected
string
$entity
$permissionMap
protected
array<string|int, mixed>
$permissionMap
= []
$surveyCondition
protected
SurveyCondition
$surveyCondition
Methods
__construct()
Constructor
public
__construct(SurveyCondition $surveyCondition) : mixed
Parameters
- $surveyCondition : SurveyCondition
-
the survey condition service object
addErrorToValidationData()
Adds the error message to the validationData array
public
addErrorToValidationData(string $error, array<string|int, mixed> $validationData) : array<string|int, mixed>
Parameters
- $error : string
- $validationData : array<string|int, mixed>
Return values
array<string|int, mixed>canHandle()
Detemines whether the action can be handled
public
canHandle(OpInterface $op) : bool
Parameters
- $op : OpInterface
-
the operation
Return values
bool —whether the action can be handled
extractTempId()
returns and removes tempId from dataset
public
extractTempId(array<string|int, mixed> &$dataSet) : int|mixed
Parameters
- $dataSet : array<string|int, mixed>
Return values
int|mixedgetSurveyIdFromContext()
Extracts and returns surveyId from context
public
getSurveyIdFromContext(OpInterface $op) : int
Parameters
- $op : OpInterface
Return values
intgetValidationReturn()
public
getValidationReturn(string $error, array<string|int, mixed> $validationData, OpInterface $op) : array<string|int, mixed>|array<string|int, array<string|int, ValidationErrorItem>>
Parameters
- $error : string
- $validationData : array<string|int, mixed>
- $op : OpInterface
Return values
array<string|int, mixed>|array<string|int, array<string|int, ValidationErrorItem>>handle()
Updates multiple attributes for a single question. Format is exactly the same as in Question create, so they share the prepare function.
public
handle(OpInterface $op) : array<string|int, mixed>
renumberScenarios: { "patch": [{ "entity": "questionCondition", "op": "update", "id": 809, "props": { "qid": 15977, "action": "renumberScenarios" } } ] } copyConditions: { "patch": [{ "entity": "questionCondition", "op": "create", "id": 809, "props": { "qid": 15977, "fromqid": 15976, "action": "copyConditions" } } ] } deleteAllConditionsOfSurvey: { "patch": [{ "entity": "questionCondition", "op": "delete", "id": 809, "props": { "sid": 1234, "action": "deleteAllConditionsOfSurvey" } } ] } deleteAllConditions: { "patch": [{ "entity": "questionCondition", "op": "delete", "id": 809, "props": { "qid": 15977, "action": "deleteAllConditions" } } ] } conditionScript: { "patch": [{ "entity": "questionCondition", "op": "update", "id": 809, "props": { "qid": 15977, "action": "conditionScript", "script":"((TOKEN:LASTNAME == "pomegrenade"))" } } ] } updateScenario: { "patch": [{ "entity": "questionCondition", "op": "update", "id": 809, "props": { "qid": 15977, "scenarios": [ { "scid": 3, "action": "updateScenario", "scenarioNumber": 123 } ] } } ] } deleteScenario: { "patch": [{ "entity": "questionCondition", "op": "delete", "id": 809, "props": { "qid": 15977, "scenarios": [ { "scid": 3, "action": "deleteScenario" } ] } } ] } insertCondition (field-constant): { "patch": [{ "entity": "questionCondition", "op": "create", "id": 809, "props": { "qid": 15977, "scenarios": [ { "scid": 3, "conditions": [ { "action":"insertCondition", "method":"==", "csrctoken":"{TOKEN:LASTNAME}", "ConditionConst":"sdfsdf", "ConditionRegexp":"", "cqid":0, "canswersToSelect":"", "tempcids":["temp_0004"], "editSourceTab":"#SRCTOKENATTRS", "editTargetTab":"#CONST" } ] } ] } } ] } insertCondition (field-field): { "patch": [{ "entity": "questionCondition", "op": "create", "id": 809, "props": { "qid": 15977, "scenarios": [ { "scid": 3, "conditions": [ { "action":"insertCondition", "method":"==", "csrctoken":"{TOKEN:FIRSTNAME}", "ConditionConst":"", "tokenAttr":"{TOKEN:TOKEN}", "ConditionRegexp":"", "cqid":0, "canswersToSelect":"", "tempcids":["temp_0004"], "editSourceTab":"#SRCTOKENATTRS", "editTargetTab":"#TOKENATTRS" } ] } ] } } ] } insertCondition (prevq-predef): { "patch": [{ "entity": "questionCondition", "op": "create", "id": 809, "props": { "qid": 15977, "scenarios": [ { "scid": 3, "conditions": [ { "action":"insertCondition", "method":"==", "cquestions":"453614X608X15979", "csrctoken":"{TOKEN:EMAIL}", "canswers":["A01","A02","A03"], "ConditionConst":"", "ConditionRegexp":"", "cqid":15979, "canswersToSelect":"", "tempcids":["temp_0004","temp_0008","temp_00012"], "editSourceTab":"#SRCPREVQUEST", "editTargetTab":"#CANSWERSTAB" } ] } ] } } ] } insertCondition (prevq-const): { "patch": [{ "entity": "questionCondition", "op": "create", "id": 809, "props": { "qid": 15977, "scenarios": [ { "scid": 3, "conditions": [ { "action":"insertCondition", "method":"==", "cquestions":"453614X608X15978", "ConditionConst":"my only virtue is modesty", "ConditionRegexp":"", "cqid":15978, "canswersToSelect":"", "tempcids":["temp_0004"], "editSourceTab":"#SRCPREVQUEST", "editTargetTab":"#CONST" } ] } ] } } ] } insertCondition (prevq-prevq) { "patch": [{ "op": "create", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "action": "insertCondition", "method": "==", "cquestions": "453614X608X15979", "prevQuestionSGQA": "@453614X608X15982@", "ConditionRegexp": "", "cqid": 15979, "canswersToSelect": "", "tempcids":["temp_0004"], "editSourceTab": "#SRCPREVQUEST", "editTargetTab": "#PREVQUESTIONS" } ] } ] }} ] } insertCondition (prevq-field) { "patch": [{ "op": "create", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "action": "insertCondition", "method": "==", "cquestions": "453614X608X15979", "ConditionConst": "", "tokenAttr":"{TOKEN:FIRSTNAME}", "prevQuestionSGQA": "@453614X608X15979@", "ConditionRegexp": "", "cqid": 15979, "canswersToSelect": "", "tempcids":["temp_0004"], "editSourceTab": "#SRCPREVQUEST", "editTargetTab": "#TOKENATTRS" } ] } ] }} ] } insertCondition (field-regex) { "patch": [{ "op": "create", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "action": "insertCondition", "method": "RX", "cquestions": "453614X608X15979", "csrctoken": "{TOKEN:FIRSTNAME}", "ConditionConst": "", "ConditionRegexp": "La*", "cqid": 0, "canswersToSelect": "", "tempcids":["temp_0004"], "editSourceTab": "#SRCTOKENATTRS", "editTargetTab": "#REGEXP" } ] } ] }} ] } insertCondition (prevq-regex) { "patch": [{ "op": "create", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "action": "insertCondition", "method": "RX", "cquestions": "453614X608X15979", "ConditionConst": "", "ConditionRegexp": "La*", "cqid": 15978, "canswersToSelect": "", "tempcids":["temp_0004"], "editSourceTab": "#SRCPREVQUEST", "editTargetTab": "#REGEXP" } ] } ] }} ] } updateCondition (prevq-answer) { "patch": [{ "op": "update", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "cid": 2601, "action": "updateCondition", "method": "<=", "cquestions": "453614X608X15979", "canswers": ["A4988"], "ConditionConst": "", "ConditionRegexp": "", "cqid": 15978, "canswersToSelect": "A4988", "editSourceTab": "#SRCPREVQUEST", "editTargetTab": "#CANSWERSTAB" } ] } ] }} ] } updateCondition (prevq-const) { "patch": [{ "op": "update", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "cid": 2601, "action": "updateCondition", "method": "<=", "cquestions": "453614X608X15979", "ConditionConst": "test", "ConditionRegexp": "", "cqid": 15978, "canswersToSelect": "", "editSourceTab": "#SRCPREVQUEST", "editTargetTab": "#CONST" } ] } ] }} ] } updateCondition (prevq-prevq) { "patch": [{ "op": "update", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "cid": 2601, "action": "updateCondition", "method": "<=", "cquestions": "453614X608X15979", "ConditionConst": "test", "prevQuestionSGQA":"@453614X608X15978@", "ConditionRegexp": "", "cqid": 15978, "canswersToSelect": "", "editSourceTab": "#SRCPREVQUEST", "editTargetTab": "#PREVQUESTIONS" } ] } ] }} ] } updateCondition (prevq-field) { "patch": [{ "op": "update", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "cid": 2601, "action": "updateCondition", "method": "<=", "cquestions": "453614X608X15979", "ConditionConst": "", "prevQuestionSGQA":"@453614X608X15978@", "tokenAttr":"{TOKEN:LASTNAME}", "ConditionRegexp": "", "cqid": 15978, "canswersToSelect": "", "editSourceTab": "#SRCPREVQUEST", "editTargetTab": "#TOKENATTRS" } ] } ] }} ] } updateCondition (prevq-regex) { "patch": [{ "op": "update", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "cid": 2601, "action": "updateCondition", "method": "RX", "cquestions": "453614X608X15979", "ConditionConst": "", "prevQuestionSGQA":"@453614X608X15978@", "ConditionRegexp": "def", "cqid": 15978, "canswersToSelect": "", "editSourceTab": "#SRCPREVQUEST", "editTargetTab": "#REGEXP" } ] } ] }} ] } updateCondition (field-constant) { "patch": [{ "op": "update", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "cid": 2601, "action": "updateCondition", "method": "==", "ConditionConst": "ABCDE", "ConditionRegexp": "", "csrctoken": "{TOKEN:LASTNAME}", "cqid": 15978, "canswersToSelect": "", "editSourceTab": "#SRCTOKENATTRS", "editTargetTab": "#CONST" } ] } ] }} ] } updateCondition (field-prevq) { "patch": [{ "op": "update", "entity": "questionCondition", "error": false, "props": { "qid": 32, "scenarios": [ { "scid": 9, "conditions": [ { "cid": 65, "action": "updateCondition", "method": "==", "csrctoken": "{TOKEN:FIRSTNAME}", "ConditionConst": "", "prevQuestionSGQA": "@543869X1X1@", "cquestions":"543869X1X1", "ConditionRegexp": "", "canswersToSelect": "", "editSourceTab": "#SRCTOKENATTRS", "editTargetTab": "#PREVQUESTIONS" } ] } ] }} ] } updateCondition (field-regex) { "patch": [{ "op": "update", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "cid": 2601, "action": "updateCondition", "method": "RX", "csrctoken": "{TOKEN:LASTNAME}", "ConditionConst": "", "ConditionRegexp": "abc", "cqid": 0, "canswersToSelect": "", "editSourceTab": "#SRCTOKENATTRS", "editTargetTab": "#REGEXP" } ] } ] }} ] } deleteCondition { "patch": [{ "op": "delete", "entity": "questionCondition", "error": false, "props": { "qid": 15977, "scenarios": [ { "scid": 123, "conditions": [ { "cid": 2601, "action": "deleteCondition" } ] } ] }} ] }
Parameters
- $op : OpInterface
Tags
Return values
array<string|int, mixed>setFlashMessage()
Since the service class depends on an output functionality due to legacy reasons, we have here a message function that will be used as a callback
public
setFlashMessage(string $message[, string $type = 'success' ]) : void
Parameters
- $message : string
-
the actual message
- $type : string = 'success'
-
the type of the message, such as success, warning or error
Tags
validateCollection()
checks incoming props if it's a collection otherwise adds error to validationData.
public
validateCollection(OpInterface $op, array<string|int, mixed> $validationData) : array<string|int, mixed>
Basically this only check for the incoming props being a multidimensional array.
Parameters
- $op : OpInterface
- $validationData : array<string|int, mixed>
Return values
array<string|int, mixed>validateCollectionIndex()
validates for collection first and then checks the indexes to be numeric or alphabetic dependent on the alphabetic flag
public
validateCollectionIndex(OpInterface $op, array<string|int, mixed> $validationData[, bool $alphabetic = true ]) : array<string|int, mixed>
Parameters
- $op : OpInterface
- $validationData : array<string|int, mixed>
- $alphabetic : bool = true
Return values
array<string|int, mixed>validateEntityId()
checks for entity id being there, otherwise adds error to validationData
public
validateEntityId(OpInterface $op, array<string|int, mixed> $validationData) : array<string|int, mixed>
Parameters
- $op : OpInterface
- $validationData : array<string|int, mixed>
Return values
array<string|int, mixed>validateOperation()
Checks if patch is valid for this operation.
public
validateOperation(OpInterface $op) : array<string|int, mixed>
We support three kinds of patches:
- general, where we do someting to all conditions related to a question or a survey
- scenario-based, where we do actions for scenarios inside the scenarios array
- condition-based, where we do actions for conditions in the condition arrays of the scenarios in the scenarios array
Parameters
- $op : OpInterface
-
the operation
Tags
Return values
array<string|int, mixed> —the validation responses
validateSurveyIdFromContext()
checks for survey ID being there, otherwise adds error to validationData
public
validateSurveyIdFromContext(OpInterface $op, array<string|int, mixed> $validationData) : array<string|int, mixed>
Parameters
- $op : OpInterface
- $validationData : array<string|int, mixed>
Return values
array<string|int, mixed>validateConditionScript()
Validates the conditionScript action
protected
validateConditionScript(array<string|int, mixed> $props) : bool
Parameters
- $props : array<string|int, mixed>
-
the properties
Return values
bool —whether the action is valid
validateCopyConditions()
Validates the copyConditions action
protected
validateCopyConditions(array<string|int, mixed> $props) : bool
Parameters
- $props : array<string|int, mixed>
-
the properties received
Return values
bool —whether the action is valid
validateDeleteAllConditions()
Validates the deleteAllConditions action
protected
validateDeleteAllConditions(array<string|int, mixed> $props) : bool
Parameters
- $props : array<string|int, mixed>
-
the properties received
Return values
bool —whether the action is valid
validateDeleteAllConditionsOfSurvey()
Validates the deleteAllConditionsOfSurvey action
protected
validateDeleteAllConditionsOfSurvey(array<string|int, mixed> $condition) : bool
Parameters
- $condition : array<string|int, mixed>
-
the condition
Return values
bool —whether the action is valid
validateDeleteCondition()
Validates the deleteCondition action
protected
validateDeleteCondition(array<string|int, mixed> $condition) : bool
Parameters
- $condition : array<string|int, mixed>
-
the condition
Return values
bool —whether the action is valid
validateDeleteScenario()
Validates the deleteScenario action
protected
validateDeleteScenario(array<string|int, mixed> $scenario) : bool
Parameters
- $scenario : array<string|int, mixed>
-
the scenario
Return values
bool —whether the action is valid
validateInsertCondition()
Validates the insertCondition action
protected
validateInsertCondition(array<string|int, mixed> $condition) : bool
Parameters
- $condition : array<string|int, mixed>
-
the condition
Return values
bool —whether the action is valid
validateRenumberScenarios()
Validates the renumberScenarios action
protected
validateRenumberScenarios(array<string|int, mixed> $props) : bool
Parameters
- $props : array<string|int, mixed>
-
the properties received
Return values
bool —whether the action is valid
validateUpdateCondition()
Validates the updateCondition action
protected
validateUpdateCondition(array<string|int, mixed> $condition) : bool
Parameters
- $condition : array<string|int, mixed>
-
the condition
Return values
bool —whether the action is valid
validateUpdateScenario()
Validates the updateScenario action
protected
validateUpdateScenario(array<string|int, mixed> $scenario) : bool
Parameters
- $scenario : array<string|int, mixed>
-
the scenario
Return values
bool —whether the action is valid
throwNoValuesException()
private
throwNoValuesException(OpInterface $op[, string $name = '' ]) : never
Parameters
- $op : OpInterface
- $name : string = ''