LimeSurvey API - Master branch

FileUploadProcessor 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.
getFileCounts()  : array<string|int, mixed>
getFileStats()  : 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
runAggregateSelect()  : array<string, array{0: string[], 1: array[]}>
Get aggregate response counts for fields to specific values

Properties

$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

$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>|bool

getTotalCount()

Returns the total response count for a survey, with results cached per survey ID.

public getTotalCount() : int
Return values
int

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

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
throws
InvalidArgumentException

if question data is invalid

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

countFieldResponses()

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
int

getFileCounts()

protected getFileCounts() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFileStats()

protected getFileStats() : 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
string

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[]]


        
On this page

Search results