-
Notifications
You must be signed in to change notification settings - Fork 2
AB#107743 add submission create method #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
7e811eb
8d6de91
9747836
f1592cd
f957dd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,9 @@ | |
|
|
||
| import edu.ksu.canvas.model.Progress; | ||
| import edu.ksu.canvas.model.assignment.Submission; | ||
| import edu.ksu.canvas.net.Response; | ||
| import edu.ksu.canvas.requestOptions.MultipleSubmissionsOptions; | ||
| import edu.ksu.canvas.requestOptions.SubmissionOptions; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Optional; | ||
|
|
@@ -29,4 +31,13 @@ public interface SubmissionWriter extends CanvasWriter<Submission, SubmissionWri | |
| * @throws IOException If there is an error talking to Canvas | ||
| */ | ||
| public Optional<Progress> gradeMultipleSubmissionsByCourse(MultipleSubmissionsOptions options) throws IOException; | ||
|
|
||
| /** | ||
| * Submit an assignment on behalf of a student. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While it can submit on behalf of a student, it only does that if you set the optional |
||
| * | ||
| * @param options Parameters object containing parameters such as: userId, submissionType, url, textComment. | ||
| * @return The response from Canvas | ||
| * @throws IOException If there is an error talking to Canvas | ||
| */ | ||
| Response submitAssignment(SubmissionOptions options) throws IOException; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package edu.ksu.canvas.requestOptions; | ||
|
|
||
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
| /** | ||
| * Submission options to submit an assignment on behalf of a user. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While it can submit on behalf of a student, it only does that if you set the optional |
||
| * <p> | ||
| * See <a href="https://canvas.instructure.com/doc/api/submissions.html#method.submissions.create">Submit an Assignment</a> | ||
| * for more details. | ||
| */ | ||
| public class SubmissionOptions extends BaseOptions { | ||
| private final String courseId; | ||
| private final String assignmentId; | ||
|
|
||
| public SubmissionOptions(String courseId, String assignmentId) { | ||
|
sebastianchristopher marked this conversation as resolved.
|
||
| if (StringUtils.isBlank(courseId)) { | ||
| throw new IllegalArgumentException("courseId must not be null or blank"); | ||
| } | ||
| if (StringUtils.isBlank(assignmentId)) { | ||
| throw new IllegalArgumentException("assignmentId must not be null or blank"); | ||
| } | ||
| this.courseId = courseId; | ||
| this.assignmentId = assignmentId; | ||
| } | ||
|
|
||
| public SubmissionOptions userId(String parameter) { | ||
| addSingleItem("submission[user_id]", parameter); | ||
| return this; | ||
| } | ||
|
|
||
| public SubmissionOptions url(String parameter) { | ||
| addSingleItem("submission[url]", parameter); | ||
| return this; | ||
| } | ||
|
|
||
| public SubmissionOptions textComment(String parameter) { | ||
| addSingleItem("comment[text_comment]", parameter); | ||
| return this; | ||
| } | ||
|
|
||
| public SubmissionOptions submissionType(String parameter) { | ||
| addSingleItem("submission[submission_type]", parameter); | ||
| return this; | ||
| } | ||
|
|
||
| public String getCourseId() { return courseId; } | ||
| public String getAssignmentId() { return assignmentId; } | ||
|
|
||
| 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); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems strange as normally I'd expect the URL to point to the external tool. |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.