Search code examples
node.jsgoogle-classroom

Get classwork status


Using nodejs (eventually react native), I am working on retrieving classwork that has not been submitted yet. I get the output from the classwork API but there is no field that I can find that tells you the status of the assignment (graded, assigned, turned in, etc). Is there a specific endpoint that I have to call on each classwork to get the status? For reference, here is the output I get (id values have been censored):

{

  courseId: '************',

  id: '****',

  title: 'HTWH Syllabus Acknowledgement Form',

  materials: [Array],

  state: 'PUBLISHED',

  alternateLink: 'https://classroom.google.com/c/.......',

  creationTime: '2020-08-26T22:10:25.522Z',

  updateTime: '2020-08-26T22:15:26.587Z',

  dueDate: [Object],

  dueTime: [Object],

  maxPoints: 5,

  workType: 'ASSIGNMENT',

  submissionModificationMode: 'MODIFIABLE_UNTIL_TURNED_IN',

  creatorUserId: '*******',

  topicId: '********'

}

Solution

  • It seems you are using courses.courseWork.get in checking your course work status which will return a CourseWork instance that doesn't contain the submission state of the course work.

    You need to use courses.courseWork.studentSubmissions.list if you want to check the submission state of your course work per student. If you want to check a particular student, you can use courses.courseWork.studentSubmissions.get.

    This will return a StudentSubmission instance, which contains a submission state and the assignedGrade (if applicable)

    enter image description here

    Sample Response:

    Example: I created course work which is assigned to 2 student then check the submission state using courses.courseWork.studentSubmissions.list

    {
      "studentSubmissions": [
        {
          "courseId": "2371163xxxx",
          "courseWorkId": "30629017xxxx",
          "id": "Cg4IwNPyqfMGEK_pxxxxx",
          "userId": "1043405157872289xxxxx",
          "creationTime": "2021-03-22T21:17:51.331Z",
          "updateTime": "2021-03-22T21:17:51.253Z",
          "state": "CREATED",
          "alternateLink": "xxxxxxxxxxxx",
          "courseWorkType": "ASSIGNMENT",
          "assignmentSubmission": {},
          "submissionHistory": [
            {
              ....
            }
          ]
        },
        {
          "courseId": "2371163xxxx",
          "courseWorkId": "30629017xxxx",
          "id": "Cg4I2ujEgvUIEK_pxxxxx",
          "userId": "1112235452378899xxxxx",
          "creationTime": "2021-03-22T21:17:44.380Z",
          "updateTime": "2021-03-22T21:17:44.354Z",
          "state": "CREATED",
          "alternateLink": "xxxxxxxxxxxx",
          "courseWorkType": "ASSIGNMENT",
          "assignmentSubmission": {},
          "submissionHistory": [
            {
              ....
            }
          ]
        }
      ]
    }