From b96d2f1ecad2fb1bdb9d6caf186dd787e082e49d Mon Sep 17 00:00:00 2001 From: bcr33d Date: Tue, 4 Apr 2023 09:04:08 -0700 Subject: [PATCH] change update_score_and_comments to wrap args when calling update_score_and_comments on a quiz submission, the attempt is already in self and there will be only one item in the update list. this change wraps the passed arguments in a unary quiz_submissions list if quiz_submissions is not one of the parameters to the call. legacy behavior is preserved if quiz_submissions is in the calling parameters. --- canvasapi/quiz.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/canvasapi/quiz.py b/canvasapi/quiz.py index 1602fb0f..7aced99b 100644 --- a/canvasapi/quiz.py +++ b/canvasapi/quiz.py @@ -662,12 +662,19 @@ def update_score_and_comments(self, **kwargs): :returns: The updated quiz. :rtype: :class:`canvasapi.quiz.QuizSubmission` """ + args = dict(**kwargs) + if 'quiz_submissions' not in args: + # we need to wrap the parameters in a quiz_submissions list. + # there will only be one element because this object represents one attempt. + args['attempt'] = self.attempt + args = {'quiz_submissions': [ args ]} + response = self._requester.request( "PUT", "courses/{}/quizzes/{}/submissions/{}".format( self.course_id, self.quiz_id, self.id ), - _kwargs=combine_kwargs(**kwargs), + _kwargs=combine_kwargs(**args), ) response_json = response.json()["quiz_submissions"][0] response_json.update({"course_id": self.course_id})