.course. assignment

Source:
Functions for interacting with assignments within courses

Methods

(async) create(optsopt, configopt) → {Promise.<CanvasAssignment>}

Source:
Author:
  • Gabe Abrams
Creates a Canvas assignment
Parameters:
Name Type Attributes Description
opts object <optional>
object containing all arguments
Properties
Name Type Attributes Default Description
courseId number <optional>
default course id Canvas course Id to create an assignment in
name string <optional>
Unnamed Assignment The name of the assignment
pointsPossible number <optional>
null Points possible
dueAt date <optional>
null Due at datetime
lockAt date <optional>
null Due at datetime
unlockAt date <optional>
null Due at datetime
description string <optional>
null html description of the assignment
submissionTypes string <optional>
null Submission type(s)
allowedExtensions string <optional>
any List of allowed file extensions (exclude period). Online upload must be enabled
gradingType string <optional>
points Grading type
position number <optional>
last Position in assignment list
published boolean <optional>
If true, publish page upon creation
muted boolean <optional>
If true, assignment is muted
groupSetId number <optional>
null Student group set Id
assignmentGroupId number <optional>
top assignment group Assignment group Id
peerReviewsEnabled boolean <optional>
If true, users asked to submit peer reviews
automaticPeerReviewsEnabled boolean <optional>
If true, Canvas will automatically assign peer reviews
omitFromFinalGrade boolean <optional>
If true, assignment is omitted from the final grade
gradeGroupStudentsIndividually boolean <optional>
If true, students in groups can be given separate grades and when one student in a group gets a grade, other students do not get graded
assignmentAppId string <optional>
null If defined, the external tool that matches this id will be used for submissions. Also, the submission types will be overwritten with ['external_tool'] and the student will be redirected via LTI to the assignmentAppURL when they launch the assignment
assignmentAppURL string <optional>
tool launch url The launch URL of the external tool. If not included and assignmentAppId is defined, we will first request info on the external tool to get its launchURL and will use that value here. Only relevant if assignmentAppId is defined.
assignmentAppNewTab boolean <optional>
Only relevant if assignmentAppId is defined. If true, when a student clicks the assignment, their LTI session with the external tool will be opened in a new tab
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasAssignment>

(async) createOverride(opts, configopt) → {Promise.<CanvasAssignmentOverride>}

Source:
Author:
  • Gabe Abrams
