SubmissionComment
extends AbstractBaseApi
in package
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
$comment
The comment text content
public
string|null
$comment
= 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
$id
Comment unique identifier
public
int|null
$id
= null
$mediaComment
Media comment data (audio/video comment information)
public
array<string|int, mixed>|null
$mediaComment
= null
$apiClient
protected
static HttpClientInterface
$apiClient
= null
$assignment
Assignment context (required)
protected
static Assignment
$assignment
= null
$course
Course context (required)
protected
static Course
$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']]
$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
__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
Return values
boolcheckContexts()
Check if all contexts are set
public
static checkContexts() : bool
Tags
Return values
boolcheckCourse()
Check if course context is set
public
static checkCourse() : bool
Tags
Return values
boolcheckUserId()
Check if user ID context is set
public
static checkUserId() : bool
Tags
Return values
boolclearContext()
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
Return values
selffind()
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
Return values
staticget()
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
Return values
array<string|int, self>getAuthor()
public
getAuthor() : object|null
Return values
object|nullgetAuthorId()
public
getAuthorId() : int|null
Return values
int|nullgetAuthorName()
public
getAuthorName() : string|null
Return values
string|nullgetComment()
public
getComment() : string|null
Return values
string|nullgetCreatedAt()
public
getCreatedAt() : string|null
Return values
string|nullgetEditedAt()
public
getEditedAt() : string|null
Return values
string|nullgetId()
public
getId() : int|null
Return values
int|nullgetMediaComment()
public
getMediaComment() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullpaginate()
Get paginated results with metadata
public
static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginationResultsave()
Save the comment (update only)
public
save() : self
Tags
Return values
selfsetApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
setAssignment()
Set the assignment context
public
static setAssignment(Assignment $assignment) : void
Parameters
- $assignment : Assignment
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
setCourse()
Set the course context
public
static setCourse(Course $course) : void
Parameters
- $course : Course
setCreatedAt()
public
setCreatedAt(string|null $createdAt) : void
Parameters
- $createdAt : string|null
setEditedAt()
public
setEditedAt(string|null $editedAt) : void
Parameters
- $editedAt : string|null
setId()
public
setId(int|null $id) : void
Parameters
- $id : int|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
update()
Update an existing submission comment
public
static update(int $commentId, array<string, mixed>|UpdateSubmissionCommentDTO $data) : self
Parameters
- $commentId : int
- $data : array<string, mixed>|UpdateSubmissionCommentDTO
Tags
Return values
selfuploadFile()
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
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
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: SubmissionComment is a nested resource under Submission
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
PaginatedResponsepopulate()
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>