From eb80c5c71ce625ca1ce98243ee38e37e4c886352 Mon Sep 17 00:00:00 2001 From: Maxime Augier Date: Tue, 4 Jun 2024 13:26:15 +0200 Subject: [PATCH] Fixes --- exam/lib.typ | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/exam/lib.typ b/exam/lib.typ index 2d44818..dc8c7d1 100644 --- a/exam/lib.typ +++ b/exam/lib.typ @@ -22,7 +22,13 @@ stop_value.at(0) - start_value.at(0) } -#let show_points(pts) = [#pts] + if pts < 2 { " pt" } else { " pts" } +#let show_points(pts) = if pts == 0 { + none +} else if pts == 1 { + [(1 pt)] +} else { + [(#pts pts)] +} // 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) } @@ -55,6 +61,7 @@ let date = if date == none { datetime.today() } else { date }; let year = if year == none { date.year() } else { year }; + let total = context [#pctr.final().at(0)] let indications = if indications == none { @@ -94,25 +101,37 @@ indications } + v(5%) + + align(right, text(size: 12pt, [Total: #total points])) + } pagebreak() set text(font: "Carlito", size: 12pt) - show heading: h => pad(bottom: 0.5em, text(fill: eastern, size: 16pt, weight: "light", [#(h.body) (#show_points(points_counter(h)))])) + show heading: h => pad(bottom: 0.5em, text(fill: eastern, size: 16pt, weight: "light", h.body + " " + show_points(points_counter(h)))) - set page(header: [#course #year - #title], footer: align(right, text(fill: gray, "Page ") + context counter(page).display("1 | 1", both: true))) + let head = text(fill: gray)[#course #year - #title]; + + set page(header: head, footer: align(right, text(fill: gray, "Page ") + context counter(page).display("1 | 1", both: true))) doc }; +// Bloc réponse caché en mode production #let reponse(a) = { let answ_block = block(width: 100%, inset: 1em, solution(a)); block(stroke: black, answ_block) + v(2em) } +#let notes(n) = if enable_notes { text(fill: red, n) } else { none }; + +// Question d'examen. Numérotée automatiquement, nombre de points optionnel +// (défaut 1), bloc de réponse automatique si 2e argument présent #let question(points: 1, q, ..a) = { context pctr.update(t => t + points) - let pts = strong([(#show_points(points))]); + let pts = strong(show_points(points)); context { qctr.step() } let num = context { qctr.display() };