Create assignment override. Note that if any dates (dueAt, unlockAt, or lockAt) are left out, they will be set to "none" for the target(s) of this override. If dueAt is omitted, the target(s) will have no deadline. If unlockAt is omitted, the target(s) will immediately be able to see the assignment (even if everyone else has to wait until the unlockAt date). If lockAt is omitted, the target(s) will be able to submit at any time in the future (even if everyone else can't submit because their lock date has passed). In short, it is not recommended to omit dates that are defined in the assignment.
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment id
courseId number <optional>
default course id Canvas course id
studentIds Array.<number> <optional>
List of Canvas student IDs to override (Note: either studentIds, groupId, or sectionId must be included)
groupId number <optional>
Group to override, must be a group assignment (Note: either studentIds, groupId, or sectionId must be included)
sectionId number <optional>
Section to override (Note: either studentIds, groupId, or sectionId must be included)
title string <optional>
Override for X students Title of the override
dueAt date <optional>
no due date New due date. If excluded, the target(s) of this override have no due date (they can submit whenever they want without being marked as late)
unlockAt date <optional>
no unlock date New unlock date. If excluded, the target(s) of this override can immediately see the assignment (their unlock date is the beginning of time)
lockAt date <optional>
no lock date New lock date. If excluded, the target(s) of this override can see and submit the assignment at any point in the future (their lock date is the end of time)
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasAssignmentOverride>

(async) createSubmissionComment(opts, configopt) → {Promise.<CanvasSubmission>}

Source:
Author:
  • Gabe Abrams
Adds a comment to a submission
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas course Id
studentId number Canvas student Id of the sub to comment on
comment string The text of the comment
courseId number <optional>
default course id Canvas course Id
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasSubmission>

(async) createTextSubmission(opts, configopt) → {Promise.<CanvasSubmission>}

Source:
Author:
  • Gabe Abrams
Creates a text submission on behalf of the current user
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number The Canvas assignment Id
text string The text body of the submission
courseId number <optional>
default course id Canvas course Id
comment string <optional>
A text student comment to include
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasSubmission>

(async) createURLSubmission(opts, configopt) → {Promise.<CanvasSubmission>}

Source:
Author:
  • Gabe Abrams
Creates a url submission on behalf of the current user
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number The Canvas assignment Id
url string The url of the submission
courseId number <optional>
default course id Canvas course Id
comment string <optional>
A text student comment to include
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasSubmission>

(async) delete(opts, configopt) → {Promise.<CanvasAssignment>}

Source:
Author:
  • Gabe Abrams
Delete an assignment
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment Id
courseId number <optional>
default course id Canvas course Id
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasAssignment>

(async) deleteOverride(opts, configopt) → {Promise.<CanvasAssignmentOverride>}

Source:
Author:
  • Gabe Abrams
Deletes an assignment override
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment id to query
overrideId number Canvas override id to look up
courseId number <optional>
default course id Canvas course id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasAssignmentOverride>

(async) get(opts, configopt) → {Promise.<CanvasAssignment>}

Source:
Author:
  • Gabe Abrams
Get info on a specific assignment in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment Id
courseId number <optional>
default course id Canvas course Id to query
ignoreOverridesForDates boolean <optional>
if true, assignment dates are taken from the default dates instead of from the ones in overrides
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasAssignment>

(async) getOverride(opts, configopt) → {Promise.<CanvasAssignmentOverride>}

Source:
Author:
  • Gabe Abrams
Get a specific override on an assignment in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment id to query
overrideId number Canvas override id to look up
courseId number <optional>
default course id Canvas course id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasAssignmentOverride>

(async) getSubmission(opts, configopt) → {Promise.<CanvasSubmission>}

Source:
Author:
  • Gabe Abrams
Gets a single submission for an assignment
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number The Canvas assignment Id
studentId number The Canvas student Id
courseId number <optional>
default course id Canvas course Id
includeComments boolean <optional>
If truthy, includes all comments on submissions
includeRubricAssessment boolean <optional>
If truthy, includes rubric assessments: breakdown of score for each rubric item
excludeUser boolean <optional>
If truthy, excludes submission[i].user value with the submission's user information
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasSubmission>

(async) list(optsopt, configopt) → {Promise.<Array.<CanvasAssignment>>}

Source:
Author:
  • Gabe Abrams
Lists the assignments in a course
Parameters:
Name Type Attributes Description
opts object <optional>
object containing all arguments
Properties
Name Type Attributes Default Description
courseId number <optional>
default course id Canvas course Id to query
ignoreOverridesForDates boolean <optional>
if true, assignment dates are taken from the default dates instead of from the ones in overrides
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<Array.<CanvasAssignment>>

(async) listAllSubmissions(optsopt, configopt) → {Promise.<Array.<CanvasSubmission>>}

Source:
Author:
  • Gabe Abrams
Lists the submissions for a batch of assignment/students in a course
Parameters:
Name Type Attributes Description
opts object <optional>
object containing all arguments
Properties
Name Type Attributes Default Description
courseId number <optional>
default course id Canvas course Id
studentIds Array.<number> <optional>
all students a list of specific students to pull submissions for
assignmentIds Array.<number> <optional>
all assignments a list of assignments to get submissions for
submittedSince Date <optional>
beginning of time Exclude submissions that were not submitted or were submitted before this date
gradedSince Date <optional>
beginning of time Exclude submissions that were not graded or were graded before this date
workflowState string <optional>
all workflows a workflow state to filter by. Allowed values: 'submitted', 'unsubmitted', 'graded', or 'pending_review'
enrollmentState string <optional>
all states except deleted an enrollment state to filter by. Allowed values: 'active' or 'concluded'
includeSubmissionHistory boolean <optional>
if true, submission history is included
includeComments boolean <optional>
if true, includes all comments on submissions
includeRubricAssessment boolean <optional>
if true, rubric assessment is included
includeAssignment boolean <optional>
if true, the assignment is included for each submission
includeTotalScores boolean <optional>
if true, include the total scores
includeVisibility boolean <optional>
if true, include visibility
includeUser boolean <optional>
if true, include the user info with each submission
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<Array.<CanvasSubmission>>

(async) listGradeableStudents(opts, configopt) → {Promise.<Array.<CanvasUser>>}

Source:
Author:
  • Gabe Abrams
List gradeable students for a specific assignment
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment Id to query
courseId number <optional>
default course id Canvas course Id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<Array.<CanvasUser>>

(async) listOverrides(opts, configopt) → {Promise.<Array.<CanvasAssignmentOverride>>}

Source:
Author:
  • Gabe Abrams
Gets the list of overrides for an assignment
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment id to look up
courseId number <optional>
default course id Canvas course id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<Array.<CanvasAssignmentOverride>>

(async) listSubmissions(opts, configopt) → {Promise.<Array.<CanvasSubmission>>}

Source:
Author:
  • Gabe Abrams
Lists the submissions to a specific assignment in a course. If the assignment has anonymous grading turned on, to exclude the test user, we will also pull the list of students in the course. If including the user object for an anonymously graded assignment, fake user objects will be created where each submissions[i].user object contains a isAnonymousUser boolean that is true
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number The Canvas assignment Id to query
courseId number <optional>
default course id Canvas course Id
includeComments boolean <optional>
If truthy, includes all comments on submissions
includeRubricAssessment boolean <optional>
If truthy, includes rubric assessments: breakdown of score for each rubric item
excludeUser boolean <optional>
If truthy, excludes submission[i].user value with the submission's user information
includeTestStudent boolean <optional>
If truthy, includes dummy submission by test student (student view) if there is one. Note: if anonymous grading is enabled for this assignment, includeTestStudent will be true because we don't know which student is the test student
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<Array.<CanvasSubmission>>

(async) update(opts, configopt) → {Promise.<CanvasAssignment>}

Source:
Author:
  • Gabe Abrams
Updates a Canvas assignment
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment Id to update
courseId number <optional>
default course id Canvas course Id to query
name string <optional>
current value The name of the assignment
pointsPossible number <optional>
current value Points possible
dueAt date <optional>
current value Due at datetime
lockAt date <optional>
current value Due at datetime
unlockAt date <optional>
current value Due at datetime
description string <optional>
current value html description of the assignment
submissionTypes Array.<string> <optional>
current value Submission type(s)
allowedExtensions string <optional>
current value List of allowed file extensions (exclude period). Online upload must be enabled
gradingType string <optional>
current value Grading type
position number <optional>
current value Position in assignment list
published boolean <optional>
current value If true, publish page upon creation. Must be a boolean
muted boolean <optional>
current value If true, assignment is muted. Must be a boolean
groupSetId number <optional>
current value Student group set Id
assignmentGroupId number <optional>
current value Assignment group Id
peerReviewsEnabled boolean <optional>
current value If true, users asked to submit peer reviews. Must be a boolean
automaticPeerReviewsEnabled boolean <optional>
current value If true, Canvas will automatically assign peer reviews. Must be a boolean
omitFromFinalGrade boolean <optional>
current value If true, assignment is omitted from the final grade. Must be a boolean
gradeGroupStudentsIndividually boolean <optional>
current value If true, students in groups can be given separate grades and when one student in a group gets a grade, other students do not get graded. Must be a boolean
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasAssignment>

(async) updateGrade(opts, configopt) → {Promise.<CanvasSubmission>}

Source:
Author:
  • Gabe Abrams
Updates a student's grade and/or comment
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment id
studentId number Canvas student id
courseId number <optional>
default course id Canvas course id
points number <optional>
the overall points to assign to the student
comment string <optional>
the grader comment to leave on the submission
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasSubmission>

(async) updateGrades(opts, configopt) → {Promise.<CanvasProgress>}

Source:
Author:
  • Gabe Abrams
Batch updates grades and/or comments. Also supports updating rubric items
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment Id
gradeItems Array List of grade items to upload to Canvas: [{ studentId: , points: , comment: , rubricId: },...]
courseId number <optional>
default course id Canvas course Id
waitForCompletion boolean <optional>
If true, promise won't resolve until Canvas has finished updating the grades, instead of resolving once the grade changes have been queued
waitForCompletionTimeout number <optional>
2 The number of minutes to wait before timing out the grade update job
dontMergeRubricItemUpdates boolean <optional>
When uploading grades to a rubric item, we intelligently merge rubric item updates with previous rubric assessments. For instance, if the assignment's rubric is: { grammar, argument, formatting } And the student of interest has the following rubric assessment so far: { grammar: 10/10, argument: 8/10, formatting: ungraded } When we upload a new gradeItem (9/10 points) to the student's formatting rubric item, the result is: { grammar: 10/10, argument: 8/10, formatting: 9/10 } However, if dontMergeRubricItemUpdates=true, the result is: { grammar: ungraded, argument: ungraded, formatting: 9/10 } Note: merging is an added feature. By default, the Canvas API does not merge rubric assessments.
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasProgress>

(async) updateOverride(opts, configopt) → {Promise.<CanvasAssignmentOverride>}

Source:
Author:
  • Gabe Abrams
Update an assignment override. Note: target can only be updated if the override is a student override (if this is a group or section override, the target remains unchanged). Also, note that if any dates (dueAt, unlockAt, or lockAt) are omitted, their previous override values will be changed to "none." For instance, if the previous override has a dueAt and the update does not, the updated override will have no dueAt date (the target(s) of the override will have no deadline).
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
assignmentId number Canvas assignment id
overrideId number the override id to update
studentIds Array.<number> List of Canvas student IDs being overridden
courseId number <optional>
default course id Canvas course id
title string <optional>
current value New title of the override
dueAt date <optional>
no due date New due date. If excluded, the target(s) of this override have no due date (they can submit whenever they want without being marked as late)
unlockAt date <optional>
no unlock date New unlock date. If excluded, the target(s) of this override can immediately see the assignment (their unlock date is the beginning of time)
lockAt date <optional>
no lock date New lock date. If excluded, the target(s) of this override can see and submit the assignment at any point in the future (their lock date is the end of time)
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasAssignmentOverride>