AB#107743 add submission create method#72
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds functionality to submit an assignment on behalf of a student through the Canvas API. The implementation follows Canvas's "Submit an Assignment" API endpoint and integrates it into the existing submission handling infrastructure.
Key changes:
- Adds a new
SubmissionOptionsrequest options class for configuring submission parameters - Extends the
SubmissionWriterinterface with asubmitAssignmentmethod - Implements the submission logic in
SubmissionImplusing the Canvas API
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| SubmissionOptions.java | New options class for submission parameters with builder-style methods and URL helper |
| SubmissionWriter.java | Adds interface method for submitting assignments, returning raw Response |
| SubmissionImpl.java | Implements the submission logic by constructing URL and calling Canvas API |
| BaseImpl.java | Adds convenience overload of buildCanvasUrl without parameters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/edu/ksu/canvas/requestOptions/SubmissionOptions.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| public Optional<Progress> gradeMultipleSubmissionsByCourse(MultipleSubmissionsOptions options) throws IOException; | ||
|
|
||
| /** | ||
| * Submit an assignment on behalf of a student. |
There was a problem hiding this comment.
While it can submit on behalf of a student, it only does that if you set the optional user_id
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
| /** | ||
| * Submission options to submit an assignment on behalf of a user. |
There was a problem hiding this comment.
While it can submit on behalf of a student, it only does that if you set the optional user_id
| public SubmissionOptions useAssignmentLaunchUrl(String canvasBaseUrl) { | ||
| if (canvasBaseUrl == null || StringUtils.isBlank(canvasBaseUrl)) { | ||
| throw new IllegalArgumentException("canvasBaseUrl must not be blank"); | ||
| } | ||
| String launchUrl = canvasBaseUrl + "/courses/" + courseId + "/assignments/" + assignmentId; | ||
| return this.url(launchUrl); | ||
| } |
There was a problem hiding this comment.
This seems strange as normally I'd expect the URL to point to the external tool.
Implementing this to allow us to post submissions from signup-assignments