canvas-student-metadata
v1.0.3
Published
A handler that uses the CACCL library to add and modify student metadata on a per-course level.
Downloads
6
Readme
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 = require('canvas-student-metadata');
Initialize using an instance of CACCL-API:
const studentMetadata = new 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.getStudentMetadataMap(104); if (metadataMap[77901] === undefined) { console.log('Student has no metadata'); } else { console.log('Student has metadata. Here it is:'); console.log(metadataMap[77901]); }
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: 48, ageYrs: 14, favoriteColor: 'red', }; await studentMetadata.setStudentMetadata(104, 77901, metadata);