OutcomeGroup
extends AbstractBaseApi
in package
OutcomeGroup API class for managing hierarchical outcome groups in Canvas LMS.
Outcome groups organize learning outcomes in a hierarchical structure, allowing for categorization and management of related outcomes.
Tags
Table of Contents
Properties
- $canEdit : bool|null
- $contextId : int|null
- $contextType : string|null
- $description : string|null
- $id : int|null
- $importsUrl : string|null
- $outcomesCount : int|null
- $outcomesUrl : string|null
- $parentOutcomeGroupId : int|null
- $subgroupsCount : int|null
- $subgroupsUrl : string|null
- $title : string|null
- $url : string|null
- $vendorGuid : string|null
- $methodAliases : array<string, array<string|int, string>>
- 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 this group can be edited.
- create() : self
- Create a new outcome group (defaults to Account context).
- createGlobal() : self
- Create a new global outcome group.
- createInContext() : self
- Create a new outcome group in a specific context.
- createOutcome() : OutcomeLink
- Create a new outcome in this group.
- createSubgroup() : self
- Create a subgroup within this group.
- delete() : self
- Delete an outcome group.
- fetchAllLinks() : array<int, OutcomeLink>
- Fetch all outcome links for a context (defaults to Account).
- fetchAllLinksByContext() : array<int, OutcomeLink>
- Fetch all outcome links for a specific context.
- fetchAllLinksPaginated() : PaginationResult
- Fetch paginated outcome links (defaults to Account context).
- fetchByContext() : array<int, OutcomeGroup>
- Fetch outcome groups by specific context.
- fetchByContextPaginated() : PaginationResult
- Fetch paginated outcome groups by specific context.
- fetchGlobal() : array<int, OutcomeGroup>
- Fetch global outcome groups.
- find() : static
- Find a specific outcome group by ID (defaults to Account context).
- findByContext() : static
- Find a specific outcome group by ID within a context.
- findGlobal() : static
- Find a specific global outcome group by ID.
- get() : array<int, OutcomeGroup>
- Get first page of outcome groups (defaults to Account context).
- getGlobalRootGroup() : self
- Get the global root outcome group.
- getHierarchyPath() : array<int, OutcomeGroup>
- Get the full hierarchy path from root to this group.
- getRootGroup() : self
- Get the global/root outcome group for a context.
- importOutcomes() : array<string, mixed>
- Import outcomes from external source.
- linkOutcome() : OutcomeLink
- Link an existing outcome to this group.
- outcomes() : array<int, OutcomeLink>
- Get outcomes in this outcome group.
- overrideApiClient() : void
- Set an API client for this class only, leaving other resources on the shared default.
- paginate() : PaginationResult
- Get paginated outcome groups (defaults to Account context).
- resetApiClients() : void
- Clear the shared default client and all per-class overrides.
- setApiClient() : void
- Set the shared default API client used by ALL resource classes.
- stream() : Generator<int, static>
- Stream all items across all pages one at a time.
- subgroups() : array<int, OutcomeGroup>
- Get subgroups of this outcome group.
- unlinkOutcome() : bool
- Unlink an outcome from this group.
- update() : self
- Update an existing outcome group.
- 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
- getAliasMap() : array<string, string>
- Build a flat alias-to-method lookup from $methodAliases.
- getApiClient() : HttpClientInterface
- Get the API client, initializing if necessary
- getEndpoint() : string
- Get the API endpoint for this resource
- getPaginatedResponse() : PaginatedResponse
- Helper method to get paginated response from API endpoint
- hydrate() : void
- Assign API response data to properties with type coercion.
- parseJsonResponse() : array<string|int, mixed>
- Parse JSON response from API safely handling StreamInterface
- populate() : void
- Populate the object with new data
- toDtoArray() : array<string|int, mixed>
- Convert the object to an array
- validateContext() : void
- Validate a context type path segment against an allowlist.
- fetchAllLinksByContextPaginated() : PaginatedResponse
- Fetch paginated outcome links for a specific context.
Properties
$canEdit
public
bool|null
$canEdit
= null
$contextId
public
int|null
$contextId
= null
$contextType
public
string|null
$contextType
= null
$description
public
string|null
$description
= null
$id
public
int|null
$id
= null
$importsUrl
public
string|null
$importsUrl
= null
$outcomesCount
public
int|null
$outcomesCount
= null
$outcomesUrl
public
string|null
$outcomesUrl
= null
$parentOutcomeGroupId
public
int|null
$parentOutcomeGroupId
= null
$subgroupsCount
public
int|null
$subgroupsCount
= null
$subgroupsUrl
public
string|null
$subgroupsUrl
= null
$title
public
string|null
$title
= null
$url
public
string|null
$url
= null
$vendorGuid
public
string|null
$vendorGuid
= null
$methodAliases
Define method aliases
protected
static array<string, array<string|int, string>>
$methodAliases
= ['get' => ['fetch', 'list'], 'all' => ['fetchAllPages', 'getAll', 'fetchAll'], 'paginate' => ['getPaginated', 'withPagination'], '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 this group can be edited.
public
canEdit() : bool
Return values
boolcreate()
Create a new outcome group (defaults to Account context).
public
static create(array<string, mixed>|CreateOutcomeGroupDTO $data[, int|null $parentGroupId = null ]) : self
Parameters
- $data : array<string, mixed>|CreateOutcomeGroupDTO
-
Outcome group data
- $parentGroupId : int|null = null
-
Parent group ID (null for root level)
Tags
Return values
selfcreateGlobal()
Create a new global outcome group.
public
static createGlobal(array<string, mixed>|CreateOutcomeGroupDTO $data[, int|null $parentGroupId = null ]) : self
Parameters
- $data : array<string, mixed>|CreateOutcomeGroupDTO
-
Outcome group data
- $parentGroupId : int|null = null
-
Parent group ID (null for root level)
Tags
Return values
selfcreateInContext()
Create a new outcome group in a specific context.
public
static createInContext(string $contextType, int $contextId, array<string, mixed>|CreateOutcomeGroupDTO $data[, int|null $parentGroupId = null ]) : self
Parameters
- $contextType : string
-
Context type (accounts, courses)
- $contextId : int
-
Context ID
- $data : array<string, mixed>|CreateOutcomeGroupDTO
-
Outcome group data
- $parentGroupId : int|null = null
-
Parent group ID (null for root level)
Tags
Return values
selfcreateOutcome()
Create a new outcome in this group.
public
createOutcome(array<string, mixed>|CreateOutcomeDTO $data) : OutcomeLink
Parameters
- $data : array<string, mixed>|CreateOutcomeDTO
-
Outcome data
Tags
Return values
OutcomeLinkcreateSubgroup()
Create a subgroup within this group.
public
createSubgroup(array<string, mixed>|CreateOutcomeGroupDTO $data) : self
Parameters
- $data : array<string, mixed>|CreateOutcomeGroupDTO
-
Subgroup data
Tags
Return values
selfdelete()
Delete an outcome group.
public
delete() : self
Tags
Return values
selffetchAllLinks()
Fetch all outcome links for a context (defaults to Account).
public
static fetchAllLinks([array<string, mixed> $params = [] ]) : array<int, OutcomeLink>
Returns ALL outcome links across ALL groups in the context.
Parameters
- $params : array<string, mixed> = []
-
Optional query parameters
Tags
Return values
array<int, OutcomeLink> —Array of OutcomeLink objects
fetchAllLinksByContext()
Fetch all outcome links for a specific context.
public
static fetchAllLinksByContext(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : array<int, OutcomeLink>
Returns ALL outcome links across ALL groups in the context.
Parameters
- $contextType : string
-
Context type (accounts, courses)
- $contextId : int
-
Context ID
- $params : array<string, mixed> = []
-
Optional query parameters
Tags
Return values
array<int, OutcomeLink> —Array of OutcomeLink objects
fetchAllLinksPaginated()
Fetch paginated outcome links (defaults to Account context).
public
static fetchAllLinksPaginated([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Optional query parameters
Tags
Return values
PaginationResultfetchByContext()
Fetch outcome groups by specific context.
public
static fetchByContext(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : array<int, OutcomeGroup>
Parameters
- $contextType : string
-
Context type (accounts, courses)
- $contextId : int
-
Context ID
- $params : array<string, mixed> = []
-
Optional query parameters
Tags
Return values
array<int, OutcomeGroup> —Array of OutcomeGroup objects
fetchByContextPaginated()
Fetch paginated outcome groups 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
PaginationResultfetchGlobal()
Fetch global outcome groups.
public
static fetchGlobal([array<string, mixed> $params = [] ]) : array<int, OutcomeGroup>
Parameters
- $params : array<string, mixed> = []
-
Optional query parameters
Tags
Return values
array<int, OutcomeGroup> —Array of OutcomeGroup objects
find()
Find a specific outcome group by ID (defaults to Account context).
public
static find(int $id[, array<string|int, mixed> $params = [] ]) : static
Parameters
- $id : int
-
Outcome group ID
- $params : array<string|int, mixed> = []
-
Optional query parameters
Tags
Return values
staticfindByContext()
Find a specific outcome group by ID within a context.
public
static findByContext(string|null $contextType, int|null $contextId, int $id) : static
Parameters
- $contextType : string|null
-
Context type (accounts, courses) or null for global
- $contextId : int|null
-
Context ID or null for global
- $id : int
-
Outcome group ID
Tags
Return values
staticfindGlobal()
Find a specific global outcome group by ID.
public
static findGlobal(int $id) : static
Parameters
- $id : int
-
Outcome group ID
Tags
Return values
staticget()
Get first page of outcome groups (defaults to Account context).
public
static get([array<string, mixed> $params = [] ]) : array<int, OutcomeGroup>
Parameters
- $params : array<string, mixed> = []
-
Optional query parameters
Tags
Return values
array<int, OutcomeGroup> —Array of OutcomeGroup objects
getGlobalRootGroup()
Get the global root outcome group.
public
static getGlobalRootGroup() : self
Tags
Return values
selfgetHierarchyPath()
Get the full hierarchy path from root to this group.
public
getHierarchyPath() : array<int, OutcomeGroup>
Tags
Return values
array<int, OutcomeGroup> —Array of parent groups
getRootGroup()
Get the global/root outcome group for a context.
public
static getRootGroup(string $contextType, int $contextId) : self
Parameters
- $contextType : string
-
Context type (accounts, courses)
- $contextId : int
-
Context ID
Tags
Return values
selfimportOutcomes()
Import outcomes from external source.
public
importOutcomes(array<string, mixed> $importData) : array<string, mixed>
Parameters
- $importData : array<string, mixed>
-
Import configuration
Tags
Return values
array<string, mixed> —Import status
linkOutcome()
Link an existing outcome to this group.
public
linkOutcome(int $outcomeId[, int|null $moveFrom = null ]) : OutcomeLink
Parameters
- $outcomeId : int
-
Outcome ID to link
- $moveFrom : int|null = null
-
Optional group ID to move the outcome from
Tags
Return values
OutcomeLinkoutcomes()
Get outcomes in this outcome group.
public
outcomes([array<string, mixed> $params = [] ]) : array<int, OutcomeLink>
Parameters
- $params : array<string, mixed> = []
-
Optional query parameters
Tags
Return values
array<int, OutcomeLink> —Array of OutcomeLink objects
overrideApiClient()
Set an API client for this class only, leaving other resources on the shared default.
public
static overrideApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
paginate()
Get paginated outcome groups (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
resetApiClients()
Clear the shared default client and all per-class overrides.
public
static resetApiClients() : void
setApiClient()
Set the shared default API client used by ALL resource classes.
public
static setApiClient(HttpClientInterface $apiClient) : void
Calling this on any resource (e.g. Course::setApiClient()) replaces the client for every resource, because relationship methods cross class boundaries ($course->enrollments() calls Enrollment internally). Use overrideApiClient() to scope a client to a single class, and resetApiClients() in test teardown to avoid state leaking.
Parameters
- $apiClient : HttpClientInterface
stream()
Stream all items across all pages one at a time.
public
static stream([array<string|int, mixed> $params = [] ]) : Generator<int, static>
Unlike all(), only one page of raw data is held in memory at a time, making this safe for very large datasets (e.g. tens of thousands of enrollments):
foreach (User::stream(['per_page' => 100]) as $user) {
processUser($user);
}
Parameters
- $params : array<string|int, mixed> = []
-
Query parameters for the request
Tags
Return values
Generator<int, static>subgroups()
Get subgroups of this outcome group.
public
subgroups([array<string, mixed> $params = [] ]) : array<int, OutcomeGroup>
Parameters
- $params : array<string, mixed> = []
-
Optional query parameters
Tags
Return values
array<int, OutcomeGroup> —Array of OutcomeGroup objects
unlinkOutcome()
Unlink an outcome from this group.
public
unlinkOutcome(int $outcomeId) : bool
Parameters
- $outcomeId : int
-
Outcome ID to unlink
Tags
Return values
boolupdate()
Update an existing outcome group.
public
update(array<string, mixed>|UpdateOutcomeGroupDTO $data) : self
Parameters
- $data : array<string, mixed>|UpdateOutcomeGroupDTO
-
Update data
Tags
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
PaginationResultgetAliasMap()
Build a flat alias-to-method lookup from $methodAliases.
protected
static getAliasMap() : array<string, string>
Return values
array<string, string>getApiClient()
Get the API client, initializing if necessary
protected
static getApiClient() : HttpClientInterface
Return values
HttpClientInterfacegetEndpoint()
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
PaginatedResponsehydrate()
Assign API response data to properties with type coercion.
protected
hydrate(array<string|int, mixed> $data) : void
Shared by the constructor and populate() so objects keep the same type guarantees after save()/update() round-trips as on creation.
Parameters
- $data : array<string|int, mixed>
parseJsonResponse()
Parse JSON response from API safely handling StreamInterface
protected
static parseJsonResponse(ResponseInterface $response) : array<string|int, mixed>
Parameters
- $response : ResponseInterface
Return values
array<string|int, mixed>populate()
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>
Return values
array<string|int, mixed>validateContext()
Validate a context type path segment against an allowlist.
protected
static validateContext(string|null $contextType, array<int, string> $allowed) : void
Context types are interpolated into URL paths; validating against the contexts Canvas actually supports prevents crafted values from injecting extra path segments or query parameters.
Parameters
- $contextType : string|null
-
The context type (plural, e.g. 'courses'); null is ignored
- $allowed : array<int, string>
-
Allowed context types
Tags
fetchAllLinksByContextPaginated()
Fetch paginated outcome links for a specific context.
private
static fetchAllLinksByContextPaginated(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $contextType : string
-
Context type (accounts, courses)
- $contextId : int
-
Context ID
- $params : array<string, mixed> = []
-
Optional query parameters