The fact that Canvas questions can be imported at all is awesome. However it’s rarely totally straight forward.
This is a deeper dive into the problems and the workarounds of just getting the file imported (not question content issues like broken images).
Same error but different causes
Canvas exports quizzes as QTI files (it’s in XML format). Sometime importing a QTI file into Moodle, the importer says there’s no questions in the file:
This one obtuse error message can have three possible causes.
Issue 1 : Canvas Question Banks
When you look at the QTI file in a text editor, indeed, there certainly is no questions:
The issue is in Canvas. The quiz is drawing questions from a question bank which simply don’t export the question items.
- Recreate the quiz in Canvas, but import the questions directly – don’t reference the question bank.
- Export to a new QTI file
- Import into Moodle
Issue 2: Canvas Grouped Questions
Sometimes you get the same message as above but when you view the QTI file, it’s is full of questions. What’s going on?
The source of error are Canvas’ Grouped Questions.
All <section></section> and selection_ordering></selection_ordering> tag elements need to be removed except for the first <section ident=”root_section”>…</section> tag element. The image below shows the offending lines of code in the QTI file:
Alternatively, you can recreate the Canvas quiz sans grouping. Note you will have a different number of questions – that’s the effect of un-grouping.
Useful RegEx for Advanced users:
(1) Find and Replace Section Pairs: FIND: ^(.*)<\/section>((.*|\n)*)\n(.*)<\/selection_ordering>\n REPLACE: (2) Find and Replace Section: FIND: ^(.*)<section ident=\"i((.*|\n)*)\n(.*)<\/selection_ordering>\n REPLACE: FIND: ^.*<\/section>\n REPLACE:
Issues 3: Canvas Broken XML
A bug with the Canvas QTI exporter means sometimes triggers this error message in a third way. Sometimes the encoded HTML within the QTI file spans multiple lines (it should be on a single line).
Simply edit the QTI file, removing the line breaks:
If you are comfortable with RegEx, you can make very short work of this issue:
Useful RegEX for Advanced users:
Find and Replace Line returns: FIND: gt;[\r\n\s]+& REPLACE: gt;&
Getting the QTI file read correctly can be one or a combination of issues above.