CourseReports
extends AbstractBaseApi
in package
Canvas Course Reports API
Manages course report generation and status tracking in Canvas LMS. Reports are asynchronous operations that generate downloadable files containing course data such as grades, student activity, assignments, etc.
Tags
Table of Contents
Properties
- $attachment : mixed
- Report attachment details
- $createdAt : string|null
- Report creation timestamp
- $endedAt : string|null
- Report completion timestamp
- $fileUrl : string|null
- URL to download the completed report file
- $id : int|null
- Report ID
- $parameters : array<string, mixed>|null
- Parameters used to generate the report
- $progress : int|null
- Report generation progress (0-100)
- $startedAt : string|null
- Report start timestamp
- $status : string|null
- Report status (complete, running, failed, etc.)
- $apiClient : HttpClientInterface
- $course : Course|null
- Course context for report operations
- $methodAliases : array<string|int, mixed>
- Define method aliases
Methods
- __callStatic() : mixed
- Magic method to handle function aliases
- __construct() : mixed
- BaseApi constructor.
- all() : array<string|int, static>
- Get all pages of results
- checkCourse() : bool
- Check if course context is set and valid
- create() : self
- Start generating a new report for the course
- delete() : bool
- destroy() : bool
- find() : static
- Interface-required find method (not supported for course reports) Use getReport() method instead with report type and ID
- get() : array<string|int, static>
- Get first page of results
- getProgress() : int
- Get the report progress as a percentage
- getReport() : self
- Get the status of a specific report
- getStatusDescription() : string
- Get a human-readable status description
- isCompleted() : bool
- Check if the report generation is completed
- isFailed() : bool
- Check if the report generation failed
- isReady() : bool
- Check if the report is ready for download
- isRunning() : bool
- Check if the report generation is currently running
- last() : self
- Get the status of the last report of the specified type
- paginate() : PaginationResult
- Get paginated results with metadata
- save() : bool
- setApiClient() : void
- Set the API client
- setCourse() : void
- Set the course context for report operations
- toArray() : array<string, mixed>
- Convert the report data to array format
- update() : self
- castValue() : DateTime|mixed
- Cast a value to the correct type
- checkApiClient() : void
- Check if the API client is set, if not, instantiate a new one
- convertPaginatedResponseToModels() : array<string|int, static>
- Helper method to convert paginated response data to model instances
- createConfiguredHttpClient() : HttpClient
- Create an HttpClient with configured middleware
- createPaginationResult() : PaginationResult
- Helper method to create PaginationResult from paginated response
- getEndpoint() : string
- Get the base API endpoint for reports (requires course context)
- getPaginatedResponse() : PaginatedResponse
- Helper method to get paginated response from API endpoint
- populate() : void
- Populate the object with new data
- toDtoArray() : array<string|int, mixed>
- Convert the object to an array
Properties
$attachment
Report attachment details
public
mixed
$attachment
= null
$createdAt
Report creation timestamp
public
string|null
$createdAt
= null
$endedAt
Report completion timestamp
public
string|null
$endedAt
= null
$fileUrl
URL to download the completed report file
public
string|null
$fileUrl
= null
$id
Report ID
public
int|null
$id
= null
$parameters
Parameters used to generate the report
public
array<string, mixed>|null
$parameters
= null
$progress
Report generation progress (0-100)
public
int|null
$progress
= null
$startedAt
Report start timestamp
public
string|null
$startedAt
= null
$status
Report status (complete, running, failed, etc.)
public
string|null
$status
= null
$apiClient
protected
static HttpClientInterface
$apiClient
= null
$course
Course context for report operations
protected
static Course|null
$course
= null
$methodAliases
Define method aliases
protected
static array<string|int, mixed>
$methodAliases
= ['get' => ['fetch', 'list', 'fetchAll'], 'all' => ['fetchAllPages', 'getAll'], 'paginate' => ['getPaginated', 'withPagination', 'fetchPage'], 'find' => ['one', 'getOne']]
Methods
__callStatic()
Magic method to handle function aliases
public
static __callStatic(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
- $name : string
- $arguments : array<string|int, mixed>
Tags
__construct()
BaseApi constructor.
public
__construct(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
all()
Get all pages of results
public
static all([array<string, mixed> $params = [] ]) : array<string|int, static>
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
array<string|int, static>checkCourse()
Check if course context is set and valid
public
static checkCourse() : bool
Tags
Return values
bool —True if course context is valid
create()
Start generating a new report for the course
public
static create(string $reportType[, array<string, mixed> $parameters = [] ]) : self
Parameters
- $reportType : string
-
Type of report to generate (e.g., 'grade_export', 'student_assignment_data')
- $parameters : array<string, mixed> = []
-
Additional parameters for report generation
Tags
Return values
self —New CourseReports instance with report details
delete()
public
static delete(int $id) : bool
Parameters
- $id : int
Return values
booldestroy()
public
destroy() : bool
Return values
boolfind()
Interface-required find method (not supported for course reports) Use getReport() method instead with report type and ID
public
static find(int $id[, array<string|int, mixed> $params = [] ]) : static
Parameters
- $id : int
-
Report ID (not used)
- $params : array<string|int, mixed> = []
-
Optional query parameters
Tags
Return values
static —Never returns, always throws exception
get()
Get first page of results
public
static get([array<string, mixed> $params = [] ]) : array<string|int, static>
Parameters
- $params : array<string, mixed> = []
Tags
Return values
array<string|int, static>getProgress()
Get the report progress as a percentage
public
getProgress() : int
Return values
int —Progress percentage (0-100)
getReport()
Get the status of a specific report
public
static getReport(string $reportType, int $reportId) : self
Parameters
- $reportType : string
-
Type of report to check
- $reportId : int
-
ID of the specific report
Tags
Return values
self —CourseReports instance with report status
getStatusDescription()
Get a human-readable status description
public
getStatusDescription() : string
Return values
string —Status description
isCompleted()
Check if the report generation is completed
public
isCompleted() : bool
Return values
bool —True if report status is 'complete'
isFailed()
Check if the report generation failed
public
isFailed() : bool
Return values
bool —True if report status is 'failed'
isReady()
Check if the report is ready for download
public
isReady() : bool
Return values
bool —True if report is completed and has a download URL
isRunning()
Check if the report generation is currently running
public
isRunning() : bool
Return values
bool —True if report status is 'running'
last()
Get the status of the last report of the specified type
public
static last(string $reportType) : self
Parameters
- $reportType : string
-
Type of report to check
Tags
Return values
self —CourseReports instance with last report status
paginate()
Get paginated results with metadata
public
static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginationResultsave()
public
save() : bool
Return values
boolsetApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
setCourse()
Set the course context for report operations
public
static setCourse(Course $course) : void
Parameters
- $course : Course
-
Course instance to operate on
toArray()
Convert the report data to array format
public
toArray() : array<string, mixed>
Return values
array<string, mixed> —Report data as associative array
update()
public
static update(int $id, array<string, mixed> $data) : self
Parameters
- $id : int
- $data : array<string, mixed>
Return values
selfcastValue()
Cast a value to the correct type
protected
castValue(string $key, mixed $value) : DateTime|mixed
Parameters
- $key : string
- $value : mixed
Tags
Return values
DateTime|mixedcheckApiClient()
Check if the API client is set, if not, instantiate a new one
protected
static checkApiClient() : void
convertPaginatedResponseToModels()
Helper method to convert paginated response data to model instances
protected
static convertPaginatedResponseToModels(PaginatedResponse $paginatedResponse) : array<string|int, static>
Parameters
- $paginatedResponse : PaginatedResponse
Return values
array<string|int, static>createConfiguredHttpClient()
Create an HttpClient with configured middleware
protected
static createConfiguredHttpClient() : HttpClient
Return values
HttpClientcreatePaginationResult()
Helper method to create PaginationResult from paginated response
protected
static createPaginationResult(PaginatedResponse $paginatedResponse) : PaginationResult
Parameters
- $paginatedResponse : PaginatedResponse
Return values
PaginationResultgetEndpoint()
Get the base API endpoint for reports (requires course context)
protected
static getEndpoint() : string
Return values
string —The API endpoint pattern
getPaginatedResponse()
Helper method to get paginated response from API endpoint
protected
static getPaginatedResponse(string $endpoint[, array<string|int, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $endpoint : string
-
The API endpoint path
- $params : array<string|int, mixed> = []
-
Query parameters for the request
Return values
PaginatedResponsepopulate()
Populate the object with new data
protected
populate(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Tags
toDtoArray()
Convert the object to an array
protected
toDtoArray() : array<string|int, mixed>