Prototype better syntax for QCM
This commit is contained in:
parent
a04f6296cf
commit
f08c30f12b
BIN
exam/demo.pdf
BIN
exam/demo.pdf
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
#import "@y-sec/exam:0.1.0": exam, question, reponse, choix
|
||||
#import "@y-sec/exam:0.1.0": exam, question, reponse, qcm
|
||||
#show: exam(
|
||||
title: "Examen en Typst",
|
||||
subtitle: "Y-Security - Typst Essentials",
|
||||
@ -57,6 +57,12 @@ de la fonction `exam`. La valeur par défaut est:
|
||||
|
||||
#question[Préféréz-vous les questions à choix multiples ?]
|
||||
|
||||
#qcm[
|
||||
- Clairement oui <yes>
|
||||
- Pas trop
|
||||
- La réponse D <yes>
|
||||
]
|
||||
|
||||
= Comptage des points
|
||||
|
||||
#question(points: 5)[Comment changer la valeur en points de la question ?]
|
||||
|
21
exam/lib.typ
21
exam/lib.typ
@ -9,6 +9,7 @@
|
||||
#let enable_notes = { compile_mode == "notes" };
|
||||
|
||||
|
||||
|
||||
#let points_counter(h) = {
|
||||
// Find the first heading at a level equal or lower (more important) than this one
|
||||
let headings_after = query(selector(heading)
|
||||
@ -26,11 +27,25 @@
|
||||
// Rend les réponses visibles seulement si compilé avec `--input mode=solution`
|
||||
#let solution(content) = if enable_solutions { set text(fill: olive); content } else { hide(content) }
|
||||
|
||||
#let choix(rep, content) = {
|
||||
if rep and solution_mode { "☒ " } else { "☐ " }
|
||||
content
|
||||
#let qcm(qcm_list) = {
|
||||
//let checked_box = "☑";
|
||||
//let unchecked_box = "☐";
|
||||
let checked_box = box(stroke: black, outset: 0.2em, "X") + " ";
|
||||
let unchecked_box = box(stroke: black, outset: 0.2em, hide("X")) + " ";
|
||||
set list(marker: unchecked_box, indent: 2em)
|
||||
if enable_solutions {
|
||||
show <yes>: i => {
|
||||
show box: b => checked_box;
|
||||
set text(fill: olive);
|
||||
i
|
||||
};
|
||||
qcm_list
|
||||
} else {
|
||||
qcm_list
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#let exam(title: "Exam", course: none, date: none, class: none,
|
||||
year: none, author: none, subtitle: none, indications: none,
|
||||
time: none, allowed: none) = doc => {
|
||||
|
Loading…
Reference in New Issue
Block a user