canvas-student-metadata
A handler that uses the CACCL library to add and modify student metadata on a per-course level.
Getting Started
Import the library:
const StudentMetadata = ;
Initialize using an instance of CACCL-API:
const studentMetadata = api;
Methods
getStudentMetadataMap – gets metadata for each student in a course
This is an asynchronous function
Argument:
courseId
– a Canvas course id
Returns:
Object where keys are studentIds and values are metadata objects.
Note: students that do not have metadata have a value of undefined
Example:
In our example, the courseId is 104 and the studentId is 77901
const metadataMap = await studentMetadata;if metadataMap77901 === undefinedconsole;elseconsole;console;
setStudentMetadata – set's the metadata for a specific student
This is an asynchronous function
Arguments:
courseId
– the id of the course containing the studentstudentId
– the id of the student to updatemetadata
– an metadata object (must be JSONifiable)
Example:
In our example, the courseId is 104 and the studentId is 77901
const metadata =heightIn: 48ageYrs: 14favoriteColor: 'red';await studentMetadata;