OutcomeImport
extends AbstractBaseApi
in package
OutcomeImport API class for importing outcome data in bulk.
Outcome imports allow bulk importing of learning outcomes from CSV files or other supported formats into Canvas LMS.
Tags
Table of Contents
Properties
- $createdAt : string|null
- $data : array<string, mixed>|null
- $endedAt : string|null
- $id : int|null
- $learningOutcomeGroupId : int|null
- $processingErrors : array<int, array{0: int, 1: string}>|null
- $progress : string|null
- $updatedAt : string|null
- $user : array<string, mixed>|null
- $workflowState : 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
- buildCsvFromArray() : string
- Build CSV data from an array of outcome definitions.
- find() : static
- Find method - not applicable for imports.
- generateCsvTemplate() : string
- Generate CSV template for outcome import.
- get() : array<int, static>
- FetchAll method - not applicable for imports.
- getErrors() : array<int, mixed>
- Get processing errors if any.
- getFormattedErrors() : array<int, string>
- Get formatted error messages.
- getLatestStatus() : self
- Get the latest import status for account context.
- getProgressPercentage() : float
- Get the progress percentage.
- getStatus() : self
- Get the status of an outcome import.
- hasErrors() : bool
- Check if there are any processing errors.
- hasFailed() : bool
- Check if the import failed.
- import() : self
- Import outcomes from a file (defaults to Account context).
- importDataToContext() : self
- Import outcomes from raw CSV data to a specific context.
- importFromData() : self
- Import outcomes from raw CSV data (defaults to Account context).
- importToContext() : self
- Import outcomes to a specific context.
- isComplete() : bool
- Check if the import is complete.
- isProcessing() : bool
- Check if the import is currently processing.
- isSuccessful() : bool
- Check if the import succeeded.
- paginate() : PaginationResult
- Get paginated results with metadata
- setApiClient() : void
- Set the API client
- waitForCompletion() : self
- Wait for import to complete with polling.
- 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
- formatRatings() : string
- Format ratings array for CSV import.
- 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
$createdAt
public
string|null
$createdAt
= null
$data
public
array<string, mixed>|null
$data
= null
$endedAt
public
string|null
$endedAt
= null
$id
public
int|null
$id
= null
$learningOutcomeGroupId
public
int|null
$learningOutcomeGroupId
= null
$processingErrors
public
array<int, array{0: int, 1: string}>|null
$processingErrors
= null
$progress
public
string|null
$progress
= null
$updatedAt
public
string|null
$updatedAt
= null
$user
public
array<string, mixed>|null
$user
= null
$workflowState
public
string|null
$workflowState
= 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>buildCsvFromArray()
Build CSV data from an array of outcome definitions.
public
static buildCsvFromArray(array<int, array<string, mixed>> $outcomes) : string
Parameters
- $outcomes : array<int, array<string, mixed>>
-
Array of outcome data
Return values
string —CSV formatted string
find()
Find method - not applicable for imports.
public
static find(int $id[, array<string|int, mixed> $params = [] ]) : static
Parameters
- $id : int
- $params : array<string|int, mixed> = []
-
Optional query parameters
Tags
Return values
staticgenerateCsvTemplate()
Generate CSV template for outcome import.
public
static generateCsvTemplate() : string
Return values
string —CSV template with headers
get()
FetchAll method - not applicable for imports.
public
static get([array<string, mixed> $params = [] ]) : array<int, static>
Parameters
- $params : array<string, mixed> = []
Tags
Return values
array<int, static>getErrors()
Get processing errors if any.
public
getErrors() : array<int, mixed>
Return values
array<int, mixed> —Array of [row_number, error_message] pairs
getFormattedErrors()
Get formatted error messages.
public
getFormattedErrors() : array<int, string>
Return values
array<int, string> —Array of formatted error strings
getLatestStatus()
Get the latest import status for account context.
public
static getLatestStatus() : self
Tags
Return values
selfgetProgressPercentage()
Get the progress percentage.
public
getProgressPercentage() : float
Return values
floatgetStatus()
Get the status of an outcome import.
public
static getStatus(string $contextType, int $contextId, int|string $importId) : self
Parameters
- $contextType : string
-
Context type (accounts, courses)
- $contextId : int
-
Context ID
- $importId : int|string
-
Import ID or 'latest' for the most recent import
Tags
Return values
selfhasErrors()
Check if there are any processing errors.
public
hasErrors() : bool
Return values
boolhasFailed()
Check if the import failed.
public
hasFailed() : bool
Return values
boolimport()
Import outcomes from a file (defaults to Account context).
public
static import(string $filePath[, int|null $groupId = null ][, string $importType = 'instructure_csv' ]) : self
Parameters
- $filePath : string
-
Path to the CSV file
- $groupId : int|null = null
-
Optional outcome group ID to import into
- $importType : string = 'instructure_csv'
-
Import type (default: 'instructure_csv')
Tags
Return values
selfimportDataToContext()
Import outcomes from raw CSV data to a specific context.
public
static importDataToContext(string $contextType, int $contextId, string $csvData[, int|null $groupId = null ][, string $importType = 'instructure_csv' ]) : self
Parameters
- $contextType : string
-
Context type (accounts, courses)
- $contextId : int
-
Context ID
- $csvData : string
-
Raw CSV data as string
- $groupId : int|null = null
-
Optional outcome group ID to import into
- $importType : string = 'instructure_csv'
-
Import type (default: 'instructure_csv')
Tags
Return values
selfimportFromData()
Import outcomes from raw CSV data (defaults to Account context).
public
static importFromData(string $csvData[, int|null $groupId = null ][, string $importType = 'instructure_csv' ]) : self
Parameters
- $csvData : string
-
Raw CSV data as string
- $groupId : int|null = null
-
Optional outcome group ID to import into
- $importType : string = 'instructure_csv'
-
Import type (default: 'instructure_csv')
Tags
Return values
selfimportToContext()
Import outcomes to a specific context.
public
static importToContext(string $contextType, int $contextId, string $filePath[, int|null $groupId = null ][, string $importType = 'instructure_csv' ]) : self
Parameters
- $contextType : string
-
Context type (accounts, courses)
- $contextId : int
-
Context ID
- $filePath : string
-
Path to the CSV file
- $groupId : int|null = null
-
Optional outcome group ID to import into
- $importType : string = 'instructure_csv'
-
Import type (default: 'instructure_csv')
Tags
Return values
selfisComplete()
Check if the import is complete.
public
isComplete() : bool
Return values
boolisProcessing()
Check if the import is currently processing.
public
isProcessing() : bool
Return values
boolisSuccessful()
Check if the import succeeded.
public
isSuccessful() : 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
waitForCompletion()
Wait for import to complete with polling.
public
waitForCompletion(string $contextType, int $contextId[, int $maxAttempts = 60 ][, int $delaySeconds = 2 ]) : self
Parameters
- $contextType : string
-
Context type (accounts, courses)
- $contextId : int
-
Context ID
- $maxAttempts : int = 60
-
Maximum polling attempts (default: 60)
- $delaySeconds : int = 2
-
Delay between polls in seconds (default: 2)
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
PaginationResultformatRatings()
Format ratings array for CSV import.
protected
static formatRatings(array<int, mixed> $ratings) : string
Parameters
- $ratings : array<int, mixed>
-
Array of rating definitions
Return values
string —Formatted ratings string
getEndpoint()
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>