SurveyResponses
in package
implements
CommandInterface
Uses
AuthPermissionTrait, ResponseMappingTrait, SurveyRequestTrait
Returns the responses of a survey, one entry per response with its answers.
Filtering and sorting go through the generic FilterPatcher, whose
filter keys are validated against the survey field map so any filter method
(equal, contain, multi-select, …) can target nested question/subquestion
columns. A fields param additionally restricts the SELECT to a caller-chosen
subset of response columns; when it is omitted every column is returned.
Table of Contents
Interfaces
Constants
- FIXED_OUTPUT_COLUMNS = ['id', 'submitdate', 'startdate', 'datestamp', 'startlanguage', 'lastpage', 'seed', 'token', 'ipaddr', 'refurl']
- Response columns always loaded regardless of field selection, because the transformed output (id, completed flag, dates, language, token, …) depends on them. Intersected with the survey's real columns before use.
Properties
- $answerCache : SurveyAnswerCache
- $permission : Permission
- $responseFactory : ResponseFactory
- $responseFilterPatcher : FilterPatcher
- $survey : Survey
- $transformerOutputSurveyResponses : TransformerOutputSurveyResponses
- $permissionModel : Permission|null
Methods
- __construct() : mixed
- Constructor
- process() : array<string|int, mixed>
- run() : Response
- Run survey responses command
- setPermissionModel() : void
- applyFieldSelection() : void
- Restrict the SELECT to a caller-provided subset of response columns.
- buildCriteria() : CSort}
- Build the criteria and sort from the generic filter/sort engine. The survey's real columns are passed so filter keys can be validated against them (and nested question/subquestion columns filtered at query level).
- buildPagination() : array<string|int, mixed>
- getActualAid() : int|null
- Get the actual answer ID using the shared answer cache.
- getLanguage() : string
- Resolve the requested language, falling back to the survey base language when none (or an unknown one) is requested.
- getPermissionModel() : Permission
- getQuestionFieldMap() : array<string|int, mixed>
- Get the question field map.
- getSurvey() : void
- getSurveyDynamicModel() : SurveyDynamic
- getSurveyId() : string
- hasGlobalPermission() : Response
- hasSurveyPermission() : Response
- mapResponsesToQuestions() : array<string|int, mixed>
- Map survey responses to survey questions.
Constants
FIXED_OUTPUT_COLUMNS
Response columns always loaded regardless of field selection, because the transformed output (id, completed flag, dates, language, token, …) depends on them. Intersected with the survey's real columns before use.
private
mixed
FIXED_OUTPUT_COLUMNS
= ['id', 'submitdate', 'startdate', 'datestamp', 'startlanguage', 'lastpage', 'seed', 'token', 'ipaddr', 'refurl']
Properties
$answerCache
protected
SurveyAnswerCache
$answerCache
$permission
protected
Permission
$permission
$responseFactory
protected
ResponseFactory
$responseFactory
$responseFilterPatcher
protected
FilterPatcher
$responseFilterPatcher
$survey
protected
Survey
$survey
$transformerOutputSurveyResponses
protected
TransformerOutputSurveyResponses
$transformerOutputSurveyResponses
$permissionModel
private
Permission|null
$permissionModel
= null
Methods
__construct()
Constructor
public
__construct(Survey $survey, Permission $permission, FilterPatcher $responseFilterPatcher, ResponseFactory $responseFactory, TransformerOutputSurveyResponses $transformerOutputSurveyResponses, SurveyAnswerCache $answerCache) : mixed
Parameters
- $survey : Survey
- $permission : Permission
- $responseFilterPatcher : FilterPatcher
- $responseFactory : ResponseFactory
- $transformerOutputSurveyResponses : TransformerOutputSurveyResponses
- $answerCache : SurveyAnswerCache
process()
public
process(Request $request) : array<string|int, mixed>
Parameters
- $request : Request
Tags
Return values
array<string|int, mixed>run()
Run survey responses command
public
run(Request $request) : Response
Parameters
- $request : Request
Return values
ResponsesetPermissionModel()
public
setPermissionModel(Permission $permissionModel) : void
Parameters
- $permissionModel : Permission
applyFieldSelection()
Restrict the SELECT to a caller-provided subset of response columns.
protected
applyFieldSelection(LSDbCriteria $criteria, Request $request) : void
Only columns that exist in the survey's field map are honoured; the fixed system columns the transformed output relies on (id, dates, language, token, …) are always kept so selecting question columns never strips the metadata each response needs. When the fields param is missing or empty every column is returned; a nonempty list matching no real column is rejected as a bad request.
Parameters
- $criteria : LSDbCriteria
- $request : Request
buildCriteria()
Build the criteria and sort from the generic filter/sort engine. The survey's real columns are passed so filter keys can be validated against them (and nested question/subquestion columns filtered at query level).
protected
buildCriteria(Request $request) : CSort}
Parameters
- $request : Request
Return values
CSort}buildPagination()
protected
buildPagination(Request $request) : array<string|int, mixed>
Parameters
- $request : Request
Return values
array<string|int, mixed>getActualAid()
Get the actual answer ID using the shared answer cache.
protected
getActualAid(int $questionID, int $scaleId, string $value) : int|null
Parameters
- $questionID : int
- $scaleId : int
- $value : string
Return values
int|nullgetLanguage()
Resolve the requested language, falling back to the survey base language when none (or an unknown one) is requested.
protected
getLanguage(Request $request) : string
Parameters
- $request : Request
Return values
stringgetPermissionModel()
protected
getPermissionModel() : Permission
Return values
PermissiongetQuestionFieldMap()
Get the question field map.
protected
getQuestionFieldMap() : array<string|int, mixed>
Return values
array<string|int, mixed>getSurvey()
protected
getSurvey(Request $request) : void
Parameters
- $request : Request
getSurveyDynamicModel()
protected
getSurveyDynamicModel(Request $request) : SurveyDynamic
Parameters
- $request : Request
Return values
SurveyDynamicgetSurveyId()
protected
getSurveyId(Request $request) : string
Parameters
- $request : Request
Return values
stringhasGlobalPermission()
protected
hasGlobalPermission(string $sPermission, string $sCRUD[, int|null $iUserID = null ]) : Response
Parameters
- $sPermission : string
- $sCRUD : string
- $iUserID : int|null = null
Return values
Response —| boolean
hasSurveyPermission()
protected
hasSurveyPermission(int $iSurveyID, string $sPermission, string $sCRUD[, string|null $iUserID = null ]) : Response
Parameters
- $iSurveyID : int
- $sPermission : string
- $sCRUD : string
- $iUserID : string|null = null
Return values
Response —| boolean
mapResponsesToQuestions()
Map survey responses to survey questions.
protected
mapResponsesToQuestions(array<string|int, mixed> $responses, array<string|int, mixed> $surveyQuestions) : array<string|int, mixed>
Parameters
- $responses : array<string|int, mixed>
- $surveyQuestions : array<string|int, mixed>