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
$createdAt
Created timestamp
public
string|null
$createdAt
= 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
$id
The ID of the association
public
int|null
$id
= null
$purpose
Purpose of the association (grading or bookmark)
public
string|null
$purpose
= null
$rubricId
The ID of the rubric
public
int|null
$rubricId
= 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
$updatedAt
Updated timestamp
public
string|null
$updatedAt
= null
$useForGrading
Whether or not the associated rubric is used for grade calculation
public
bool|null
$useForGrading
= null
$apiClient
protected
static HttpClientInterface
$apiClient
= null
$course
Course context for operations
protected
static Course|null
$course
= 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>create()
Create a new rubric association
public
static create(array<string, mixed>|CreateRubricAssociationDTO $data) : self
Parameters
- $data : array<string, mixed>|CreateRubricAssociationDTO
-
The association data
Tags
Return values
selfdelete()
Delete a rubric association
public
delete() : self
Tags
Return values
selffind()
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
Return values
selfget()
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
Return values
array<int, self>paginate()
Get paginated results with metadata
public
static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginationResultrubric()
Get the associated rubric
public
rubric() : Rubric
Tags
Return values
Rubricsave()
Save the rubric association (create or update)
public
save() : self
Tags
Return values
selfsetApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
setCourse()
Set the course context for rubric association operations
public
static setCourse(Course|null $course) : void
Parameters
- $course : Course|null
update()
Update a rubric association
public
static update(int $id, array<string, mixed>|UpdateRubricAssociationDTO $data) : self
Parameters
- $id : int
-
The association ID
- $data : array<string, mixed>|UpdateRubricAssociationDTO
-
The 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
PaginationResultgetEndpoint()
Get the API endpoint for this resource Note: RubricAssociation is a nested resource under Rubric
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
PaginatedResponsegetResourceEndpoint()
Get the resource endpoint
protected
static getResourceEndpoint() : string
Tags
Return values
stringgetResourceIdentifier()
Get the resource identifier for API endpoints
protected
static getResourceIdentifier() : string
Return values
stringpopulate()
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>