NumericalProcessor
extends AbstractQuestionProcessor
in package
Numerical input: no chart, one data row whose `stats` object feeds the descriptive-statistics table. The response column is DECIMAL, so all aggregates run in numeric-column mode (blank = NULL).
Table of Contents
Properties
- $answers : array<string|int, mixed>
- $batch : ResponseAggregateBatch
- $noAnswerTypes : array<string|int, mixed>
- $question : array<string|int, mixed>
- $rt : string
- $surveyId : int
Methods
- getQuestion() : array<string|int, mixed>
- Returns the question data as assigned to the processor (title flattened).
- getTotalCount() : callable
- Returns a deferred total response count for the survey.
- process() : array<string|int, mixed>
- Plan a question into one or more statistics chart plans.
- rt() : void
- Build the identifier for current question.
- setAnswers() : void
- Assign available answers to the processor (if applicable).
- setBatch() : void
- Assign the shared aggregate batch for the current statistics run.
- setQuestion() : void
- Assign question metadata to the processor.
- batchGetResponseCounts() : array<string, callable>
- Returns deferred non-empty response counts for multiple columns.
- buildBatchItemsForSubquestions() : array<string, array{0: string[], 1: array[]}>
- Plan multiple subquestion fields × answer codes.
- buildItemsFromCodes() : array<string|int, mixed>
- Build chart items (legend + values) from a list of answer codes.
- countFieldResponses() : callable
- Returns a deferred count of non-empty responses for a column.
- read() : callable
- Closure resolving a batch alias once the batch has executed.
- planAggregateItems() : array<string, array{0: string[], 1: array[]}>
- Register value counts (and a NoAnswer/blank count for the applicable question types) for fields against specific answer codes.
- statsOf() : callable
- Deferred stats; null when nobody answered. Standard deviation is the population deviation (÷ n, like legacy): variance = Σx²/n − mean².
Properties
$answers
protected
array<string|int, mixed>
$answers
= []
Answer list for the question (if applicable)
$batch
protected
ResponseAggregateBatch
$batch
Shared aggregate batch for the current run
$noAnswerTypes
protected
array<string|int, mixed>
$noAnswerTypes
= [\Question::QT_L_LIST, \Question::QT_EXCLAMATION_LIST_DROPDOWN, \Question::QT_O_LIST_WITH_COMMENT, \Question::QT_Y_YES_NO_RADIO, \Question::QT_G_GENDER, \Question::QT_5_POINT_CHOICE, \Question::QT_A_ARRAY_5_POINT, \Question::QT_B_ARRAY_10_CHOICE_QUESTIONS, \Question::QT_C_ARRAY_YES_UNCERTAIN_NO, \Question::QT_E_ARRAY_INC_SAME_DEC, \Question::QT_F_ARRAY, \Question::QT_H_ARRAY_COLUMN, \Question::QT_1_ARRAY_DUAL, \Question::QT_SEMICOLON_ARRAY_TEXT, \Question::QT_S_SHORT_FREE_TEXT, \Question::QT_T_LONG_FREE_TEXT, \Question::QT_Q_MULTIPLE_SHORT_TEXT]
List of question types which contain no answer option
$question
protected
array<string|int, mixed>
$question
= []
Current question data
$rt
protected
string
$rt
= ''
$surveyId
protected
int
$surveyId
= 0
Survey ID for the current context
Methods
getQuestion()
Returns the question data as assigned to the processor (title flattened).
public
getQuestion() : array<string|int, mixed>
Return values
array<string|int, mixed>getTotalCount()
Returns a deferred total response count for the survey.
public
getTotalCount() : callable
Return values
callable —Resolves to an int once the batch has executed
process()
Plan a question into one or more statistics chart plans.
public
process() : array<string|int, mixed>
Must be side-effect free with respect to aggregate values: counts are not available while planning, only after the batch has executed.
Return values
array<string|int, mixed> —A chart plan or a list of chart plans
rt()
Build the identifier for current question.
public
rt() : void
Ex: Qqid
setAnswers()
Assign available answers to the processor (if applicable).
public
setAnswers(array<string|int, mixed> $answers) : void
Parameters
- $answers : array<string|int, mixed>
-
List of answers
setBatch()
Assign the shared aggregate batch for the current statistics run.
public
setBatch(ResponseAggregateBatch $batch) : void
Parameters
- $batch : ResponseAggregateBatch
setQuestion()
Assign question metadata to the processor.
public
setQuestion(array<string|int, mixed> $question) : void
Parameters
- $question : array<string|int, mixed>
-
Question data (from DB/metadata fetch)
Tags
batchGetResponseCounts()
Returns deferred non-empty response counts for multiple columns.
protected
batchGetResponseCounts(array<string|int, string> $fieldNames) : array<string, callable>
Parameters
- $fieldNames : array<string|int, string>
-
Column names in the response table
Return values
array<string, callable> —fieldName => deferred count
buildBatchItemsForSubquestions()
Plan multiple subquestion fields × answer codes.
protected
buildBatchItemsForSubquestions(array<string|int, string> $fieldNames, array<string|int, string> $codes[, array<string|int, string> $labels = [] ]) : array<string, array{0: string[], 1: array[]}>
Parameters
- $fieldNames : array<string|int, string>
-
Column names (one per subquestion)
- $codes : array<string|int, string>
-
Answer codes to count
- $labels : array<string|int, string> = []
-
Display labels aligned with $codes
Return values
array<string, array{0: string[], 1: array[]}> —fieldName => [legend[], items[]]
buildItemsFromCodes()
Build chart items (legend + values) from a list of answer codes.
protected
buildItemsFromCodes(string $fieldname, array<string|int, string> $codes[, array<string|int, string> $labels = [] ]) : array<string|int, mixed>
Parameters
- $fieldname : string
-
Column name in the response table
- $codes : array<string|int, string>
-
Answer codes
- $labels : array<string|int, string> = []
-
Display labels aligned with $codes
Return values
array<string|int, mixed> —[legend[], items[]]
countFieldResponses()
Returns a deferred count of non-empty responses for a column.
protected
countFieldResponses(string $fieldName) : callable
Parameters
- $fieldName : string
-
Column name in the response table
Return values
callable —Resolves to an int once the batch has executed
read()
Closure resolving a batch alias once the batch has executed.
protected
read(string $alias) : callable
Parameters
- $alias : string
Return values
callableplanAggregateItems()
Register value counts (and a NoAnswer/blank count for the applicable question types) for fields against specific answer codes.
private
planAggregateItems(array<string|int, string> $fieldNames, array<string|int, string> $codes, array<string|int, string> $labels) : array<string, array{0: string[], 1: array[]}>
Parameters
- $fieldNames : array<string|int, string>
- $codes : array<string|int, string>
- $labels : array<string|int, string>
Return values
array<string, array{0: string[], 1: array[]}> —fieldName => [legend[], items[]]
statsOf()
Deferred stats; null when nobody answered. Standard deviation is the population deviation (÷ n, like legacy): variance = Σx²/n − mean².
private
statsOf(string $field) : callable
Parameters
- $field : string