Broken on Import


he 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:

No questions to import error.
Error: There are no questions in the import 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:

File too short to be have any questions.

Cause

The issue is in Canvas. The quiz is drawing questions from a question bank which simply don’t export the question items.

Workaround

  1. Recreate the quiz in Canvas, but import the questions directly – don’t reference the question bank.
  2. Export to a new QTI file
  3. 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?

Plenty of data but doesn’t import. What’s going on?

Cause

The source of error are Canvas’ Grouped Questions.

Workarounds

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

Cause

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).

Encoded HTML split over multiple lines.

Workaround

Simply edit the QTI file, removing the line breaks:

Encoded HTML on a single line.

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;& 

Summary

Getting the QTI file read correctly can be one or a combination of issues above.




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.