A handler that uses the CACCL library to add and modify student metadata on a per-course level.
npm install canvas-student-metadataImport the library:
``js`
const StudentMetadata = require('canvas-student-metadata');
Initialize using an instance of CACCL-API:
`js`
const studentMetadata = new StudentMetadata(api);
_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
>
> `js`
> 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]);
> }
>
_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
>
> `js``
> const metadata = {
> heightIn: 48,
> ageYrs: 14,
> favoriteColor: 'red',
> };
>
> await studentMetadata.setStudentMetadata(104, 77901, metadata);
>