Betterquiz is a format and engine for creating multiple-choice tests and embedding them on websites in an iframe. It’s an open-source project hosted here.
For Bettercare, we create MCQ quizzes for books in kramdown-flavoured markdown. We then need to quickly convert them to BQF for uploading to our Betterquiz server.
This series of regex search-and-replaces turns a kramdown quiz file into a BQF file. In each case, the first line is the search, and the second line the replace (unless you should replace with nothing).
-
Remove numbers from questions.
Find (and replace with an empty line) lines starting with a number between 1 and 99, a dot, and a tab (regex background):
\n^[0-9]{1,2}\.\t \n\n
-
Remove the tab before bullet characters
–
and+
:\n\t([\-,\+])\t \n$1\t
-
Remove YAML
style:
style:.*\n
Note: You must manually add the book title. E.g.
title: Quiz 1. HIV Infection
must become
title: Adult HIV. Quiz 1. HIV Infection
-
Remove
#
heading, by replacing this with nothing:\n#(.*)\n
Also manually remove any
{% include metadata %}
tag. -
Remove the opening instruction phrase:
Please choose.*\n
-
Remove layout YAML, if any, by replacing this with nothing:
\nlayout: (.*)
-
Remove
-
s around YAML frontmatter, by replacing this with nothing:---\n
-
Remove markdown emphasis and strong elements with a non-regex search-and-replace to remove
*
.