Documentation

GradebookHistory extends AbstractBaseApi

GradebookHistory Class

Provides access to the versioned history of student submissions and grade changes in Canvas LMS. This API is essential for academic integrity, grade disputes, and compliance requirements as it provides a complete audit trail of all grading activities.

The Gradebook History API tracks:

  • All grade changes with timestamps
  • Who made each grade change (grader information)
  • Previous and new grade values
  • Date-based organization of grading activities
  • Submission versions and their changes over time

Usage:

// Set the course context
GradebookHistory::setCourse(123);

// Get days with grading activity
$days = GradebookHistory::fetchDays();

// Get details for a specific day
$graders = GradebookHistory::fetchDay('2025-01-15');

// Get detailed submissions for a specific grader, assignment, and date
$submissions = GradebookHistory::fetchSubmissions('2025-01-15', 456, 789);

// Get submission versions feed with pagination
$feed = GradebookHistory::fetchFeedPaginated([
    'assignment_id' => 789,
    'user_id' => 456,
    'ascending' => true
]);

// Access through Course instance
$course = Course::find(123);
$history = $course->gradebookHistory();
$days = $history::fetchDays();
Tags
see
https://canvas.instructure.com/doc/api/gradebook_history.html

Table of Contents

Properties

$apiClient  : HttpClientInterface
$courseId  : int|null
The course ID context for gradebook history 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
fetchAllFeed()  : array<string|int, SubmissionVersion>
Get all submission versions from the feed (memory intensive).
fetchDay()  : array<string|int, GradebookHistoryGrader>
Get details for a specific day in gradebook history.
fetchDays()  : array<string|int, GradebookHistoryDay>
List days with grading activity in the course.
fetchFeed()  : array<string|int, SubmissionVersion>
Get a paginated feed of submission versions.
fetchFeedPaginated()  : PaginatedResponse
Get a paginated feed of submission versions with pagination support.
fetchSubmissions()  : array<string|int, SubmissionHistory>
Get detailed submissions for a specific date, grader, and assignment.
find()  : static
Find a specific resource by ID.
get()  : array<string|int, static>
Get first page of results
getCourse()  : int|null
Get the current course context.
paginate()  : PaginationResult
Get paginated results with metadata
resetCourse()  : void
Reset the course context.
setApiClient()  : void
Set the API client
setCourse()  : void
Set the course context for gradebook history operations.
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
checkCourse()  : void
Check if course context is set and throw exception if not.
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
getApiEndpoint()  : string
Get the API endpoint name for this resource.
getEndpoint()  : string
Get the base endpoint for gradebook history operations.
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

$courseId

The course ID context for gradebook history operations

protected static int|null $courseId = 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>

fetchAllFeed()

Get all submission versions from the feed (memory intensive).

public static fetchAllFeed([array<string, mixed> $params = [] ]) : array<string|int, SubmissionVersion>

This method fetches all pages of submission versions. Use with caution on large datasets as it loads all results into memory.

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

Optional query parameters

Tags
throws
CanvasApiException
Return values
array<string|int, SubmissionVersion>

fetchDay()

Get details for a specific day in gradebook history.

public static fetchDay(string $date[, array<string, mixed> $params = [] ]) : array<string|int, GradebookHistoryGrader>

Returns the graders who worked on this day, along with the assignments they worked on. More details can be obtained by calling fetchSubmissions() with a specific grader and assignment.

Parameters
$date : string

The date in YYYY-MM-DD format

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

Optional query parameters

Tags
throws
CanvasApiException
Return values
array<string|int, GradebookHistoryGrader>

fetchDays()

List days with grading activity in the course.

public static fetchDays([array<string, mixed> $params = [] ]) : array<string|int, GradebookHistoryDay>

Returns a list of dates that have grading activity in this course. The response is ordered by date, descending (newest first).

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

Optional query parameters

Tags
throws
CanvasApiException
Return values
array<string|int, GradebookHistoryDay>

fetchFeed()

Get a paginated feed of submission versions.

public static fetchFeed([array<string, mixed> $params = [] ]) : array<string|int, SubmissionVersion>

Returns a paginated, uncollated list of submission versions for all matching submissions in the course. The SubmissionVersion objects returned by this endpoint will not include the new_grade or previous_grade keys, only the grade; same for graded_at and grader.

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

Optional query parameters:

  • assignment_id (int): Filter by assignment ID
  • user_id (int): Filter by user ID
  • ascending (bool): Return in ascending date order (oldest first)
Tags
throws
CanvasApiException
Return values
array<string|int, SubmissionVersion>

fetchFeedPaginated()

Get a paginated feed of submission versions with pagination support.

public static fetchFeedPaginated([array<string, mixed> $params = [] ]) : PaginatedResponse

Returns a PaginatedResponse containing submission versions and pagination metadata. This is useful for processing large datasets efficiently.

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

Optional query parameters:

  • assignment_id (int): Filter by assignment ID
  • user_id (int): Filter by user ID
  • ascending (bool): Return in ascending date order (oldest first)
  • per_page (int): Number of items per page (default: 10, max: 100)
Tags
throws
CanvasApiException
Return values
PaginatedResponse

fetchSubmissions()

Get detailed submissions for a specific date, grader, and assignment.

public static fetchSubmissions(string $date, int $graderId, int $assignmentId[, array<string, mixed> $params = [] ]) : array<string|int, SubmissionHistory>

Returns a nested list of submission versions for all submissions graded by the specified grader for the specified assignment on the specified date.

Parameters
$date : string

The date in YYYY-MM-DD format

$graderId : int

The ID of the grader

$assignmentId : int

The ID of the assignment

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

Optional query parameters

Tags
throws
CanvasApiException
Return values
array<string|int, SubmissionHistory>

find()

Find a specific resource by ID.

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

Note: Gradebook History API doesn't support finding individual records by ID. This method is required by the interface but not applicable for this resource.

Parameters
$id : int

The ID to search for

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

Optional query parameters

Tags
throws
CanvasApiException
Return values
static

get()

Get first page of results

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

Query parameters

Return values
array<string|int, static>

getCourse()

Get the current course context.

public static getCourse() : int|null
Return values
int|null

resetCourse()

Reset the course context.

public static resetCourse() : void

setCourse()

Set the course context for gradebook history operations.

public static setCourse(int $courseId) : void
Parameters
$courseId : int

The ID of the course

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>

getApiEndpoint()

Get the API endpoint name for this resource.

protected static getApiEndpoint() : string
Return values
string

getEndpoint()

Get the base endpoint for gradebook history operations.

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

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