@openworkspace/classroom
v0.1.1
Published
Google Classroom API client for courses, assignments, and grading
Maintainers
Readme
@openworkspace/classroom
Google Classroom API client for OpenWorkspace -- courses, coursework, roster, submissions.
Part of the OpenWorkspace monorepo.
Install
npm install @openworkspace/classroom @openworkspace/coreUsage
import { createHttpClient } from '@openworkspace/core';
import { listCourses, listStudents, createCourseWork, gradeSubmission } from '@openworkspace/classroom';
const http = createHttpClient({ auth: { accessToken: 'token' } });
// List courses
const result = await listCourses(http);
if (result.ok) {
for (const course of result.value.courses ?? []) {
console.log(course.name, course.courseState);
}
}
// List students in a course
const students = await listStudents(http, 'courseId');
// Create an assignment
await createCourseWork(http, 'courseId', {
title: 'Homework 1',
workType: 'ASSIGNMENT',
maxPoints: 100,
});
// Grade a submission
await gradeSubmission(http, 'courseId', 'courseWorkId', 'submissionId', { assignedGrade: 95 });API
All functions take an HttpClient as the first parameter and return Result<T, E>.
Courses
listCourses(http)-- List all coursesgetCourse(http, id)-- Get a coursecreateCourse(http, course)-- Create a courseupdateCourse(http, id, course)-- Update a coursedeleteCourse(http, id)-- Delete a coursearchiveCourse(http, id)-- Archive a course
Roster
listStudents(http, courseId)-- List studentslistTeachers(http, courseId)-- List teachersaddStudent(http, courseId, email)-- Add a studentaddTeacher(http, courseId, email)-- Add a teacherremoveStudent(http, courseId, userId)-- Remove a studentremoveTeacher(http, courseId, userId)-- Remove a teacher
Coursework & Submissions
listCourseWork(http, courseId)-- List assignmentsgetCourseWork(http, courseId, id)-- Get an assignmentcreateCourseWork(http, courseId, work)-- Create an assignmentupdateCourseWork(http, courseId, id, work)-- Update an assignmentdeleteCourseWork(http, courseId, id)-- Delete an assignmentlistSubmissions(http, courseId, workId)-- List submissionsgetSubmission(http, courseId, workId, id)-- Get a submissiongradeSubmission(http, courseId, workId, id, grade)-- Grade a submissionreturnSubmission(http, courseId, workId, id)-- Return a submission
Announcements & Guardians
listAnnouncements(http, courseId)-- List announcementscreateAnnouncement(http, courseId, announcement)-- Create an announcementdeleteAnnouncement(http, courseId, id)-- Delete an announcementlistGuardians(http, studentId)-- List guardiansinviteGuardian(http, studentId, email)-- Invite a guardian
