LimeSurvey API - Master branch

QuestionStatistics
in package
implements StatisticsChartInterface

Table of Contents

Interfaces

StatisticsChartInterface
Interface for all statistics chart classes.

Properties

$factories  : array<string|int, mixed>
$filters  : mixed
$language  : string
$output  : array<string|int, mixed>
$page  : int
$pageSize  : int|null
$paginationMeta  : array<string|int, mixed>|null
$questionFields  : array<int, array<string|int, string>>
$survey  : Survey|null
$surveyId  : int
$typeDescriptions  : array<string, string>|null

Methods

__construct()  : mixed
getPaginationMeta()  : array<string|int, mixed>|null
Pagination details of the last run, null when pagination was not set.
run()  : array<string|int, mixed>
Run the chart generation logic.
setFilters()  : void
Set filters for responses
setPagination()  : void
Limit the run to one page of chart-producing questions.
setSurveyModel()  : void
buildBaseQuery()  : CDbCommand
buildQuestionFields()  : array<int, array<string|int, string>>
Map every question id to its response-table column fieldnames (e.g.
fetchSurveyMetadata()  : mixed
paginate()  : array<string|int, mixed>
Slice the eligible [factory, question] pairs to the configured page and record the pagination meta.
planFactory()  : array{0: array, 1: array}
Configure the processor and let it plan its charts against the batch.
resolvePlan()  : StatisticsChartDTO
Materialize a chart plan: resolve every deferred value against the executed batch and compute the total.
resolvePlans()  : StatisticsChartDTO|array<string|int, StatisticsChartDTO>
Resolve one plan or a list of plans into StatisticsChartDTO(s).
toNumber()  : int|float
Normalise a (possibly numeric-string) value to an int or float, preserving fractional precision instead of truncating means to whole numbers. Non-numeric values become 0.
trimMeta()  : void

Properties

$pageSize

private int|null $pageSize = null

Charts per page; null disables pagination

$paginationMeta

private array<string|int, mixed>|null $paginationMeta = null

Pagination details of the last run, null when unpaginated

$questionFields

private array<int, array<string|int, string>> $questionFields = []

Question id -> its response-table column fieldnames

$typeDescriptions

private array<string, string>|null $typeDescriptions = null

Cached type code -> human-readable description map

Methods

getPaginationMeta()

Pagination details of the last run, null when pagination was not set.

public getPaginationMeta() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

run()

Run the chart generation logic.

public run(int $surveyId[, string $language = 'en' ]) : array<string|int, mixed>
Parameters
$surveyId : int

Survey ID

$language : string = 'en'

Language code (optional, for localized text)

Return values
array<string|int, mixed>

Chart output(s)

setPagination()

Limit the run to one page of chart-producing questions.

public setPagination(int $page, int $pageSize) : void
Parameters
$page : int

Zero-based page index

$pageSize : int

Charts per page

buildBaseQuery()

private buildBaseQuery() : CDbCommand
Return values
CDbCommand

buildQuestionFields()

Map every question id to its response-table column fieldnames (e.g.

private buildQuestionFields() : array<int, array<string|int, string>>

Q12, Q12_S34, Q12_Ccomment). These are the columns the client passes as fields to the survey-responses endpoint to fetch only that question's answers. Built once per run from the authoritative survey field map.

Return values
array<int, array<string|int, string>>

paginate()

Slice the eligible [factory, question] pairs to the configured page and record the pagination meta.

private paginate(array<string|int, mixed> $eligible) : array<string|int, mixed>
Parameters
$eligible : array<string|int, mixed>
Return values
array<string|int, mixed>

planFactory()

Configure the processor and let it plan its charts against the batch.

private planFactory(mixed $factory, ResponseAggregateBatch $batch, mixed $survey, mixed $question) : array{0: array, 1: array}
Parameters
$factory : mixed
$batch : ResponseAggregateBatch
$survey : mixed
$question : mixed
Return values
array{0: array, 1: array}

[chart plan(s), question data]

resolvePlan()

Materialize a chart plan: resolve every deferred value against the executed batch and compute the total.

private resolvePlan(array<string|int, mixed> $plan, array<string|int, mixed> $question) : StatisticsChartDTO
Parameters
$plan : array<string|int, mixed>
$question : array<string|int, mixed>
Return values
StatisticsChartDTO

resolvePlans()

Resolve one plan or a list of plans into StatisticsChartDTO(s).

private resolvePlans(array<string|int, mixed> $plans, array<string|int, mixed> $question) : StatisticsChartDTO|array<string|int, StatisticsChartDTO>
Parameters
$plans : array<string|int, mixed>

Single chart plan (has 'title') or list of plans

$question : array<string|int, mixed>

Question data for the chart meta

Return values
StatisticsChartDTO|array<string|int, StatisticsChartDTO>

toNumber()

Normalise a (possibly numeric-string) value to an int or float, preserving fractional precision instead of truncating means to whole numbers. Non-numeric values become 0.

private toNumber(mixed $value) : int|float
Parameters
$value : mixed
Return values
int|float

        
On this page

Search results