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
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
$canUnlink
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
$id
public
int|null
$id
= 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
$url
public
string|null
$url
= null
$vendorGuid
public
string|null
$vendorGuid
= 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>canEdit()
Check if outcome can be edited.
public
canEdit() : bool
Return values
boolcanUnlink()
Check if outcome can be unlinked.
public
canUnlink() : bool
Return values
boolcreate()
Create a new outcome (defaults to Account context).
public
static create(array<string, mixed>|CreateOutcomeDTO $data) : self
Parameters
- $data : array<string, mixed>|CreateOutcomeDTO
-
Outcome data
Tags
Return values
selfcreateInContext()
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
Return values
selfdeleteFromContext()
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
Return values
boolfetchByContext()
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
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
Return values
PaginationResultfind()
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
Return values
selfget()
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
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
Return values
array<int, mixed> —Array of alignments
getCalculationMethodDisplayName()
Get the calculation method display name.
public
getCalculationMethodDisplayName() : string
Return values
stringimportFromVendor()
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
Return values
selfisAssessed()
Check if outcome has been assessed.
public
isAssessed() : bool
Return values
boolpaginate()
Get paginated outcomes (defaults to Account context).
public
static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Optional query parameters
Tags
Return values
PaginationResult —Paginated result with metadata
save()
Save the current outcome (create or update).
public
save() : self
Tags
Return values
selfsetApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
update()
Update an existing outcome.
public
update(array<string, mixed>|UpdateOutcomeDTO $data) : self
Parameters
- $data : array<string, mixed>|UpdateOutcomeDTO
-
Update data
Tags
Return values
selfvalidateRatings()
Validate rating scale.
public
validateRatings() : bool
Return values
boolcastValue()
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 endpoint for this resource.
protected
static getEndpoint() : string
Tags
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>