SingleOptionMultipleChartsProcessor
extends AbstractQuestionProcessor
in package
Base abstract class for all question processors used in statistics that provides common functionality.
Each concrete processor must implement the process() method
that returns one or more StatisticsChartDTO instances.
Table of Contents
Properties
- $answers : array<string|int, mixed>
- $noAnswerTypes : array<string|int, mixed>
- $question : array<string|int, mixed>
- $rt : string
- $surveyId : int
- $completed : bool
- $maxId : int
- $minId : int
- $totalCountCache : array<int, int>
Methods
- getAggregateResponses() : array<string|int, mixed>|bool
- Gets column aggregate response
- getTotalCount() : int
- Returns the total response count for a survey, with results cached per survey ID.
- process() : array<string|int, StatisticsChartDTO>|StatisticsChartDTO
- Process a question into one or more statistics charts.
- rt() : void
- Build the identifier for current question.
- setAnswers() : void
- Assign available answers to the processor (if applicable).
- setCompleted() : AbstractQuestionProcessor
- setMaxId() : AbstractQuestionProcessor
- setMinId() : AbstractQuestionProcessor
- setQuestion() : void
- Assign question metadata to the processor.
- batchGetResponseCounts() : array<string, int>
- Returns non-empty response counts for multiple columns.
- buildBatchItemsForSubquestions() : array<string, array{0: string[], 1: array[]}>
- Process multiple subquestion fields × answer codes in a query.
- buildItemsFromCodes() : array<string|int, mixed>
- Build chart items (legend + values) from a list of answer codes.
- calculateTotal() : float|int
- countFieldResponses() : int
- Returns the count of non-empty responses for a column.
- buildChartDataByType() : array<string|int, mixed>
- buildFilteredQuery() : array{table: string, where: string, params: array}
- Returns the response table name and (where, params) with filters applied.
- getColSumClause() : string
- Returns clause that counts non-empty values in a column.
- getDb() : CDbConnection
- Returns the active DB connection
- handleArray5Or10() : array<string|int, mixed>
- handleFOrHArray() : array<string|int, mixed>
- handleIncSameDec() : array<string|int, mixed>
- handleYesUncertainNo() : array<string|int, mixed>
- runAggregateSelect() : array<string, array{0: string[], 1: array[]}>
- Get aggregate response counts for fields to specific values
Properties
$answers
protected
array<string|int, mixed>
$answers
= []
Answer list for the question (if applicable)
$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
$completed
private
bool
$completed
= null
Completed responses filter
$maxId
private
int
$maxId
= null
Max ID for responses filter
$minId
private
int
$minId
= null
Min ID for responses filter
$totalCountCache
private
static array<int, int>
$totalCountCache
= []
Cache of total response counts by survey ID
Methods
getAggregateResponses()
Gets column aggregate response
public
getAggregateResponses(mixed $fields, mixed $params) : array<string|int, mixed>|bool
Parameters
- $fields : mixed
- $params : mixed
Return values
array<string|int, mixed>|boolgetTotalCount()
Returns the total response count for a survey, with results cached per survey ID.
public
getTotalCount() : int
Return values
intprocess()
Process a question into one or more statistics charts.
public
process() : array<string|int, StatisticsChartDTO>|StatisticsChartDTO
Return values
array<string|int, StatisticsChartDTO>|StatisticsChartDTOrt()
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
setCompleted()
public
setCompleted(bool|null $completed) : AbstractQuestionProcessor
Parameters
- $completed : bool|null
Return values
AbstractQuestionProcessorsetMaxId()
public
setMaxId(int|null $maxId) : AbstractQuestionProcessor
Parameters
- $maxId : int|null
Return values
AbstractQuestionProcessorsetMinId()
public
setMinId(int|null $minId) : AbstractQuestionProcessor
Parameters
- $minId : int|null
Return values
AbstractQuestionProcessorsetQuestion()
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 non-empty response counts for multiple columns.
protected
batchGetResponseCounts(array<string|int, string> $fieldNames) : array<string, int>
Parameters
- $fieldNames : array<string|int, string>
-
Column names in the response table
Return values
array<string, int> —fieldName => count
buildBatchItemsForSubquestions()
Process multiple subquestion fields × answer codes in a query.
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[]]
calculateTotal()
protected
calculateTotal(array<string|int, mixed> $data[, string $key = 'value' ]) : float|int
Parameters
- $data : array<string|int, mixed>
- $key : string = 'value'
Return values
float|intcountFieldResponses()
Returns the count of non-empty responses for a column.
protected
countFieldResponses(string $fieldName) : int
Parameters
- $fieldName : string
-
Column name in the response table
Return values
intbuildChartDataByType()
private
buildChartDataByType() : array<string|int, mixed>
Return values
array<string|int, mixed>buildFilteredQuery()
Returns the response table name and (where, params) with filters applied.
private
buildFilteredQuery() : array{table: string, where: string, params: array}
Return values
array{table: string, where: string, params: array}getColSumClause()
Returns clause that counts non-empty values in a column.
private
getColSumClause(string $col, string $alias) : string
Parameters
- $col : string
-
column name
- $alias : string
-
alias
Return values
stringgetDb()
Returns the active DB connection
private
getDb() : CDbConnection
Return values
CDbConnectionhandleArray5Or10()
private
handleArray5Or10() : array<string|int, mixed>
Return values
array<string|int, mixed>handleFOrHArray()
private
handleFOrHArray() : array<string|int, mixed>
Return values
array<string|int, mixed>handleIncSameDec()
private
handleIncSameDec() : array<string|int, mixed>
Return values
array<string|int, mixed>handleYesUncertainNo()
private
handleYesUncertainNo() : array<string|int, mixed>
Return values
array<string|int, mixed>runAggregateSelect()
Get aggregate response counts for fields to specific values
private
runAggregateSelect(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[]]