kj460
Community Novice

Getting list of Quiz Statistics

Hi all,

In my application, I'm making separate API calls for each Quiz object to get its Statistics.

And as a result of this, if the number of Quiz is large, sometimes it takes minutes to load the page.

Would there be a better way to achieve this without creating separate API calls for each Quiz to speed up the process?

FYI, I'm using python SDK to make requests.

Thank you!

Labels (1)
0 Kudos
1 Reply
kj460
Community Novice

I'm uploading the function that I created inside quiz.py that returns the statistics object:

# function declaration

def get_statistics(self, **kwargs):
   response = self._requester.request(
      'GET',
      'courses/{}/quizzes/{}/statistics'.format(self.course_id, self.id),
      _kwargs=combine_kwargs(**kwargs)
   )
   response_json = response.json()
   response_json['quiz_statistics'][0]['course_id'] = self.course_id

   return QuizStatistics(self._requester, response_json['quiz_statistics'][0])

# QuizStatistics class declaration

@python_2_unicode_compatible
class QuizStatistics(CanvasObject):
   def __str__(self):
   return "{} ({})".format(self.url, self.id)

Thanks

0 Kudos