# Classroom - Courses - [API documentation](#api-documentation) - [Notes](#notes) - [Python Regular Expressions](Python-Regular-Expressions) Match function - [Definitions](#definitions) - [Special quoting for course aliases and topics](#special-quoting-for-course-aliases-and-topics) - [Updating course owner](#updating-course-owner) - [Create and update courses](#create-and-update-courses) - [Delete courses](#delete-courses) - [Manage course aliases](#manage-course-aliases) - [Manage course topics](#manage-course-topics) - [Display courses](#display-courses) - [Display course counts](#display-course-counts) - [Display course announcements](#display-course-announcements) - [Display course materials](#display-course-materials) - [Display course topics](#display-course-topics) - [Display course work](#display-course-work) - [Display course submissions](#display-course-submissions) ## API documentation * [Google Classroom API](https://developers.google.com/classroom/reference/rest) * [Google Classroom API - Courses Students](https://developers.google.com/classroom/reference/rest/v1/courses.students) * [Google Classroom API - Courses Teachers](https://developers.google.com/classroom/reference/rest/v1/courses.teachers) * [Google Classroom API - Announcements](https://developers.google.com/classroom/reference/rest/v1/courses.announcements/list) * [Google Classroom API - Topics](https://developers.google.com/classroom/reference/rest/v1/courses.topics/list) * [Google Classroom API - Course Work](https://developers.google.com/classroom/reference/rest/v1/courses.courseWork/list) * [Google Classroom API - Course Work Materials](https://developers.google.com/classroom/reference/rest/v1/courses.courseWorkMaterials/list) * [Google Classroom API - Course Work Student Submissions](https://developers.google.com/classroom/reference/rest/v1/courses.courseWork.studentSubmissions/list) ## Notes In this document, `course materials` refers to stand-alone materials, not the materials associated with `course announcements` or `course work`. Google added support for stand-alone materials in early 2021. To use the course materials features you must authorize the appropriate scope: `Classroom API - Course Work/Materials`. ``` gam oauth create gam user user@domain.com check|update serviceaccount ``` ## Definitions ``` ::= (.)+ ::= @ ::= id: ::= || ::= See: https://docs.python.org/3/library/re.html ::= ::= ::= > ::= ::= "(,)*" ::= |||| See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= ::= "(,)*" ::= ||||| See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= draft|published|deleted ::= all|"(,)*" ::= |d: ::= "(,)*" ::= ||| See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= ::= "(,)*" ::= draft|published|deleted ::= all|"(,)*" ::= | | | | | See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= active|archived|provisioned|declined|suspended ::= all|"(,)*" ::= ::= "(,)*" ::= ||| See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= new|created|turned_in|returned|reclaimed_by_student ::= all|"(,)*" ::= ::= "(,)*" ::= | | | | See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= ::= "(,)*" ::= ||||| See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= ::= "(,)*" ::= ||||| See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= draft|published|deleted ::= all|"(,)*" ::= (description )| (descriptionheading|heading )| (name )| (room )| (section )| (state|status )| (owner|ownerid|teacher ) ::= alternatelink| coursegroupemail| coursematerialsets| coursestate| creationtime| description| descriptionheading|heading| enrollmentcode| gradebooksettings| guardiansenabled| id| name| owneremail| ownerid| room| section| teacherfolder| teachergroupemail| updatetime ::= '(,)*' ::= alternatelink| assigneemode| courseid| courseannouncementid| creationtime| creator|creatoruserid| id| individualstudentsoptions| materials| scheduledtime| state| text| updatetime ::= "(,)*" ::= updatetime| updatedate ::= alternatelink| assigneemode| courseid| courseworkmaterialid| creationtime| creator|creatoruserid| description| id| individualstudentsoptions| materials| scheduledtime| state| title| topicid| updatetime| workmaterialid ::= "(,)*" ::= updatetime| updatedate ::= alternatelink| assigneemode| courseid| courseworkid| courseworktype| creationtime| creator|creatoruserid| description| duedate| duetime| id| individualstudentsoptions| materials| maxpoints| scheduledtime| state| submissionmodificationmode| title| topicid| updatetime| workid| worktype ::= "(,)*" ::= duedate| updatetime| updatedate ::= alternatelink| assignedgrade| courseid| courseworkid| courseworktype| creationtime| draftgrade| id| late| state| submissionhistory| updatetime| userid| worktype ::= "(,)*" ``` ## Special quoting for course aliases and topics As course aliases and topics can contain spaces, some care must be used when entering `` and ``. Suppose you have a course with the alias `Math Class`. To get information about it you enter the command: `gam info course "d:Math Class"` The shell strips the `"` leaving a single argument `d:Math Class`; gam correctly processes the argument as it is expecting a single course. Suppose you enter the command: `gam info courses "d:Math Class"` The shell strips the `"` leaving a single argument `d:Math Class`; as gam is expecting a list, it splits the argument on space leaving two items and then tries to process `d:Math` and `Class`, not what you want. You must enter: `gam info courses "'d:Math Class'"` The shell strips the `"` leaving a single argument `'d:Math Class'`; as gam is expecting a list, it splits the argument on space while honoring the `'` leaving one item `d:Math Class` and correctly processes the item. For multiple aliases you must enter: `gam info courses "'d:Math Class','d:Science Class'"` See: [Lists and Collections](Lists-and-Collections) ## Updating course owner When updating a course owner, the Classroom API generates an error if the new owner is not a co-teacher or is the current owner. If `` is not a co-teacher, GAM adds `` as a co-teacher of the course, pauses 10 seconds, and then updates them to be the owner. ``` $ gam update course 123929046789 teacher newteacher@domain.com Course Name: Test, Course: 123929046789, Updated with new teacher as owner: newteacher@domain.com ``` If `` is the current owner, GAM now reports that the current owner was retained. ``` $ gam update course 123929046789 teacher newteacher@domain.com Course Name: Test, Course: 123929046789, Updated with current owner: newteacher@domain.com ``` In the normal case when `` is a co-teacher, GAM now reports the change. ``` $ gam update course 123929046789 teacher newteacher@domain.com Course Name: Test, Course: 123929046789, Updated with co-teacher as owner: newteacher@domain.com ``` ## Create and update courses The options `name ` and `teacher ` are required when creating a class. ``` gam create|add course [id|alias ] * [copyfrom [announcementstates ] [individualstudentannouncements copy|delete|maptoall] [materialstates ] [individualstudentmaterials copy|delete|maptoall] [workstates ] [individualstudentcoursework copy|delete|maptoall] [removeduedate []] [mapsharemodestudentcopy edit|none|view] [individualstudentassignments copy|delete|maptoall] [copymaterialsfiles []] [copytopics []] [markdraftaspublished []] [markpublishedasdraft []] [members none|all|students|teachers]] [logdrivefileids []] gam update course + [copyfrom [announcementstates ] [individualstudentannouncements copy|delete|maptoall] [materialstates ] [individualstudentmaterials copy|delete|maptoall] [workstates ] [individualstudentcoursework copy|delete|maptoall] [removeduedate []] [mapsharemodestudentcopy edit|none|view] [individualstudentassignments copy|delete|maptoall] [copymaterialsfiles []] [copytopics []] [markdraftaspublished []] [markpublishedasdraft []] [members none|all|students|teachers]] [logdrivefileids []] gam update courses + [copyfrom [announcementstates ] [individualstudentannouncements copy|delete|maptoall] [materialstates ] [individualstudentmaterials copy|delete|maptoall] [workstates ] [individualstudentcoursework copy|delete|maptoall] [removeduedate []] [mapsharemodestudentcopy edit|none|view] [individualstudentassignments copy|delete|maptoall] [copymaterialsfiles []] [copytopics []] [markdraftaspublished []] [markpublishedasdraft []] [members none|all|students|teachers]] [logdrivefileids []] ``` `copyfrom ` allows copying of course announcements, work, topics and members from one course to another. * Accouncements - By default, no course announcements are copied * `announcementstates ` - Copy class announcements with the specified states * `individualstudentannouncements copy` - Copy individual student announcements; this is the default. You will get an error if a student is not a member of the course * `individualstudentannouncements delete` - Delete individual student announcements * `individualstudentannouncements maptoall` - Map individual student announcements to all student announcements * Materials - By default, no course materials are copied * `materialstates ` - Copy class materials with the specified states * `individualstudentmaterials copy` - Copy individual student materials; this is the default. You will get an error if a student is not a member of the course * `individualstudentmaterials delete` - Delete individual student materials * `individualstudentmaterials maptoall` - Map individual student materials to all student materials * Work - By default, no course work is copied * `workstates ` - Copy class work with the specified states * `individualstudentcoursework copy` - Copy individual student coursework; this is the default. You will get an error if the student is not a member of the course * `individualstudentcoursework delete` - Delete individual student coursework * `individualstudentcoursework maptoall` - Map individual student coursework to all student coursework * `removeduedate false` - Remove due dates before the current time; this is the default * `removeduedate|removeduedate true` - Remove all due dates * For convenience, setting `individualstudentassignments` sets all the following to the same value: * `individualstudentannouncements` * `individualstudentmaterials` * `individualstudentcoursework` * Announcements, Materials and Work Materials files * `copymaterialsfiles false` - Copy links to files referenced by materials in the `copyfrom` course; this is the default * `copymaterialsfiles|copymaterialsfiles true` - Copy files referenced by materials in the `copyfrom` course * You must verify that the teacher of the course being created/updated has access to the files in the `copyfrom` course * Files can only be copied to a course that is ACTIVE; GAM will adjust the course state as necessary * Topics - By default, no course topics are copied; if topics are not copied, references to them will be deleted from class work that is copied * `copytopics false` - No course topics are copies * `copytopics|copytopics true` - Copy topics * Published Material and Work - By default, published material and work is not relabeled * `markdraftaspublished false` - Do not relabel draft material/work as published; this is the default * `markdraftaspublished|markpublishedasdraft true` - Relabel draft material/work as published * `markpublishedasdraft false` - Do not relabel published material/work as draft; this is the default * `markpublishedasdraft|markpublishedasdraft true` - Relabel published material/work as draft * Members - By default, no course members are copied * `members none` - No course members are copied * `members all` - Copy course students and teachers * `members students` - Copy students * `members teachers` - Copy teachers When true, `logdrivefileids []` generates a CSV file with headers `courseId,ownerId,fileId' that lists all drive files in the course. The Classroom API does not support course materials of type `form`, they will not be copied. Drive files with `shareMode` `Each student will get a copy` don't seem to be able to be copied. * `mapsharemodestudentcopy edit` - Map `Each student will get a copy` to `Students can edit file` * `mapsharemodestudentcopy view` - Map `Each student will get a copy` to `Students can view file` * `mapsharemodestudentcopy none` or not specified - No `shareMode` mapping is performed, you may get an error ## Delete courses Classes can only be deleted when they are in the ARCHIVED state; to delete a class, you can update its state to ARCHIVED and then delete it or you can specify that it be archived as parot of the delete command. ``` gam delete course [archived] gam delete courses [archived] ``` ## Manage course aliases These commands can process a single course. ``` gam course add alias gam course delete alias ``` These commands can process multiple courses. ``` gam courses add alias gam courses delete alias ``` ## Manage course topics These commands can process a single course. ``` gam course add topic gam course delete topic ``` These commands can process multiple courses. ``` gam courses add topic gam courses delete topic ``` ## Display courses ``` gam info course [owneremail] [alias|aliases] [show all|students|teachers] [countsonly] [fields ] [skipfields ] [formatjson] gam info courses [owneremail] [alias|aliases] [show all|students|teachers] [countsonly] [fields ] [skipfields ] [formatjson] gam print courses [todrive *] (course|class )*|([teacher ] [student ] [states ]) [owneremail] [owneremailmatchpattern ] [alias|aliases|aliasesincolumns [delimiter ]] [show all|students|teachers] [countsonly] [fields ] [skipfields ] [formatjson [quotechar ]] [timefilter creationtime|updatetime] [start|starttime |