Apps Scriptリファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

2025年5月2日金曜日

Google Classroom APIで資料を作成してみる


指定したクラスに資料を作成するコードを試してみました


Classroomの画面上では「授業 > 作成 > 資料」で作れます



下記 Code.gs の courseId, title, description を自身の環境に合わせて書き換えて

createMaterial() を実行すると

courseId で指定したクラスに資料が作成されます

今回は Syllabus を想定して書いてみたので description がちょっと長くなりました



Code.gs
function createMaterial() {
const courseId = '776967326029'; // クラスIDを指定
const title = 'Syllabus';
const description = `
Course Title:
Google Classroom Essentials

Department / Program:
EdTech Training Program

Term / Schedule:
Online, Self-paced

Classroom / Location:
Online, from the comfort of your home

Instructor:
Pre-Practice

Course Overview / Purpose:
This course is designed to help educators and administrators
understand and use the essential features and functions of Google Classroom effectively.
Participants will learn how to set up classes,
create course work,
use rubrics,
manage members,
provide feedback,
and communicate efficiently through the platform.

Learning Objectives:
- Create and manage Google Classroom classes.
- Create and organize course work and assignments.
- Develop and apply rubrics for grading.
- Invite and manage students, co-teachers, and guardians.
- Provide effective feedback and return graded work.
- Post announcements and manage classroom settings.
- Understand both the teacher and student user flows.

Weekly Course Plan / Schedule:
1. Introduction to Google Classroom
2. Creating a Class
3. Creating Course Work
4. Creating Rubrics
5. Inviting Members
6. Providing Feedback
7. Grading and Returning Work
8. Posting Announcements
9. Classroom Settings
10. Teacher and Student Flow
11. Working with Guardians
12. Final Review and Best Practices

References:
- Google Classroom Help Center
- Google for Education Training Center

Out-of-Class Learning:
Participants are expected to explore Google Classroom hands-on,
complete practice assignments,
and review help resources.
Estimated time: 1–2 hours per week.

Evaluation / Grading Criteria:
- Completion of practice tasks: 40%
- Participation in discussions (if applicable): 20%
- Final project (create and submit a sample class): 40%

Prerequisites / Requirements:
- Basic computer literacy
- A Google account
`;

const material = {
title: title,
description: description,
state: 'DRAFT'
};

try {
const createdMaterial = Classroom.Courses.CourseWorkMaterials.create(material, courseId);
Logger.log(`資料作成成功: ID = ${createdMaterial.id}, タイトル: ${createdMaterial.title}`);
} catch (e) {
Logger.log('資料作成失敗: ' + e.message);
}
}


実行後に以下のような資料が下書きで作成されました






Tips

API経由ではdescription(詳細)のテキストはstring型のため
太字、斜体、箇条書きなどのリッチテキスト形式は指定できないようです(2025/05/02現在)。

Latest post

Google Classroom APIでクラス内にある資料を取得してみる

Classroomの授業の中にある「資料」を取得してみたときのコードです Code.gs のcourseId を自身の環境に合わせて書き換えて listAllCourseWorkMaterials() を実行すると PUBLISHED または DRAFT 状態の「資料」のタイトル...