简体   繁体   中英

Canvas LMS REST API Quiz creation

I'm having an issue with quiz creation using the Canvas REST API:

I can create a new quiz with title set.

I can add N questions with the following parameters set:

  • question_name
  • question_text
  • question_type
  • points_possible
  • answers

When I look at my quizzes page, I can see the quiz exists, but it only shows that 1 question has been created for the quiz. I have to go to the quiz page, click the Edit button and then save the quiz for all of the questions to show up on the quizzes page.

What am I missing in this workflow?

So, for anyone interested in this question, the best solution I've been able to find is a hack. I tried doing comparisons of the quiz model data structure returned both before and after manually saving the quiz. There were some trivial differences, but only a couple meaningful ones. The only relevant difference was in the question_count attribute. It isn't being updated after adding questions.

To "fix" this : after adding your questions, manually update the question_count attribute (via a PUSH ).

Perhaps this is a bug, perhaps I don't know what I'm doing. Either way, if anyone else has a better understanding of the Canvas REST API, please comment or provide a better answer.

Just ran into this same issue and here's a possible fix: Create the quiz first with published set to False . Add your questions. Then edit the quiz ( https://canvas.instructure.com/doc/api/quizzes.html#method.quizzes/quizzes_api.update ) to set published to True . Then add any overrides, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM