@@ -66,15 +66,14 @@ def get_available_courses(course_name=None, course_period=None, api_key=None):
6666 result = r .json ()
6767
6868 except Exception as exc :
69-
7069 raise RuntimeError (
7170 """
7271 get_available_courses: Unexpected exception while retrieving
7372 the list of available courses/terms; this could be related
7473 to the API key({:.5}...) being either unavailable, invalid,
7574 or stale:
7675 {}
77- """ .format (api_key , exc )
76+ """ .format (_util . _robust_str ( api_key ) , exc )
7877 )
7978
8079 # Optionally filter according to the `course_name` parameter
@@ -90,6 +89,7 @@ def get_available_courses(course_name=None, course_period=None, api_key=None):
9089 return list (result )
9190
9291
92+ @_util .api_key_decorator ()
9393def get_course_roster_by_id (course_id , api_key = None ):
9494 """
9595 Returns the course roster, given the course's ID. The course ID
@@ -114,12 +114,14 @@ def get_course_roster_by_id(course_id, api_key=None):
114114 except Exception as exc :
115115 raise RuntimeError (
116116 """
117- get_course_roster_by_id: Unexpected exception while retrieving the
118- course roster from the provided course id({: d}):
117+ get_course_roster_by_id: Unexpected exception while
118+ retrieving the course roster from the provided course
119+ id ({: d}):
119120 {}
120121 """ .format (course_id , exc )
121122 )
122123
124+ @_util .api_key_decorator ()
123125def get_course_roster_by_name (course_name , course_period , api_key = None ):
124126 """
125127 Returns the course information and roster for a course, given its
@@ -138,7 +140,7 @@ def get_course_roster_by_name(course_name, course_period, api_key=None):
138140 ("get_course_roster_by_name: No course '{course_name}_{course_name}' "
139141 "is available, or codePost API key '{api_key:.5}...' is invalid or "
140142 "does not have access to it." ).format (
141- api_key = api_key ,
143+ api_key = _util . _robust_str ( api_key ) ,
142144 course_name = course_name ,
143145 course_period = course_period ,
144146 )
@@ -168,6 +170,7 @@ def get_course_roster_by_name(course_name, course_period, api_key=None):
168170
169171 return course_info
170172
173+ @_util .api_key_decorator ()
171174def get_assignment_info_by_id (assignment_id , api_key = None ):
172175 """
173176 Returns the assignment information dictionary, given the assignment's ID.
@@ -190,11 +193,12 @@ def get_assignment_info_by_id(assignment_id, api_key=None):
190193 raise RuntimeError (
191194 """
192195 get_assignment_info_by_id: Unexpected exception while retrieving the
193- assignment info from the provided id({: d}):
196+ assignment info from the provided id ({: d}):
194197 {}
195198 """ .format (assignment_id , exc )
196199 )
197200
201+ @_util .api_key_decorator ()
198202def get_assignment_info_by_name (course_name , course_period , assignment_name , api_key = None ):
199203 """
200204 Returns the assignment information dictionary, given a(course name, course period,
@@ -217,7 +221,8 @@ def get_assignment_info_by_name(course_name, course_period, assignment_name, api
217221 get_assignment_info_by_name: Either no course with the
218222 specified course({}) and period({}) exists, or the provided
219223 API key({:.5}...) does not have access to it.
220- """ .format (course_name , course_period , api_key )
224+ """ .format (course_name , course_period ,
225+ _util ._robust_str (api_key ))
221226 )
222227
223228 elif len (courses ) > 1 :
@@ -260,6 +265,7 @@ def get_assignment_info_by_name(course_name, course_period, assignment_name, api
260265 return selected_assignment
261266
262267
268+ @_util .api_key_decorator ()
263269def get_assignment_submissions (assignment_id , student = None , grader = None , api_key = None ):
264270 """
265271 Returns the list of submissions of an assignment, provided an assignment ID
@@ -321,6 +327,7 @@ def get_assignment_submissions(assignment_id, student=None, grader=None, api_key
321327
322328 return result
323329
330+ @_util .api_key_decorator ()
324331def get_submission_by_id (submission_id , api_key = None ):
325332 """
326333 Returns the submission information dictionary, given the submission's ID.
@@ -348,6 +355,7 @@ def get_submission_by_id(submission_id, api_key=None):
348355 """ .format (submission_id , exc )
349356 )
350357
358+ @_util .api_key_decorator ()
351359def get_file (file_id , api_key = None ):
352360 """
353361 Returns the file given its file ID; the file IDs are provided within a
@@ -377,6 +385,7 @@ def get_file(file_id, api_key=None):
377385 )
378386
379387
388+ @_util .api_key_decorator ()
380389def set_submission_grader (submission_id , grader , api_key = None ):
381390 """
382391 Changes the grader claimed to a submission with a given submission ID.
@@ -415,6 +424,7 @@ def set_submission_grader(submission_id, grader, api_key=None):
415424 )
416425
417426
427+ @_util .api_key_decorator ()
418428def unclaim_submission (submission_id , api_key = None ):
419429 """
420430 Unclaims a submission, given the submission ID. This unsets the associated
@@ -427,6 +437,7 @@ def unclaim_submission(submission_id, api_key=None):
427437 )
428438
429439
440+ @_util .api_key_decorator ()
430441def remove_comments (submission_id = None , file_id = None , api_key = None ):
431442 """
432443 Removes all comments either from the submission with the given submission ID
@@ -491,6 +502,7 @@ def remove_comments(submission_id=None, file_id=None, api_key=None):
491502 return (total_comments == deleted_comments )
492503
493504
505+ @_util .api_key_decorator ()
494506def delete_submission (submission_id , api_key = None ):
495507 """
496508 Deletes the submission with the given submission ID; raises an exception
@@ -520,6 +532,7 @@ def delete_submission(submission_id, api_key=None):
520532 )
521533
522534
535+ @_util .api_key_decorator ()
523536def delete_file (file_id , api_key = None ):
524537 """
525538 Deletes the file with the given file ID; raises an exception
@@ -549,6 +562,7 @@ def delete_file(file_id, api_key=None):
549562 )
550563
551564
565+ @_util .api_key_decorator ()
552566def post_file (submission_id , filename , content , extension , api_key = None ):
553567 """
554568 Uploads a file to a submission.
@@ -589,6 +603,7 @@ def post_file(submission_id, filename, content, extension, api_key=None):
589603 )
590604
591605
606+ @_util .api_key_decorator ()
592607def post_submission (assignment_id , students , files , api_key = None ):
593608 """
594609 Uploads a submission, give the assignment's ID, and a dictionary containing
@@ -663,6 +678,7 @@ def post_submission(assignment_id, students, files, api_key=None):
663678
664679 return submission
665680
681+ @_util .api_key_decorator ()
666682def post_comment (file , text , pointDelta , startChar , endChar , startLine , endLine , rubricComment = None , api_key = None ):
667683 """
668684 Adds comment specified by (startChar, endChar, startLine, endLine) to file
@@ -710,6 +726,7 @@ def post_comment(file, text, pointDelta, startChar, endChar, startLine, endLine,
710726
711727 return comment
712728
729+ @_util .api_key_decorator ()
713730def set_submission_students (submission_id , students , api_key = None ):
714731 """
715732 Modifies the students associated with a submission.
@@ -741,6 +758,7 @@ def set_submission_students(submission_id, students, api_key=None):
741758 """ .format (students , submission_id , exc )
742759 )
743760
761+ @_util .api_key_decorator ()
744762def remove_students_from_submission (submission_info , students_to_remove , api_key = None ):
745763 """
746764 Removes students from a submission, and possibly delete the submission if no
@@ -773,6 +791,7 @@ def _submission_list_is_unclaimed(submissions):
773791 return False
774792 return True
775793
794+ @_util .api_key_decorator ()
776795def get_course_grades (course_name , course_period , only_finalized = True , api_key = None ):
777796 """
778797 Returns a dictionary mapping every student in the specified course
0 commit comments