Documentation

Outcome extends AbstractBaseApi
in package

Outcome API class for managing learning outcomes in Canvas LMS.

Outcomes allow instructors to track student mastery of specific learning objectives across assignments and courses. This class follows the Account-as-Default convention for multi-context resources.

Tags
see
https://canvas.instructure.com/doc/api/outcomes.html

Table of Contents

Properties

$alignments  : array<int, mixed>|null
$assessed  : bool|null
$calculationInt  : int|null
$calculationMethod  : string|null
$canEdit  : bool|null
$canUnlink  : bool|null
$contextId  : string|null
$contextType  : string|null
$description  : string|null
$displayName  : string|null
$friendlyDescription  : string|null
$hasUpdateableRubrics  : bool|null
$id  : int|null
$masteryPoints  : float|null
$pointsPossible  : float|null
$ratings  : array<int, mixed>|null
$title  : string|null
$url  : string|null
$vendorGuid  : 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
canEdit()  : bool
Check if outcome can be edited.
canUnlink()  : bool
Check if outcome can be unlinked.
create()  : self
Create a new outcome (defaults to Account context).
createInContext()  : self
Create or link an outcome in a specific context and group.
deleteFromContext()  : bool
Delete/unlink an outcome from a specific context and group.
fetchByContext()  : array<int, static>
Fetch outcomes by specific context.
fetchByContextPaginated()  : PaginationResult
Fetch paginated outcomes by specific context.
find()  : self
Find a specific outcome by ID.
get()  : array<int, static>
Get first page of outcomes (defaults to Account context).
getAlignments()  : array<int, mixed>
Get alignments for this outcome.
getCalculationMethodDisplayName()  : string
Get the calculation method display name.
importFromVendor()  : self
Import an outcome from external vendor.
isAssessed()  : bool
Check if outcome has been assessed.
paginate()  : PaginationResult
Get paginated outcomes (defaults to Account context).
save()  : self
Save the current outcome (create or update).
setApiClient()  : void
Set the API client
update()  : self
Update an existing outcome.
validateRatings()  : bool
Validate rating scale.
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 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

$alignments

public array<int, mixed>|null $alignments = null

$assessed

public bool|null $assessed = null

$calculationInt

public int|null $calculationInt = null

$calculationMethod

public string|null $calculationMethod = null

$canEdit

public bool|null $canEdit = null
public bool|null $canUnlink = null

$contextId

public string|null $contextId = null

$contextType

public string|null $contextType = null

$description

public string|null $description = null

$displayName

public string|null $displayName = null

$friendlyDescription

public string|null $friendlyDescription = null

$hasUpdateableRubrics

public bool|null $hasUpdateableRubrics = null

$masteryPoints

public float|null $masteryPoints = null

$pointsPossible

public float|null $pointsPossible = null

$ratings

public array<int, mixed>|null $ratings = null

$title

public string|null $title = null

$vendorGuid

public string|null $vendorGuid = 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>

canEdit()

Check if outcome can be edited.

public canEdit() : bool
Return values
bool

Check if outcome can be unlinked.

public canUnlink() : bool
Return values
bool

createInContext()

Create or link an outcome in a specific context and group.

public static createInContext(string $contextType, int $contextId, int|null $groupId, array<string, mixed>|CreateOutcomeDTO $data) : self
Parameters
$contextType : string

Context type (accounts, courses)

$contextId : int

Context ID

$groupId : int|null

Outcome group ID (null for global group)

$data : array<string, mixed>|CreateOutcomeDTO

Outcome data

Tags
throws
CanvasApiException
Return values
self

deleteFromContext()

Delete/unlink an outcome from a specific context and group.

public deleteFromContext(string $contextType, int $contextId[, int|null $groupId = null ]) : bool
Parameters
$contextType : string

Context type (accounts, courses)

$contextId : int

Context ID

$groupId : int|null = null

Outcome group ID (null for global group)

Tags
throws
CanvasApiException
Return values
bool

fetchByContext()

Fetch outcomes by specific context.

public static fetchByContext(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : array<int, static>
Parameters
$contextType : string

Context type (accounts, courses)

$contextId : int

Context ID

$params : array<string, mixed> = []

Optional query parameters

Tags
throws
CanvasApiException
Return values
array<int, static>

Array of Outcome objects

fetchByContextPaginated()

Fetch paginated outcomes by specific context.

public static fetchByContextPaginated(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : PaginationResult
Parameters
$contextType : string

Context type (accounts, courses)

$contextId : int

Context ID

$params : array<string, mixed> = []

Optional query parameters

Tags
throws
CanvasApiException
Return values
PaginationResult

find()

Find a specific outcome by ID.

public static find(int $id[, array<string|int, mixed> $params = [] ]) : self
Parameters
$id : int

Outcome ID

$params : array<string|int, mixed> = []

Optional query parameters

Tags
throws
CanvasApiException
Return values
self

get()

Get first page of outcomes (defaults to Account context).

public static get([array<string, mixed> $params = [] ]) : array<int, static>
Parameters
$params : array<string, mixed> = []

Optional query parameters

Tags
throws
CanvasApiException
Return values
array<int, static>

Array of Outcome objects

getAlignments()

Get alignments for this outcome.

public getAlignments(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : array<int, mixed>
Parameters
$contextType : string

Context type (accounts, courses)

$contextId : int

Context ID

$params : array<string, mixed> = []

Optional query parameters

Tags
throws
CanvasApiException
Return values
array<int, mixed>

Array of alignments

getCalculationMethodDisplayName()

Get the calculation method display name.

public getCalculationMethodDisplayName() : string
Return values
string

importFromVendor()

Import an outcome from external vendor.

public static importFromVendor(string $contextType, int $contextId, string $vendorGuid[, int|null $groupId = null ]) : self
Parameters
$contextType : string

Context type (accounts, courses)

$contextId : int

Context ID

$vendorGuid : string

Vendor GUID

$groupId : int|null = null

Outcome group ID

Tags
throws
CanvasApiException
Return values
self

isAssessed()

Check if outcome has been assessed.

public isAssessed() : bool
Return values
bool

paginate()

Get paginated outcomes (defaults to Account context).

public static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
$params : array<string, mixed> = []

Optional query parameters

Tags
throws
CanvasApiException
Return values
PaginationResult

Paginated result with metadata

validateRatings()

Validate rating scale.

public validateRatings() : 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 endpoint for this resource.

protected static getEndpoint() : string
Tags
throws
CanvasApiException
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