molpopgen / md2Canvas

Examples of canvas questions written in Markdown
5 stars 1 forks source link

Examples of generating Canvas "quizzes" using Markdown

This repo gives several examples of Geoffrey Poore's text2qti to generate Canvas quizzes using Markdown.

The advantages of this approach are:

The disadvantages are:

General comments

Python dependencies

The Python dependencies are listed in reuirements.txt. Install them via:

pip3 install -r requirements.txt

Or, if you don't clone this repo:

pip3 install text2qti numpy pandas

If you use conda (or brew), feel free to install pandas and numpy using those tools.

Other dependencies

From the above list, only pandoc is truly required. The others are used for specific example questions:

How to install these

Linux

They are available via your distro's package manager

macOS/Windows

I recommend conda. Windows 10 users can probably use a Linux installation of conda into the bash/Ubuntu subsystem.

Gotchas

Building the quizzes

For each markdown file, execute

text2qti --run-code-blocks --pandoc-mathml foo.md

Note that foo.md is a placeholder. Your actual quiz will have a name like Lecture1.md and the quiz names provided here are visible in quizzes/.

One a Unix-like system (Linux, macOS, or Windows 10 with the bash subsystem), the Makefile will build the examples in quizzes:

cd quizzes
make

Gotchas

Image generation with Inkscape and krita

Inkscape and krita are two open source programs for creating images. The former is a vector graphics package, works through svg files and is well-suited for technical diagrams. The latter is a very capable drawing program. As with their Adobe counterparts, both have fairly steep learning curves. One very nice feature is that both provide command line interfaces for exporting to standard graphics formats. The following show the terminal commands and the corresponding Makefile rules for converting svg and krita files to png.

For inkscape svg, the terminal command is

inkscape --export-png image.png -D image.svg

The corresponding make rule is:

%.png: %.svg
    inkscape --export-png $@ -D $<

For krita, we have:

krita --export image.kra --export-filename image.png
%.png: %.kra
    krita --export $@ --export-filename $<

Both programs have more options to control the output dpi, etc., and convert can be used for resizing, etc..

The advantage of this approach is that you only ever need to store your inkscape and krita files. (Both formats are not very git-friendly, however.)

Uploading to Canvas

Settings -> Upload Course Content and probably create a new question bank. Remember to "bookmark" it if it is uploaded to a "sandbox" course. You'll also need to burn sage or perform a sacrifice of some sort.

Advanced example of coupled questions

Canvas does not support a question group from which two questions are pulled where they both use the same data, or the answer of the second builds on the answer to the first. A workaround is given in quizzes/quiztemplate.md, where we change the work flow:

My approach to building these metaprogramming quizzes again uses a Makefile. However, I use a potentially non-portable trick to use the bash shell for file pattern expansion. Thus, I've written a separate Makefile, which you can execute as:

cd quizzes
make -f Makefile.quiztemplate