1.1.1 • Published 3 years ago

canvas-student-wrapper v1.1.1

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

Canvas Student Wrapper

Exposes an object that contains a student's courses, their announcements, and their grades.

Usage:

Install with npm install canvas-student-wrapper -S and import using

import StudentCanvas, { RedactedCanvas } from 'canvas-student-wrapper' in a .mjs file.

You can generate a student access token by going to canvas, navigating to the profile settting page, and clicking on + New Access Token. You can give this access token any name.

Student Canvas

Acts as an interface for everything a student can see on their course page. This includes read status for announcements and the status of their assignments.

To create an instance of StudentCanvas, use const canvas = new StudentCavas(ACCESS_TOKEN, SUBDOMAIN).

StudentCanvas Methods:

  • getActiveCourses(): Gets basic information about all courses the user is currently enrolled in. This does not include announcements or assignments.
  • getAllCourses(): Gets basic information about all courses the user has ever been enrolled in. This does not include announcements or assignments.
  • getAnnouncements(COURSE_IDS): Get the announcements for all courses in COURSE_IDS.
  • getAssignments(COURSE_IDS): Get the assignments for all courses in COURSE_IDS.
  • getCourseExtras(COURSE_IDS): Gets both announcements and assignments for courses in COURSE_IDS.
  • update(): Refreshes all courses, announcements, and assignments that are currently stored.

Redacted Canvas

This has most of the same functions as the student canvas, but it removes all sensitive information and autopopulates all currently active lectures.

To create an instance of RedactedCanvas, use const canvas = await RedactedCanvas.setup(ACCESS_TOKEN, SUBDOMAIN).

The update method of RedactedCanvas only updates active courses.

Course Object

Course objects Contain the following properties:

KeyProperty
idA number that uniquely identifies the course on canvas.
nameThe long, descriptive name of the course.
codeThe course code.
startDateA date object with the start date of the course.
activeA boolean representing whether the student is currently in the course.
calendarLinkA link to an ics file that has the course calendar.
termAn object with the keys name, startDate, and endDate that represents the term the course was taken in.
courseImgA link to the front image of the course.
totalStudentsThe total number of students in the course.
teachersAn array of objects with the keys avatar, link, and name that identify the course instructors.
tabsAn array of objects with the keys id, label, link, position, and type that point to canvas pages.
announcementsAn array of Annoucement objects (Reference Below).
assignmentsAn array of Assignment objects (Reference Below).

Annoucement Object

Annoucement objects contain the following properties:

KeyProperty
positionNumber that sorts the annoucements.
titleThe title of the annoucement.
messageThe body text of the annoucement
readWhether the user has opened this announcement.
authorAn object with a name key that identifies the person who posted the announcement.
linkA link to the announcement page.
dateThe date that the announcement was made.

Assignment Object

Assignment objects contain the following properties:

KeyProperty
positionNumber that sorts the annoucements.
nameThe title of the assignment.
descriptionA detailed description of the assignment.
dueDateA date object representing the due date.
unlockDateA date object representing the date the assignment will be available at.
countsA boolean value representing whether the assignment will effect the final grade.
allowedAttemptsA number representing the number of times the user can submit.
submittedA boolean representing whether the user has submitted.
linkA link to the assignment page.
submissionA Submission object. (Reference Below)
possiblePointsA number representing the max number of points on the assignment
submittedWhether the student has submitted this assignment.

Submission Object

Submission objects contain the following properties:

KeyProperty
scoreA number representing how many points the student got.
possiblePointsThe max number of points that could be achieved.
submissionDateThe date that the user submitted.
gradedDateThe date that the submission was graded.
gradedA boolean representing if the submission has been graded.
lateA boolean representing if the submission was late.
missingA boolean representing if the submission is missing.