From 8f3a5f4ce759ab9788a760dfe4bf97c40ee7c1b2 Mon Sep 17 00:00:00 2001 From: Maxime Augier Date: Wed, 22 May 2024 19:24:29 +0200 Subject: [PATCH] Tweaks --- demo.typ | 8 +++++-- exam.typ | 73 +++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/demo.typ b/demo.typ index f12aa5f..437a6a3 100644 --- a/demo.typ +++ b/demo.typ @@ -6,12 +6,15 @@ date: datetime(year: 2024, month: 5, day: 27), author: "Maxime Augier", indications: [ -Indications: - Ce test doit être réalisé en maximum *45 minutes*. + - Aucun document n'est admis, excepté une page A4 (recto-verso) de résumé personnel + - L'utilisation de tout type de matériel électronique est interdite. + - Ne pas oublier d'inscrire votre nom et prénom à l'endroit prévu à cet effet. + - Merci de respecter un silence absolu jusqu'à ce que le dernier étudiant aie rendu sa copie ], @@ -20,13 +23,14 @@ Indications: = Web + Vous opérez l’infrastructure d'une association de hackers amateurs, et remarquez un comportement étrange sur votre serveur web. Vous lisez les logs de votre serveur web, et observez plusieurs requêtes suspectes, par exemple l’URL suivante : `https://hackerz-club.ch/forum/browse.php?category=XSS&sort=post_date+union+select+%2A+from+users` -#question[Quel est le nom usuel de la vulnérabilité exploitée +#question[Quel est le *nom usuel* de la vulnérabilité exploitée ci dessus ?][Injection SQL (dans une clause ORDER BY)] #question(points: 2)[Quel est l'effet de l'attaque ?][Le vol de la table `users` de la base de données] diff --git a/exam.typ b/exam.typ index d79a1d7..362f168 100644 --- a/exam.typ +++ b/exam.typ @@ -1,42 +1,71 @@ #let qctr = counter("question") +#let pctr = counter("points") #let french_month = ("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre") +#let points_counter(h) = { + // Find the first heading at a level equal or higher than this one + let headings_after = query(selector(heading) + .after(h.location()) + ).filter(nh => nh.level >= h.level); + + let start_value = pctr.at(h.location()) + let stop_value = if headings_after.len() == 0 { pctr.final() } + else { pctr.at(headings_after.last().location()) } + stop_value.at(0) - start_value.at(0) +} + +#let show_points(pts) = [#pts] + if pts < 2 { " pt" } else { " pts" } + +// Rend les réponses visibles seulement si compilé avec `--input grading=true` +#let grading(content) = if sys.inputs.at("grading", default: "solution") == "solution" { set text(fill: olive); content } else { hide(content) } + #let exam(title: "Exam", course: none, date: none, class: none, -author: none, subtitle: none, indications: none, doc) = { + author: none, subtitle: none, indications: none, doc) = { - set text(font: "Montserrat") + { + set text(font: "Montserrat") - let date = if date == none { datetime.today() } else { date }; + let date = if date == none { datetime.today() } else { date }; - align(center, text(size:26pt, course + " - " + date.display("[year]"))) - align(center, text(size:26pt, title)) - align(center, text(size:15pt, fill: luma(80), subtitle)) - v(5%) - align(center, text(size:14pt, author)) - v(3%) - align(center, text(size:14pt, date.display("[day] ") + french_month.at(date.month() - 1) + date.display(" [year]"))) + align(center, text(size:26pt, course + " - " + date.display("[year]"))) + align(center, text(size:26pt, title)) + align(center, text(size:15pt, fill: luma(80), subtitle)) + v(5%) + align(center, text(size:14pt, author)) + v(3%) + align(center, text(size:14pt, date.display("[day] ") + french_month.at(date.month() - 1) + date.display(" [year]"))) - v(7%) - align(left, text(size: 20pt, "Nom :")) - align(left, text(size: 20pt, "Prénom :")) - v(3%) + v(7%) + align(left, text(size: 20pt, "Nom :")) + align(left, text(size: 20pt, "Prénom :")) + v(3%) - line(length: 100%, stroke: luma(80)) + line(length: 100%, stroke: luma(80)) + v(3%) + + text(size: 16pt, "Indications :") + { + set text(size: 12pt) + set list(marker: "●", indent: 2em, body-indent: 1em) + indications + } - text(size: 14pt, indications) + } 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)))])) doc }; #let question(points: 1, q, a) = { - let pts = text(weight: "bold", - [#points] + if points < 2 { "pt" } else { "pts" }); + context pctr.step() + let pts = strong([(#show_points(points))]); - context { qctr.step(); qctr.display() } - q + let num = context { qctr.step(); qctr.display() } + [#num) #q #pts] + let answ_block = block(width: 100%, inset: 1em, grading(a)); + block(stroke: black, answ_block) }