Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
Found this content helpful? Log in or sign up to leave a like!
I use this python library
pip install canvasapi
I am successfully created a new quiz via a Python API
I use the following code to create questions for a quiz (that's online part of a bigger code)
def fillQuizWithQuestions(quiz_template_questions, new_quiz):
for quiz_template_question in quiz_template_questions:
quiz_question = new_quiz.create_question(question = {
'question_name':quiz_template_question.question_name,
'question_text':quiz_template_question.question_text,
'quiz_group_id':quiz_template_question.quiz_group_id,
'question_type':quiz_template_question.question_type,
'position':quiz_template_question.position,
'points_possible':quiz_template_question.points_possible,
'correct_comments':quiz_template_question.correct_comments,
'incorrect_comments':quiz_template_question.incorrect_comments,
'neutral_comments':quiz_template_question.neutral_comments,
'answers':quiz_template_question.answers
})
When I run this code on Canvas Test ( myeducationcompany.test.instructure.com )
Everything runs fine.
But if I try to run this on Canvas Beta ( myeducationcompany.beta.instructure.com ) or Canvas Production( myeducationcompany.instructure.com ). I got an error
quiz_question = new_quiz.create_question(question = {
File "C:\Users\Ideapad320\AppData\Local\Programs\Python\Python39\lib\site-packages\canvasapi\quiz.py", line 62, in create_question
response = self._requester.request(
File "C:\Users\Ideapad320\AppData\Local\Programs\Python\Python39\lib\site-packages\canvasapi\requester.py", line 262, in request
raise CanvasException(
canvasapi.exceptions.CanvasException: Encountered an error: status code 500
Why this code run on Canvas Test, but it does not work on Canvas Beta or Canvas Production?
Any idea of how to fix that problem?
To participate in the Instructure Community, you need to sign up or log in:
Sign In