@@ -248,7 +248,8 @@ def list_submissions(self):
248248 while True :
249249 coursework = service .courses ().courseWork ()
250250 response = coursework .studentSubmissions ().list (
251- pageToken = page_token , courseId = "123456" ,
251+ pageToken = page_token ,
252+ courseId = "123456" ,
252253 courseWorkId = "654321" ).execute ()
253254 submissions .extend (response .get ('studentSubmissions' , []))
254255 page_token = response .get ('nextPageToken' , None )
@@ -263,5 +264,66 @@ def list_submissions(self):
263264 print ("%s was submitted at %s" %
264265 (submission .get ('id' ),
265266 submission .get ('creationTime' )))
267+ # [END classroom_list_submissions]
268+
269+ def list_student_submissions (self ):
270+ """
271+ Lists all coursework submissions for a given student.
272+ """
273+ service = self .service
274+ # [START classroom_list_student_submissions]
275+ submissions = []
276+ page_token = None
277+
278+ while True :
279+ coursework = service .courses ().courseWork ()
280+ response = coursework .studentSubmissions ().list (
281+ pageToken = page_token ,
282+ courseId = "123456" ,
283+ courseWorkId = "123456" ,
284+ userId = "123456" ).execute ()
285+ submissions .extend (response .get ('studentSubmissions' , []))
286+ page_token = response .get ('nextPageToken' , None )
287+ if not page_token :
288+ break
289+
290+ if not submissions :
291+ print ('No student submissions found.' )
292+ else :
293+ print ('Student Submissions:' )
294+ for submission in submissions :
295+ print ("%s was submitted at %s" %
296+ (submission .get ('id' ),
297+ submission .get ('creationTime' )))
298+ # [END classroom_list_student_submissions]
299+
300+ def list_all_submissions (self ):
301+ """
302+ Lists all coursework submissions for a given student.
303+ """
304+ service = self .service
305+ # [START classroom_list_submissions]
306+ submissions = []
307+ page_token = None
266308
309+ while True :
310+ coursework = service .courses ().courseWork ()
311+ response = coursework .studentSubmissions ().list (
312+ pageToken = page_token ,
313+ courseId = "123456" ,
314+ courseWorkId = "-" ,
315+ userId = "123456" ).execute ()
316+ submissions .extend (response .get ('studentSubmissions' , []))
317+ page_token = response .get ('nextPageToken' , None )
318+ if not page_token :
319+ break
320+
321+ if not submissions :
322+ print ('No student submissions found.' )
323+ else :
324+ print ('Complete list of student Submissions:' )
325+ for submission in submissions :
326+ print ("%s was submitted at %s" %
327+ (submission .get ('id' ),
328+ submission .get ('creationTime' )))
267329 # [END classroom_list_submissions]
0 commit comments