I am creating a python script that get how many due assignments I have left in google classroom among all courses, but I could get direct api call from Google Classroom API.
I followed official google classroom python documentation, but I couldn't find a way to get pending assignments. Currently I am using work around.
...
courses = service.courses().courseWork().list(courseId= <my_course_id>).execute()
subm = service.courses().courseWork().studentSubmissions().list(courseId= <my_course_id>, userId='me',courseWorkId='-').execute()
for i in courses['courseWork']:
for j in subm['studentSubmissions']:
if i['id'] == j['courseWorkId'] and j['state'] == 'CREATED':
print(i['title'])
It works but I need to make 2 request per course, and I have 10 courses. So, it will be too much expensive for me as I`m calling this script every 5 min. Is there any easier way to get it
I don't think there's a way around sending 2 requests, but you can speed it up by only requesting the fields you need (title) and set the
submissionStates[]filter tosubmissionStates=['CREATED']. It should greatly speed up your requests.Hope that helps (also the code might be wrong, I wasn't able to test it but I think you see the point).