Documentation

RubricAssociation extends AbstractBaseApi
in package

RubricAssociation Class

Represents the association between a rubric and an assessable item in Canvas LMS. RubricAssociations link rubrics to assignments, discussions, or other contexts and define how the rubric is used for grading.

Usage:

// Set course context first
$course = Course::find(123);
RubricAssociation::setCourse($course);

// Creating a rubric association (using array)
$association = RubricAssociation::create([
    'rubricId' => 123,
    'associationId' => 456,
    'associationType' => 'Assignment',
    'useForGrading' => true
]);

// Creating using DTO (still supported)
$dto = new CreateRubricAssociationDTO();
$dto->rubricId = 123;
$dto->associationId = 456;
$dto->associationType = 'Assignment';
$dto->useForGrading = true;
$association = RubricAssociation::create($dto);

// Updating an association (using array)
$association = RubricAssociation::update(111, [
    'useForGrading' => false
]);

// Updating using DTO (still supported)
$updateDto = new UpdateRubricAssociationDTO();
$updateDto->useForGrading = false;
$association = RubricAssociation::update(111, $updateDto);

Table of Contents

Properties

$associationId  : int|null
The ID of the object this association links to
$associationType  : string|null
The type of object this association links to
$bookmarked  : bool|null
Whether or not the rubric is bookmarked
$contextId  : int|null
The context ID owning the association
$contextType  : string|null
The context type owning the association
$createdAt  : string|null
Created timestamp
$hideOutcomeResults  : bool|null
Whether or not outcome results are hidden
$hidePoints  : bool|null
Whether or not points are hidden
$hideScoreTotal  : bool|null
Whether or not the score total is displayed within the rubric
$id  : int|null
The ID of the association
$purpose  : string|null
Purpose of the association (grading or bookmark)
$rubricId  : int|null
The ID of the rubric
$summaryData  : array<string, mixed>|null
Summary data for the association
$title  : string|null
The title of the object this rubric is associated with
$updatedAt  : string|null
Updated timestamp
$useForGrading  : bool|null
Whether or not the associated rubric is used for grade calculation
$apiClient  : HttpClientInterface
$course  : Course|null
Course context for operations
$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
create()  : self
Create a new rubric association
delete()  : self
Delete a rubric association
find()  : self
Find a rubric association by ID
get()  : array<int, self>
Fetch all rubric associations
paginate()  : PaginationResult
Get paginated results with metadata
rubric()  : Rubric
Get the associated rubric
save()  : self
Save the rubric association (create or update)
setApiClient()  : void
Set the API client
setCourse()  : void
Set the course context for rubric association operations
update()  : self
Update a rubric association
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 API endpoint for this resource Note: RubricAssociation is a nested resource under Rubric
getPaginatedResponse()  : PaginatedResponse
Helper method to get paginated response from API endpoint
getResourceEndpoint()  : string
Get the resource endpoint
getResourceIdentifier()  : string
Get the resource identifier for API endpoints
populate()  : void
Populate the object with new data
toDtoArray()  : array<string|int, mixed>
Convert the object to an array

Properties

$associationId

The ID of the object this association links to

public int|null $associationId = null

$associationType

The type of object this association links to

public string|null $associationType = null

$bookmarked

Whether or not the rubric is bookmarked

public bool|null $bookmarked = null

$contextId

The context ID owning the association

public int|null $contextId = null

$contextType

The context type owning the association

public string|null $contextType = null

$hideOutcomeResults

Whether or not outcome results are hidden

public bool|null $hideOutcomeResults = null

$hidePoints

Whether or not points are hidden

public bool|null $hidePoints = null

$hideScoreTotal

Whether or not the score total is displayed within the rubric

public bool|null $hideScoreTotal = null

$purpose

Purpose of the association (grading or bookmark)

public string|null $purpose = null

$summaryData

Summary data for the association

public array<string, mixed>|null $summaryData = null

$title

The title of the object this rubric is associated with

public string|null $title = null

$useForGrading

Whether or not the associated rubric is used for grade calculation

public bool|null $useForGrading = 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>

find()

Find a rubric association by ID

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

Note: Canvas API does not support fetching individual rubric associations

Parameters
$id : int

The association ID

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

Optional query parameters

Tags
throws
CanvasApiException
Return values
self

get()

Fetch all rubric associations

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

Note: Canvas API does not support listing all rubric associations directly

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

Query parameters

Tags
throws
CanvasApiException
Return values
array<int, self>

setCourse()

Set the course context for rubric association operations

public static setCourse(Course|null $course) : void
Parameters
$course : Course|null

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 API endpoint for this resource Note: RubricAssociation is a nested resource under Rubric

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

getResourceIdentifier()

Get the resource identifier for API endpoints

protected static getResourceIdentifier() : string
Return values
string

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