cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
cmcdanie
Community Member

Add answers to question and receive CanvasException: Encountered an error: status code 500

Jump to solution

Hi,

I have added multiple choice quiz questions hundreds times to my course, but today I get an error when I run code that worked previously. Encountered an error: status code 500
I have narrowed the problem down to adding answer choices to multiple choice questions.
I see there has been a similar issue and I upgraded from canvasapi 0.12.0 to 2.2.0 and I run python 3.8.5. No luck.

This code works and creates a question with no answer choices:

quiz.create_question(question=dict(question_name='Question',
question_type='multiple_choice_question',
question_text='Here is a question',
points_possible=1.0))

This code generates the error:


quiz.create_question(question=dict(question_name='Question',
question_type='multiple_choice_question',
question_text='Here is a question',
points_possible=1.0,
answers=[{'text': 'Answer 1 is correct','weight': 100}, {'text': 'Answer 2 is incorrect','weight': 0}]
))

I tried manually adding the answers, requesting the question and passing back the dictionary with answers and no luck.

Any advice is appreciated,

Cara

0 Kudos
1 Solution

Accepted Solutions
0 Kudos
2 Replies
cmcdanie
Community Member

This did not fix the problem, but I shared a dictionary with answers formatted incorrectly. This is the dictionary that fails.

{'question_name':'Question',
'question_type':'multiple_choice_question',
'question_text':'Here is a question',
'points_possible':1.0,
'answers':[
{'answer_text': 'Answer 1 is correct',
'answer_weight': 100},
{'answer_text': 'Answer 2 is incorrect',
'answer_weight': 0}]}

0 Kudos