שירות Classroom

שירות Classroom מאפשר לכם להשתמש ב-Google Classroom API ב-Apps Script. ‫API שמאפשר לאדמינים, למורים ולתלמידים להציג ולנהל את הקורסים ואת רשימות התלמידים שלהם.

חומרי עזר

מידע מפורט על השירות הזה זמין במאמרי העזרה בנושא Google Classroom API. בדומה לכל השירותים המתקדמים ב-Apps Script, שירות Classroom משתמש באותם אובייקטים, שיטות ופרמטרים כמו ה-API הציבורי. מידע נוסף זמין במאמר איך נקבעות חתימות של שיטות.

כדי לדווח על בעיות ולקבל תמיכה אחרת, אפשר לעיין במדריך התמיכה של Classroom.

קוד לדוגמה

בדוגמת הקוד שבהמשך נעשה שימוש בגרסה 1 של ה-API.

הצגת רשימת קורסים

בדוגמה הזו מפורטים עשרת הקורסים הראשונים שהמשתמש יכול לגשת אליהם.

advanced/classroom.gs
/**
 * Lists 10 course names and IDs.
 */
function listCourses() {
  /**
   * @see https://developers.google.com/classroom/reference/rest/v1/courses/list
   */
  const optionalArgs = {
    pageSize: 10
    // Use other query parameters here if needed.
  };
  try {
    const response = Classroom.Courses.list(optionalArgs);
    const courses = response.courses;
    if (!courses || courses.length === 0) {
      console.log('No courses found.');
      return;
    }
    // Print the course names and IDs of the available courses.
    for (const course in courses) {
      console.log('%s (%s)', courses[course].name, courses[course].id);
    }
  } catch (err) {
    // TODO (developer)- Handle Courses.list() exception from Classroom API
    console.log('Failed with error %s', err.message);
  }
}