LimeSurvey API - Master branch

OpHandlerAnswer
in package
implements OpHandlerInterface Uses OpHandlerSurveyTrait, OpHandlerQuestionTrait, OpHandlerExceptionTrait, OpHandlerValidationTrait

Table of Contents

Interfaces

OpHandlerInterface

Properties

$answersService  : AnswersService
$entity  : string
$questionService  : QuestionService
$transformer  : TransformerInputAnswer

Methods

__construct()  : mixed
addErrorToValidationData()  : array<string|int, mixed>
Adds the error message to the validationData array
canHandle()  : bool
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>
Example patch: "id" is the qid, so we are only allowing answers for a single question in the patch.
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.
throwNoValuesException()  : void

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

Example patch: "id" is the qid, so we are only allowing answers for a single question in the patch.

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

Attention: Currently all answers not provided in the patch will be deleted by the service. Doesn't matter if create or update was chosen

Example for "update": { "patch": [{ "entity": "answer", "op": "update", "id": "809", "props": { "0": { "aid": 465, "code": "AO01", "sortOrder": 2, "assessmentValue": 0, "scaleId": 1, "l10ns": { "de": { "answer": "ANTW1 scale 1", "language": "de" }, "en": { "answer": "ANS1 scale 1", "language": "en" } } }, "1": { "aid": 467, "code": "AO02", "sortOrder": 3, "assessmentValue": 0, "scaleId": 1, "l10ns": { "de": { "answer": "ANTW2 scale 1", "language": "de" }, "en": { "answer": "ANS2 scale 1", "language": "en" } } } } } ] }

Example for "create": { "patch": [{ "entity": "answer", "op": "create", "id": "809", "props": { "0": { "tempId": "222", "code": "AO11", "sortOrder": 4, "assessmentValue": 0, "scaleId": 1, "l10ns": { "de": { "answer": "ANTW11 scale 1", "language": "de" }, "en": { "answer": "ANS11 scale 1", "language": "en" } } }, "1": { "tempId": "223", "code": "AO12", "sortOrder": 5, "assessmentValue": 0, "scaleId": 1, "l10ns": { "de": { "answer": "ANTW12 scale 1", "language": "de" }, "en": { "answer": "ANS12 scale 1", "language": "en" } } } } } ] }

Parameters
$op : OpInterface
Tags
throws
OpHandlerException
throws
NotFoundException
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