Directly inserting different types of quizzes via the API

In trying to understand how to insert different types of quizzes into Canvas I made a couple program to experiment with inserting a particular type of quiz:

Download insert_match_quiz.py

 - for matching type quizzes

Download insert_multiple_answers.py

 - where there are multiple answers to choose from

Download insert_multiple_dropdown_quiz.py

and Download insert_multiple_dropdown_quiz2.py - for match type questions and matrix type questions (respectively).

Please ignore the random mix of English in Swedish in the "questions" and "answers" - these are not intended to be either correct or complete, only structurally similar to questions that I was trying to insert.


Along the way, I found that Canvas assumes that all questions of the types: missing_word, multiple_answers, and multiple_choice must have a correct answer and if they do not, the code turns the first answer into a "correct" answer - even though it is incorrect by using: "@answers.set_correct_if_none"

See app/models/quizzes/quiz_question/answer_parsers/

  • missing_word.rb
  • multiple_answers.rb
  • multiple_choice.rb

This is issue is further described at https://kth.instructure.com/courses/11/pages/canvas-turns-first-answer-into-the-correct-answer-even-if-it-is-incorrect-when-there-are-not-correct-answers