LimeSurvey API - Master branch

OpHandlerSubQuestion
in package
implements OpHandlerInterface Uses OpHandlerSurveyTrait, OpHandlerQuestionTrait, OpHandlerValidationTrait

Class OpHandlerSubQuestion can handle create and update of subquestions which belong to a single question.

Table of Contents

Interfaces

OpHandlerInterface

Properties

$questionAggregateService  : QuestionAggregateService
$questionService  : QuestionService
$subQuestionsService  : SubQuestionsService
$transformer  : TransformerInputSubQuestion

Methods

__construct()  : mixed
addErrorToValidationData()  : array<string|int, mixed>
Adds the error message to the validationData array
canHandle()  : bool
Checks if the operation is applicable for the given entity.
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>
Handle subquestion create or update operation.
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.
getSubQuestionNewIdMapping()  : array<string|int, mixed>
Maps the tempIds of new subquestions or answers to the real ids.

Properties

Methods

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>

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

handle()

Handle subquestion create or update operation.

public handle(OpInterface $op) : array<string|int, mixed>

Attention: subquestions not present in the patch will be deleted. Expects a patch structure like this for update: { "patch": [{ "entity": "subquestion", "op": "update", "id": 722, //parent qid "props": { "0": { "qid": 728, "title": "SQ001new", "l10ns": { "de": { "question": "subger1updated", "language": "de" }, "en": { "question": "sub1updated", "language": "en" } } }, "1": { "qid": 729, "title": "SQ002new", "l10ns": { "de": { "question": "subger2updated", "language": "de" }, "en": { "question": "sub2updated", "language": "en" } } } } } ] }

Expects a patch structure like this for create: { "patch": [{ "entity": "subquestion", "op": "create", "id": 722, "props": { "0": { "tempId": "456789", "title": "SQ011", "l10ns": { "de": { "question": "germanized1", "language": "de" }, "en": { "question": "englishized", "language": "en" } } }, "1": { "title": "SQ012", "tempId": "345678", "l10ns": { "de": { "question": "germanized2", "language": "de" }, "en": { "question": "englishized2", "language": "en" } } } } } ] }

Parameters
$op : OpInterface
Tags
throws
NotFoundException
throws
OpHandlerException
throws
PermissionDeniedException
throws
PersistErrorException
Return values
array<string|int, mixed>

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>
Parameters
$op : OpInterface
Return values
array<string|int, mixed>

getSubQuestionNewIdMapping()

Maps the tempIds of new subquestions or answers to the real ids.

private getSubQuestionNewIdMapping(Question $question, array<string|int, mixed> $data[, bool $answers = false ]) : array<string|int, mixed>
Parameters
$question : Question
$data : array<string|int, mixed>
$answers : bool = false
Return values
array<string|int, mixed>

        
On this page

Search results