Community Explorer

Can I use the REST API to import a testbank?


I use R and Python to make many versions of similar questions, especially for STEM-oriented courses.  Essentially, in a quiz, each question is a question group that pulls from a specific testbank carefully crafted with hundreds of versions of a question ("formula quiz" functionality is limited in a number of ways, so I do the versioning myself outside of Canvas--plus, as far as I can tell, Canvas doesn't support the "cloze" format, only QTI).

I have no problem importing the many testbanks (again, one per question) in QTI format, but I have to do that work manually (which adds up for midterms and finals...sigh).  I'm comfortable with the API and I mostly use UCF's (thank you!) Python package.  However, I don't see any REST API (or more recently, GraphQL) functionality on the Canvas API documentation page for the "import" process in Canvas.

1) Can I just upload a testbank as a regular file (uploading files can indeed be automated via the API), make sure it's private, and then, somehow, tag it as a testbank to be used for quizzes only?

2) Am I missing an API call for the import functionality in Canvas?

3) Or?




Labels (1)
0 Kudos
5 Replies
Community Explorer

I have been told there is not one. Additionally, this thread, though a little old, says the same thing.


HOWEVER, Respondus is somehow able to create test banks through their desktop tool, so there must be some work around. Hopefully someone else is able to provide more information.


0 Kudos

I'm posting in hopes of being helpful to anyone who stumbles on this thread. There seems to be some confusion regarding quiz QTI import via the API. It is not only possible, but works pretty well. I don't use the question banks (posting a new quiz via the API is MUCH faster in my workflow) so I don't know how they are structured. However, if it is in a QTI format, there is no reason it cannot be done. I can import multiple QTI-structured quizzes packaged into a single zipped file via the API within a few seconds.

The process is not obvious, but the API is documented:


To employ the API, you must first understand how to upload a file to canvas. After that, importing a QTI is trivial. 

Unfortunately, giving someone step by step instructions on how to accomplish this isn't practical at this point. However, if someone is interested, I'm happy to facilitate.



Thank you so much!

Canvas does not have any published API method for creating question banks. The workaround I'm looking at is importing QTI files. That way it is possible to create the question banks.

Your answer provides the path I need.

0 Kudos

Hello @wayne_smith  thanks for your post and sorry its taken some time to respond to this with an accepted solution, although @jhveem is completely right. There is not an API currently for importing of QTI files and the respective formatting of those QTI files. 

I answered a similar question in this thread: Dates not honored when QTI package imported via Canvas API

Right now this does seem like a limitation as we do not have documentation regarding this. I would suggest to create a feature idea request in order to get better documentation regarding QTI file formatting as well as further documentation to be able to import quiz questions in QTI files via API. https://community.canvaslms.com/t5/Idea-Conversations/idb-p/ideas/status-key/complete

0 Kudos
Community Explorer

Looks as though you've sorted this out.

Indeed, there does not appear to be any API support for testbanks. That said, QTI-imported quizzes are automatically added to a testbank — I've found no way to control this 'feature'. I'd like to know if it can be prevented. I suspect this is just an automated backend process. While I script for 1 quiz at a time to upload, one can upload multiple quizzes in a single shot, but the QTI format is more complex from an implementation standpoint. I suspect you are aware that QTI is simply a zipped folder containing a group of organized xml files. If you are not aware, simply download a group of quizzes from Canvas, manually change the trailing extension to zip, decompress, and you'll see the structure. The manifest.xml file is what Canvas uses for context when dealing with the upload and associated files. Finally, if you attempt to implement your own solution, cool, however reach out because there are some Canvas-specific pitfalls where they do not adhere to the QTI standard and if one tries to upload any file that begins with a number, it gets ignored. This is not documented and is a huge issue when random UUIDs are needed for building questions and quizzes using the QTI schema.

One suggestion on ensuring a file is private ... upload files to a folder where access is limited to those having the appropriate link.

Good luck