Documentation

OutcomeImport extends AbstractBaseApi

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

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

$learningOutcomeGroupId

public int|null $learningOutcomeGroupId = null

$processingErrors

public array<int, array{0: int, 1: string}>|null $processingErrors = 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>

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

generateCsvTemplate()

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

getProgressPercentage()

Get the progress percentage.

public getProgressPercentage() : float
Return values
float

getStatus()

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

hasErrors()

Check if there are any processing errors.

public hasErrors() : bool
Return values
bool

hasFailed()

Check if the import failed.

public hasFailed() : bool
Return values
bool

import()

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

importDataToContext()

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

importFromData()

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

importToContext()

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

isComplete()

Check if the import is complete.

public isComplete() : bool
Return values
bool

isProcessing()

Check if the import is currently processing.

public isProcessing() : bool
Return values
bool

isSuccessful()

Check if the import succeeded.

public isSuccessful() : bool
Return values
bool

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

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>

formatRatings()

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