OutcomeResult
extends AbstractBaseApi
in package
OutcomeResult API class for tracking student mastery of outcomes.
Outcome results represent individual assessments of student performance against specific learning outcomes, including scores and mastery status.
Note: OutcomeResult is a read-only resource that requires context (Course or User). Direct fetching without context is not supported by Canvas API.
Tags
Table of Contents
Properties
- $alignment : array<string, mixed>|null
- $assessedAt : string|null
- $assignmentId : int|null
- $assignmentName : string|null
- $attemptedAt : string|null
- $hidden : bool|null
- $id : int|null
- $links : array<string, mixed>|null
- $mastery : bool|null
- $outcome : array<string, mixed>|null
- $outcomeId : int|null
- $outcomeTitle : string|null
- $percent : float|null
- $possiblePoints : float|null
- $score : float|null
- $submittedOrAssessedAt : string|null
- $user : array<string, mixed>|null
- $userId : int|null
- $userName : string|null
- $apiClient : HttpClientInterface
- $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
- fetchByContext() : array<int, OutcomeResult>
- Fetch all outcome results by context.
- fetchByContextPaginated() : PaginatedResponse
- Fetch paginated outcome results by context.
- fetchByCourse() : array<int, OutcomeResult>
- Fetch outcome results for a course.
- fetchByUser() : array<int, OutcomeResult>
- Fetch outcome results for a user.
- find() : static
- Find method - NOT SUPPORTED for OutcomeResult.
- get() : array<int, static>
- Fetch all outcome results - NOT SUPPORTED.
- getLinkedAlignment() : string|null
- Get the linked alignment.
- getLinkedOutcomeId() : int|null
- Get the linked outcome ID.
- getLinkedUserId() : int|null
- Get the linked user ID.
- getMasteryPercentage() : float|null
- Get the mastery percentage.
- isHidden() : bool
- Check if the result is hidden.
- isMastery() : bool
- Check if the result represents mastery.
- paginate() : PaginationResult
- Get paginated results with metadata
- setApiClient() : void
- Set the API client
- 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 API endpoint for this resource
- 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
$alignment
public
array<string, mixed>|null
$alignment
= null
$assessedAt
public
string|null
$assessedAt
= null
$assignmentId
public
int|null
$assignmentId
= null
$assignmentName
public
string|null
$assignmentName
= null
$attemptedAt
public
string|null
$attemptedAt
= null
$hidden
public
bool|null
$hidden
= null
$id
public
int|null
$id
= null
$links
public
array<string, mixed>|null
$links
= null
$mastery
public
bool|null
$mastery
= null
$outcome
public
array<string, mixed>|null
$outcome
= null
$outcomeId
public
int|null
$outcomeId
= null
$outcomeTitle
public
string|null
$outcomeTitle
= null
$percent
public
float|null
$percent
= null
$possiblePoints
public
float|null
$possiblePoints
= null
$score
public
float|null
$score
= null
$submittedOrAssessedAt
public
string|null
$submittedOrAssessedAt
= null
$user
public
array<string, mixed>|null
$user
= null
$userId
public
int|null
$userId
= null
$userName
public
string|null
$userName
= null
$apiClient
protected
static HttpClientInterface
$apiClient
= 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>fetchByContext()
Fetch all outcome results by context.
public
static fetchByContext(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : array<int, OutcomeResult>
Parameters
- $contextType : string
-
Context type (courses, users)
- $contextId : int
-
Context ID
- $params : array<string, mixed> = []
-
Query parameters
Tags
Return values
array<int, OutcomeResult> —Array of OutcomeResult objects
fetchByContextPaginated()
Fetch paginated outcome results by context.
public
static fetchByContextPaginated(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $contextType : string
-
Context type (courses, users)
- $contextId : int
-
Context ID
- $params : array<string, mixed> = []
-
Query parameters
Tags
Return values
PaginatedResponsefetchByCourse()
Fetch outcome results for a course.
public
static fetchByCourse(int $courseId[, array<string, mixed> $params = [] ]) : array<int, OutcomeResult>
Parameters
- $courseId : int
-
Course ID
- $params : array<string, mixed> = []
-
Query parameters (user_ids, outcome_ids, include, etc.)
Tags
Return values
array<int, OutcomeResult> —Array of OutcomeResult objects
fetchByUser()
Fetch outcome results for a user.
public
static fetchByUser(int $userId[, array<string, mixed> $params = [] ]) : array<int, OutcomeResult>
Parameters
- $userId : int
-
User ID
- $params : array<string, mixed> = []
-
Query parameters
Tags
Return values
array<int, OutcomeResult> —Array of OutcomeResult objects
find()
Find method - NOT SUPPORTED for OutcomeResult.
public
static find(int $id[, array<string|int, mixed> $params = [] ]) : static
Parameters
- $id : int
-
ID
- $params : array<string|int, mixed> = []
-
Optional query parameters
Tags
Return values
static —Never returns - always throws exception
get()
Fetch all outcome results - NOT SUPPORTED.
public
static get([array<string, mixed> $params = [] ]) : array<int, static>
OutcomeResult requires context. Use fetchByContext() instead.
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Tags
Return values
array<int, static> —Never returns - always throws exception
getLinkedAlignment()
Get the linked alignment.
public
getLinkedAlignment() : string|null
Return values
string|nullgetLinkedOutcomeId()
Get the linked outcome ID.
public
getLinkedOutcomeId() : int|null
Return values
int|nullgetLinkedUserId()
Get the linked user ID.
public
getLinkedUserId() : int|null
Return values
int|nullgetMasteryPercentage()
Get the mastery percentage.
public
getMasteryPercentage() : float|null
Return values
float|nullisHidden()
Check if the result is hidden.
public
isHidden() : bool
Return values
boolisMastery()
Check if the result represents mastery.
public
isMastery() : bool
Return values
boolpaginate()
Get paginated results with metadata
public
static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginationResultsetApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
castValue()
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 API endpoint for this resource
protected
static getEndpoint() : string
Return values
stringgetPaginatedResponse()
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>