canvas-student-metadata

1.0.3 • Public • Published

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 student
  • studentId – the id of the student to update
  • metadata – 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);

Readme

Keywords

Package Sidebar

Install

npm i canvas-student-metadata

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

14.2 kB

Total Files

9

Last publish

Collaborators

  • gabeabrams