Documentation

OutcomeResult extends AbstractBaseApi

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
see
https://canvas.instructure.com/doc/api/outcome_results.html

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

$submittedOrAssessedAt

public string|null $submittedOrAssessedAt = 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
throws
InvalidArgumentException

__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
throws
CanvasApiException
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
throws
CanvasApiException
Return values
PaginatedResponse

fetchByCourse()

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

Always thrown as OutcomeResult doesn't support direct find

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

Always thrown as method requires context

Return values
array<int, static>

Never returns - always throws exception

getLinkedAlignment()

Get the linked alignment.

public getLinkedAlignment() : string|null
Return values
string|null

getLinkedOutcomeId()

Get the linked outcome ID.

public getLinkedOutcomeId() : int|null
Return values
int|null

getLinkedUserId()

Get the linked user ID.

public getLinkedUserId() : int|null
Return values
int|null

getMasteryPercentage()

Get the mastery percentage.

public getMasteryPercentage() : float|null
Return values
float|null

isHidden()

Check if the result is hidden.

public isHidden() : bool
Return values
bool

isMastery()

Check if the result represents mastery.

public isMastery() : bool
Return values
bool

castValue()

Cast a value to the correct type

protected castValue(string $key, mixed $value) : DateTime|mixed
Parameters
$key : string
$value : mixed
Tags
throws
Exception
Return values
DateTime|mixed

checkApiClient()

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>

getEndpoint()

Get the API endpoint for this resource

protected static getEndpoint() : string
Return values
string

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
PaginatedResponse

populate()

Populate the object with new data

protected populate(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Tags
throws
Exception

toDtoArray()

Convert the object to an array

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

        
On this page

Search results