I have been learning how to use Typst lately. I came from using LaTex then Quarto then Typst. I find Typst to be a lot more modern and easier to use than LaTex or Quarto. It has less boiler plate to get started than LaTex. It uses Markdown syntax just like Quartos. And it has a more robust scripting capability. One of the first thing I did with Typst was to create a Bingo card. Then I started using it to write my papers for my courses. Then one day while studying for one of my midterms. I realized I can use Typst to help me study by creating practice tests.
There is a part of the midterm where my prof has already told us what will be on it. We have to be able to match scripture passages to the corresponding doctrine that it teaches. I already took a similar course last semster by the same prof, so I have an idea of what the format of the midterm will look like. This mean that I can re-create a portion of the test (15% of it) using Typst. I thought this is a great idea because it will give me an excuse to use Typst and help me study for my midterm.
Below is the final Typst code that I used to generate the practice test. Click here to see the practice test it produced
|
|
Line 6-30, is used to define the dictionary used to store the questions. The verses and phrases are split in line 29-30 so that when I can shuffle the pharses without changing the order of the verses.
#let rng = gen-rng-f(20260301) in line 4 generates the seeds to get reproducible random numbers.
I use this later in line 32 #let (rng, phrase) = shuffle-f(rng, phrase) to shuffle the test questions around.
By changing the number in the parameters of gen-rng-f I can randomize the order of the questions.
Line 42-47 is the where I generate the list of questions. I created two counters in line 33 and 34, this is used later in line 45 to generate two different kind of counters. One numerically and one alphabetically.
Future Improvements
In the future I would also want it to generate an answer key.