LimeSurvey API - Master branch

StatisticsService
in package

Service layer for survey statistics.

Acts as the entry point for generating statistics across all configured graph processors (e.g., question-level statistics).

Table of Contents

Properties

$charts  : array<string|int, mixed>
$filters  : StatisticsResponseFilters
$language  : string
$output  : array<string|int, mixed>
$pagination  : array{page: int, pageSize: int}|null
$paginationMeta  : array<string|int, mixed>|null
$survey  : Survey|null
$surveyId  : int|string

Methods

__construct()  : mixed
getPaginationMeta()  : array<string|int, mixed>|null
Pagination meta from the last run, null when no pagination applied.
run()  : array<string|int, mixed>
Execute statistics generation for all configured graphs.
setChart()  : $this
Register a chart type processor by class name.
setFilters()  : void
Set response filters to apply to all chart processors.
setPagination()  : $this
Paginate chart output for chart processors that support it.
setSurvey()  : $this
Set survey context (ID + language).
handleChartOutput()  : void

Properties

$charts

private array<string|int, mixed> $charts

List of charts classes to run

$output

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

Gathered chart results

$pagination

private array{page: int, pageSize: int}|null $pagination = null

Pagination to apply to charts supporting it

$paginationMeta

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

Pagination meta reported by the executed charts

$survey

private Survey|null $survey = null

Survey model loaded during setSurvey(), shared with charts so they don't re-fetch it

Methods

getPaginationMeta()

Pagination meta from the last run, null when no pagination applied.

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

run()

Execute statistics generation for all configured graphs.

public run([array<string|int, mixed> $specificCharts = [] ]) : array<string|int, mixed>
Parameters
$specificCharts : array<string|int, mixed> = []

List of specific chart classes to run

Tags
throws
RuntimeException
Return values
array<string|int, mixed>

Combined output from all graph processors

setChart()

Register a chart type processor by class name.

public setChart(string $chart) : $this
Parameters
$chart : string
Return values
$this

setPagination()

Paginate chart output for chart processors that support it.

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

Zero-based page index

$pageSize : int

Charts per page

Return values
$this

setSurvey()

Set survey context (ID + language).

public setSurvey(int|string $surveyId[, string|null $language = null ]) : $this
Parameters
$surveyId : int|string

Survey ID

$language : string|null = null

Language code (default = null)

Tags
throws
InvalidArgumentException
throws
NotFoundException
Return values
$this

handleChartOutput()

private handleChartOutput(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>

        
On this page

Search results