Hello, I’m trying to use typst to generate random mcq from a set of questions.
Questions are grouped and each subject is build from a sample of questions from each group, then answers and selected questions are randomized
Currently, I write a subject as follow. The motivation is to be able to render the content of the subject without the generation step.
= Some Group
#metadata((kind: "group", sample: 1))
== Question
Statement
- #metadata((kind: "answer", correct: true)) Answer 1
- #metadata((kind: "answer", correct: false)) Answer 2
...
== Question
...
= Other groupe
...
Then, assuming this hierarchy, a function extract the groups/questions/answers from heading and list. From this data, I sample subjects and rendered all of them.
#show: body => {
let groups = mcq-extract(body)
let subjects = mcq-generate-subjects(groups, seed)
for subject in subjects {
let doc = mcq-format-subject(subject)
counter(page).update(1)
doc
pagebreak(to: "odd")
}
}
The directions I follow are :
- avoid state and context if possible
- the subject should render without the show rule
- final results should looks like Overview :: AMC and I must be able to extract all needed geometrical information (basically, all box positions and sizes
I successfully conduct a mcq but I feel I’m doing things wrong :
- the extraction is highly dependent on the document structure
- I cannot style per questions
- the show rule basically rewrites the whole document
I’m asking for guidance, how you would do, how you definitely won’t do…
