Documentation

SubmissionComment extends AbstractBaseApi

Canvas LMS Submission Comments API

Provides functionality to manage submission comments in Canvas LMS. This class handles updating and deleting submission comments for specific submissions. Requires Course, Assignment, and User ID context for all operations.

Note: Creating submission comments is typically done through the Submission API when creating or updating submissions. This class handles standalone comment operations.

Usage Examples:

// Set triple context (required for all operations)
$course = Course::find(123);
$assignment = Assignment::find(456);
SubmissionComment::setCourse($course);
SubmissionComment::setAssignment($assignment);
SubmissionComment::setUserId(789); // The submission user ID

// Update an existing comment
$updatedComment = SubmissionComment::update(101, [
    'text_comment' => 'Updated comment text'
]);

// Delete a comment
$success = SubmissionComment::delete(101);

// Upload a file to a comment
$fileData = [
    'name' => 'feedback.pdf',
    'size' => 1024000,
    'content_type' => 'application/pdf',
    'parent_folder_path' => '/submission_comments'
];
$fileInfo = SubmissionComment::uploadFile($fileData);

Table of Contents

Properties

$author  : object|null
Author user object (contains display information)
$authorId  : int|null
ID of the user who authored this comment
$authorName  : string|null
Name of the user who authored this comment
$comment  : string|null
The comment text content
$createdAt  : string|null
Date and time when comment was created
$editedAt  : string|null
Date and time when comment was last edited
$id  : int|null
Comment unique identifier
$mediaComment  : array<string|int, mixed>|null
Media comment data (audio/video comment information)
$apiClient  : HttpClientInterface
$assignment  : Assignment
Assignment context (required)
$course  : Course
Course context (required)
$methodAliases  : array<string|int, mixed>
Define method aliases
$userId  : int
User ID context (required) - the user whose submission this comment belongs to

Methods

__callStatic()  : mixed
Magic method to handle function aliases
__construct()  : mixed
BaseApi constructor.
all()  : array<string|int, static>
Get all pages of results
checkAssignment()  : bool
Check if assignment context is set
checkContexts()  : bool
Check if all contexts are set
checkCourse()  : bool
Check if course context is set
checkUserId()  : bool
Check if user ID context is set
clearContext()  : void
Clear static contexts to prevent memory leaks in long-running processes
delete()  : self
Delete a submission comment
find()  : static
Find a submission comment by ID (required by ApiInterface) Note: Canvas API doesn't provide a direct endpoint for individual comment retrieval
get()  : array<string|int, self>
Fetch all submission comments (required by ApiInterface) Note: Canvas API doesn't provide a direct endpoint for listing comments independently
getAuthor()  : object|null
getAuthorId()  : int|null
getAuthorName()  : string|null
getComment()  : string|null
getCreatedAt()  : string|null
getEditedAt()  : string|null
getId()  : int|null
getMediaComment()  : array<string|int, mixed>|null
paginate()  : PaginationResult
Get paginated results with metadata
save()  : self
Save the comment (update only)
setApiClient()  : void
Set the API client
setAssignment()  : void
Set the assignment context
setAuthor()  : void
setAuthorId()  : void
setAuthorName()  : void
setComment()  : void
setCourse()  : void
Set the course context
setCreatedAt()  : void
setEditedAt()  : void
setId()  : void
setMediaComment()  : void
setUserId()  : void
Set the user ID context (the submission owner)
update()  : self
Update an existing submission comment
uploadFile()  : array<string, mixed>
Upload a file to attach to a submission comment
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: SubmissionComment is a nested resource under Submission
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

$author

Author user object (contains display information)

public object|null $author = null

$authorId

ID of the user who authored this comment

public int|null $authorId = null

$authorName

Name of the user who authored this comment

public string|null $authorName = null

$createdAt

Date and time when comment was created

public string|null $createdAt = null

$editedAt

Date and time when comment was last edited

public string|null $editedAt = null

$mediaComment

Media comment data (audio/video comment information)

public array<string|int, mixed>|null $mediaComment = 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']]

$userId

User ID context (required) - the user whose submission this comment belongs to

protected static int $userId = null

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>

checkAssignment()

Check if assignment context is set

public static checkAssignment() : bool
Tags
throws
Exception
Return values
bool

checkContexts()

Check if all contexts are set

public static checkContexts() : bool
Tags
throws
Exception
Return values
bool

checkCourse()

Check if course context is set

public static checkCourse() : bool
Tags
throws
Exception
Return values
bool

checkUserId()

Check if user ID context is set

public static checkUserId() : bool
Tags
throws
Exception
Return values
bool

clearContext()

Clear static contexts to prevent memory leaks in long-running processes

public static clearContext() : void

delete()

Delete a submission comment

public static delete(int $commentId) : self
Parameters
$commentId : int
Tags
throws
CanvasApiException
throws
Exception
Return values
self

find()

Find a submission comment by ID (required by ApiInterface) Note: Canvas API doesn't provide a direct endpoint for individual comment retrieval

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

Optional query parameters

Tags
throws
Exception
Return values
static

get()

Fetch all submission comments (required by ApiInterface) Note: Canvas API doesn't provide a direct endpoint for listing comments independently

public static get([array<string, mixed> $params = [] ]) : array<string|int, self>
Parameters
$params : array<string, mixed> = []
Tags
throws
Exception
Return values
array<string|int, self>

getAuthorName()

public getAuthorName() : string|null
Return values
string|null

getCreatedAt()

public getCreatedAt() : string|null
Return values
string|null

getMediaComment()

public getMediaComment() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

setAuthor()

public setAuthor(object|null $author) : void
Parameters
$author : object|null

setAuthorId()

public setAuthorId(int|null $authorId) : void
Parameters
$authorId : int|null

setAuthorName()

public setAuthorName(string|null $authorName) : void
Parameters
$authorName : string|null

setComment()

public setComment(string|null $comment) : void
Parameters
$comment : string|null

setCreatedAt()

public setCreatedAt(string|null $createdAt) : void
Parameters
$createdAt : string|null

setEditedAt()

public setEditedAt(string|null $editedAt) : void
Parameters
$editedAt : string|null

setMediaComment()

public setMediaComment(array<string|int, mixed>|null $mediaComment) : void
Parameters
$mediaComment : array<string|int, mixed>|null

setUserId()

Set the user ID context (the submission owner)

public static setUserId(int $userId) : void
Parameters
$userId : int

uploadFile()

Upload a file to attach to a submission comment

public static uploadFile(array<string, mixed> $fileData) : array<string, mixed>
Parameters
$fileData : array<string, mixed>

File upload data

Tags
throws
CanvasApiException
throws
Exception
Return values
array<string, mixed>

File upload response

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: SubmissionComment is a nested resource under Submission

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