Deploy
This commit is contained in:
1 parent
8bbcf8ecd9
commit
45dd65b48e
116 files changed
+20457
-1164
No files matched your search
@@ -1,7 +1,7 @@
|
||||
e1b695980dee84de5bfa19ff7bfab6c2 README.md
|
||||
a86fced789dc540cf13974d26391c92d _extension.yml
|
||||
5b7e9e47a1d66e992b69f7ac91901349 README.md
|
||||
41f8fa1eb18e957e8423e0c97275af73 _extension.yml
|
||||
9037e06faf2c5fde7b3d614039652eed audit-page.js
|
||||
f9f1c739b8a198b3e9c2c087a5904f85 audit.py
|
||||
f6fbbba5aecc3141f06bf2aca93fccac audit.py
|
||||
a2f486f6e2dc382624f99801db209b75 calc-notes.css
|
||||
e9500e2554429fc8da7e9b2a6b51c8f1 calc-notes.js
|
||||
c06ae335d8506b347298d2a8f0e04ef2 calc-notes.lua
|
||||
@@ -20,9 +20,9 @@ e380e93d24a5968cc483dcbe48d99613 exo.css
|
||||
061f762946d63ea672d4f989f762baf7 latex-tables.css
|
||||
bab632a49553476bc5275b9c583f457e latex-tables.lua
|
||||
b846f2c4afd59aa0c9a328c71633425f narrow.css
|
||||
f5b63a6c6c5d3f9df63766ade2719ff2 quiz.css
|
||||
79e94885bf370abe27eeb6df81666946 quiz.js
|
||||
1695d57dcb6deb45f4fb2303dee6aa09 quiz.lua
|
||||
21b27640373cee858ad28cd9aaa1e858 quiz.css
|
||||
d03bb30f6a18c048173c24a0bcba5e24 quiz.js
|
||||
fb8f6092f6d5c3d2d407f8dac41bd2af quiz.lua
|
||||
2b8ca7ff531d30903bc41240e8b77691 si-mathjax.lua
|
||||
d32141259df2ce229400779c2ed284d9 sync.sh
|
||||
838bac386bf1e2b1e0323d91119c3632 theme.css
|
||||
@@ -31,6 +31,8 @@ exo:
|
||||
|
||||
quiz:
|
||||
pdf-answers: inline # PDF: answers under the quiz (default: end of chapter)
|
||||
points: 3 # points one question is worth (default 3)
|
||||
penalty: 1 # points one wrong statement costs (default 1)
|
||||
label: "Quiz" # labels follow `lang` (en/fr/de); override any of
|
||||
question: "Question" # label, question, answers, answer, check, reset,
|
||||
check: "Vérifier" # right, wrong, score, true, false, hint, page
|
||||
@@ -194,13 +196,29 @@ a single question). Numbering is chapter.n, as for exercises.
|
||||
|
||||
In HTML the options are real checkboxes and one **Check** button at the end of
|
||||
the quiz marks every option, reveals the explanations for the mistakes and
|
||||
scores the quiz; **Reset** clears it. A question counts as correct only when
|
||||
*all* of its options are in the right state — the exam's multiple-true-false
|
||||
rule.
|
||||
scores the quiz; **Reset** clears it. A question counts as correct — the
|
||||
verdict line — only when *all* of its options are in the right state, which is
|
||||
the exam's multiple-true-false rule.
|
||||
|
||||
In the PDF the boxes are empty, to tick with a pen, and the answers are
|
||||
printed at the end of the chapter with a page reference back to the quiz
|
||||
(`quiz: pdf-answers: inline` keeps them in place).
|
||||
**Points.** A question is worth `points` (default 3). Every statement whose box
|
||||
disagrees with its truth value costs `penalty` (default 1): an unticked true
|
||||
statement and a ticked false one both count as one miss. The result floors at
|
||||
zero, so three misses empty a 3-point question and a fourth cannot take the
|
||||
total negative. The quiz's headline is the sum over its questions, "4 of 6
|
||||
points". Set the pair book-wide under `quiz:` in `_quarto.yml`, or per quiz and
|
||||
per question:
|
||||
|
||||
```markdown
|
||||
::::{.quiz title="..." points="6" penalty="2"}
|
||||
::: {.question points="3"}
|
||||
```
|
||||
|
||||
A question's own attribute wins over the quiz's, which wins over the metadata.
|
||||
|
||||
In the PDF the boxes are empty, to tick with a pen, the points a question is
|
||||
worth are printed next to its heading, and the answers are printed at the end
|
||||
of the chapter with a page reference back to the quiz (`quiz: pdf-answers:
|
||||
inline` keeps them in place).
|
||||
|
||||
Correct answers are part of the built HTML, as solutions are: the quiz is a
|
||||
self-check, not an assessment.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
title: notes
|
||||
author: Matsune
|
||||
version: 2.8.18
|
||||
version: 2.9.0
|
||||
quarto-required: ">=1.4.0"
|
||||
contributes:
|
||||
filters:
|
||||
|
||||
@@ -83,6 +83,18 @@ def main():
|
||||
futs = {ex.submit(load, SHELLS[-1], f"http://127.0.0.2:{port}/{p}", w): (p, w) for p, w in jobs}
|
||||
for f in cf.as_completed(futs):
|
||||
results[futs[f]] = f.result()
|
||||
# Under load the little http server sometimes drops a file: a page then
|
||||
# gives no result, or loads without the extension (no ◐ button, no
|
||||
# narrow.css) and shows overflow that is not there. Retry those runs
|
||||
# alone, twice, before reporting them.
|
||||
def suspect(r):
|
||||
return "error" in r or not r.get("hasHcButton")
|
||||
for _ in range(2):
|
||||
again = [k for k, r in results.items() if suspect(r)]
|
||||
for p, w in again:
|
||||
r = load(SHELLS[-1], f"http://127.0.0.2:{port}/{p}", w)
|
||||
if not suspect(r) or "error" in results[(p, w)]:
|
||||
results[(p, w)] = r
|
||||
srv.shutdown()
|
||||
shutil.rmtree(os.path.dirname(dst), ignore_errors=True)
|
||||
|
||||
|
||||
@@ -113,6 +113,31 @@
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
/* ---- the per-question points badge ---------------------------------- */
|
||||
|
||||
/* The head now always exists (it is where the badge lands), so an empty one
|
||||
on a single-question quiz must not leave a gap. */
|
||||
.quiz-q-head:empty { display: none; }
|
||||
|
||||
.quiz-q-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.quiz-q-score {
|
||||
font-size: 0.82rem;
|
||||
font-weight: 400;
|
||||
color: var(--quiz-ink);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.quiz-q-score b { color: var(--calc-notecolor, #B45309); font-weight: 600; }
|
||||
/* green and red stay reserved for a judged answer; the badge follows the
|
||||
verdict right below it so the two never disagree */
|
||||
.quiz-q-score.quiz-ok b { color: var(--quiz-ok); }
|
||||
.quiz-q-score.quiz-bad b { color: var(--quiz-bad); }
|
||||
|
||||
/* ---- verdict and bar ------------------------------------------------ */
|
||||
|
||||
.quiz-verdict {
|
||||
@@ -160,6 +185,18 @@
|
||||
|
||||
/* ---- dark theme ----------------------------------------------------- */
|
||||
|
||||
/* High contrast remaps the whole palette, and --quiz-ok / --quiz-bad are local
|
||||
to this file, so they have to be pointed at the HC pair by hand: without
|
||||
this the verdict and the points badge keep their ordinary-mode green and
|
||||
red, which is exactly what a reader turns HC on to avoid. `body` makes it
|
||||
outweigh body.quarto-dark .quiz below, or dark + HC would keep the plain
|
||||
dark pair. */
|
||||
html.hc body .quiz {
|
||||
--quiz-ok: var(--hc-success);
|
||||
--quiz-bad: var(--hc-danger);
|
||||
--quiz-ink: var(--hc-fg);
|
||||
}
|
||||
|
||||
body.quarto-dark .quiz {
|
||||
--quiz-ok: #4cb08a;
|
||||
--quiz-bad: #e2798f;
|
||||
@@ -174,5 +211,8 @@ body.quarto-dark .quiz {
|
||||
*/
|
||||
@media print {
|
||||
.quiz-bar { display: none; }
|
||||
/* on paper the points are printed in the statement by quiz.lua, so the
|
||||
screen badge would say the same thing twice */
|
||||
.quiz-q-score { display: none; }
|
||||
.quiz-opt.quiz-ok, .quiz-opt.quiz-bad { background: none; }
|
||||
}
|
||||
+90
-33
@@ -1,16 +1,22 @@
|
||||
// quiz — judge the tick boxes of one quiz, explain what went wrong
|
||||
// quiz — judge the tick boxes of one quiz, score it in points, explain mistakes
|
||||
//
|
||||
// Every label the reader sees is written into the markup by quiz.lua, so the
|
||||
// wording follows the book's language and nothing is translated twice. A
|
||||
// quiz carries:
|
||||
// data-quiz-score "{n} of {m} questions correct" ({n}/{m} substituted)
|
||||
// data-quiz-right verdict of a question answered correctly
|
||||
// data-quiz-wrong verdict of a question answered wrongly
|
||||
// data-quiz-score "{n} of {m} questions correct"
|
||||
// data-quiz-points "{n} of {m} points" (the headline)
|
||||
// data-quiz-qpoints "{n}/{m} points" (one question's badge)
|
||||
// data-quiz-right verdict of a question answered correctly
|
||||
// data-quiz-wrong verdict of a question answered wrongly
|
||||
// and each question carries data-points / data-penalty.
|
||||
//
|
||||
// A question is right only when every one of its options is in the right
|
||||
// state: ticked when true, left empty when false. That is the "multiple
|
||||
// true/false" rule of the exam, and it is why a half-ticked question counts
|
||||
// as wrong.
|
||||
// SCORING. A question is worth data-points (default 3). Every statement whose
|
||||
// box disagrees with its truth value — an unticked true one, or a ticked false
|
||||
// one — costs data-penalty (default 1). The result floors at zero, so a
|
||||
// question can never drag the total down. The quiz total is the sum over its
|
||||
// questions. A question still counts as "correct" for the verdict line only
|
||||
// when every one of its statements is right, which is the exam's
|
||||
// multiple-true-false rule.
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
@@ -18,12 +24,41 @@
|
||||
return quiz.querySelectorAll(".quiz-opt");
|
||||
}
|
||||
|
||||
// Number(undefined) || 3 would also swallow a deliberate 0, so test first.
|
||||
function num(el, name, dflt) {
|
||||
var raw = el.dataset ? el.dataset[name] : null;
|
||||
if (raw === undefined || raw === null || raw === "") return dflt;
|
||||
var n = Number(raw);
|
||||
return isFinite(n) ? n : dflt;
|
||||
}
|
||||
|
||||
// Substitute {n} and {m} into a template from metadata, building text nodes
|
||||
// rather than markup: the template is author text, never trusted as HTML.
|
||||
function render(el, template, n, m) {
|
||||
el.innerHTML = "";
|
||||
var parts = template.split(/\{n\}|\{m\}/);
|
||||
var values = (template.match(/\{n\}|\{m\}/g) || []).map(function (token) {
|
||||
return token === "{n}" ? n : m;
|
||||
});
|
||||
parts.forEach(function (text, i) {
|
||||
el.appendChild(document.createTextNode(text));
|
||||
if (i < values.length) {
|
||||
var b = document.createElement("b");
|
||||
b.textContent = String(values[i]);
|
||||
el.appendChild(b);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function judge(quiz) {
|
||||
var questions = quiz.querySelectorAll(".quiz-q");
|
||||
var right = 0;
|
||||
var right = 0, scored = 0, available = 0;
|
||||
|
||||
questions.forEach(function (q) {
|
||||
var ok = true;
|
||||
var misses = 0;
|
||||
var pts = num(q, "points", 3);
|
||||
var pen = num(q, "penalty", 1);
|
||||
|
||||
q.querySelectorAll(".quiz-opt").forEach(function (opt) {
|
||||
var box = opt.querySelector(".quiz-box");
|
||||
@@ -34,13 +69,27 @@
|
||||
opt.classList.toggle("quiz-ok", hit);
|
||||
opt.classList.toggle("quiz-bad", !hit);
|
||||
|
||||
// the explanation of an option is for the reader who got it wrong
|
||||
var why = opt.querySelector(".quiz-why");
|
||||
// the explanation of an option is for the reader who got it wrong.
|
||||
// :scope > keeps this to the option's own .why — a question-level
|
||||
// .quiz-why-q also carries the class quiz-why.
|
||||
var why = opt.querySelector(":scope > .quiz-why");
|
||||
if (why) why.hidden = hit;
|
||||
|
||||
if (!hit) ok = false;
|
||||
if (!hit) { ok = false; misses++; }
|
||||
});
|
||||
|
||||
var got = Math.max(0, pts - misses * pen);
|
||||
scored += got;
|
||||
available += pts;
|
||||
|
||||
var badge = q.querySelector(".quiz-q-score");
|
||||
if (badge) {
|
||||
badge.hidden = false;
|
||||
render(badge, quiz.dataset.quizQpoints || "{n}/{m}", got, pts);
|
||||
badge.classList.toggle("quiz-ok", misses === 0);
|
||||
badge.classList.toggle("quiz-bad", got === 0 && pts > 0);
|
||||
}
|
||||
|
||||
var verdict = q.querySelector(".quiz-verdict");
|
||||
if (verdict) {
|
||||
verdict.hidden = false;
|
||||
@@ -60,22 +109,8 @@
|
||||
|
||||
var score = quiz.querySelector(".quiz-score");
|
||||
if (score) {
|
||||
var template = quiz.dataset.quizScore || "{n}/{m}";
|
||||
score.innerHTML = "";
|
||||
// built as nodes, not markup: the template comes from metadata
|
||||
var parts = template.split(/\{n\}|\{m\}/);
|
||||
var values = [];
|
||||
(template.match(/\{n\}|\{m\}/g) || []).forEach(function (token) {
|
||||
values.push(token === "{n}" ? right : questions.length);
|
||||
});
|
||||
parts.forEach(function (text, i) {
|
||||
score.appendChild(document.createTextNode(text));
|
||||
if (i < values.length) {
|
||||
var b = document.createElement("b");
|
||||
b.textContent = String(values[i]);
|
||||
score.appendChild(b);
|
||||
}
|
||||
});
|
||||
score.hidden = false;
|
||||
render(score, quiz.dataset.quizPoints || "{n}/{m}", scored, available);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +119,7 @@
|
||||
var box = opt.querySelector(".quiz-box");
|
||||
if (box) box.checked = false;
|
||||
opt.classList.remove("quiz-ok", "quiz-bad");
|
||||
var why = opt.querySelector(".quiz-why");
|
||||
var why = opt.querySelector(":scope > .quiz-why");
|
||||
if (why) why.hidden = true;
|
||||
});
|
||||
quiz.querySelectorAll(".quiz-verdict").forEach(function (v) {
|
||||
@@ -92,9 +127,14 @@
|
||||
v.textContent = "";
|
||||
v.classList.remove("quiz-ok", "quiz-bad");
|
||||
});
|
||||
quiz.querySelectorAll(".quiz-q-score").forEach(function (b) {
|
||||
b.hidden = true;
|
||||
b.textContent = "";
|
||||
b.classList.remove("quiz-ok", "quiz-bad");
|
||||
});
|
||||
quiz.querySelectorAll(".quiz-why-q").forEach(function (w) { w.hidden = true; });
|
||||
var score = quiz.querySelector(".quiz-score");
|
||||
if (score) score.textContent = "";
|
||||
if (score) { score.textContent = ""; score.hidden = false; }
|
||||
}
|
||||
|
||||
document.addEventListener("click", function (event) {
|
||||
@@ -112,15 +152,32 @@
|
||||
}
|
||||
});
|
||||
|
||||
// re-ticking a box after checking clears that row's verdict, so a stale
|
||||
// green or red never sits next to a box the reader has just changed
|
||||
// Re-ticking a box after checking clears that row's verdict, so a stale
|
||||
// green or red never sits next to a box the reader has just changed — and
|
||||
// with it the question's badge and the headline, which would otherwise
|
||||
// still claim a score for an answer that has since moved.
|
||||
document.addEventListener("change", function (event) {
|
||||
var box = event.target;
|
||||
if (!box.closest || !box.classList || !box.classList.contains("quiz-box")) return;
|
||||
var opt = box.closest(".quiz-opt");
|
||||
if (!opt) return;
|
||||
opt.classList.remove("quiz-ok", "quiz-bad");
|
||||
var why = opt.querySelector(".quiz-why");
|
||||
var why = opt.querySelector(":scope > .quiz-why");
|
||||
if (why) why.hidden = true;
|
||||
|
||||
var q = opt.closest(".quiz-q");
|
||||
if (q) {
|
||||
var badge = q.querySelector(".quiz-q-score");
|
||||
if (badge) { badge.hidden = true; badge.textContent = ""; }
|
||||
var verdict = q.querySelector(".quiz-verdict");
|
||||
if (verdict) { verdict.hidden = true; verdict.textContent = ""; }
|
||||
var qwhy = q.querySelector(".quiz-why-q");
|
||||
if (qwhy) qwhy.hidden = true;
|
||||
}
|
||||
var quiz = opt.closest(".quiz");
|
||||
if (quiz) {
|
||||
var score = quiz.querySelector(".quiz-score");
|
||||
if (score) score.textContent = "";
|
||||
}
|
||||
});
|
||||
})();
|
||||
+76
-21
@@ -54,23 +54,29 @@ local LABELS = {
|
||||
right = "Correct", wrong = "Not quite",
|
||||
score = "{n} of {m} questions correct",
|
||||
["true"] = "true", ["false"] = "false",
|
||||
hint = "Tick every statement you think is true.", page = "p." },
|
||||
hint = "Tick every statement you think is true.", page = "p.",
|
||||
qpoints = "{n}/{m} points", totalpoints = "{n} of {m} points",
|
||||
avail = "{m} points" },
|
||||
fr = { label = "Quiz", question = "Question", answers = "Réponses du quiz",
|
||||
answer = "Réponses", check = "Vérifier", reset = "Réinitialiser",
|
||||
right = "Correct", wrong = "Pas tout à fait",
|
||||
score = "{n} question(s) correcte(s) sur {m}",
|
||||
["true"] = "vrai", ["false"] = "faux",
|
||||
hint = "Cochez chaque énoncé que vous pensez vrai.", page = "p." },
|
||||
hint = "Cochez chaque énoncé que vous pensez vrai.", page = "p.",
|
||||
qpoints = "{n}/{m} points", totalpoints = "{n} points sur {m}",
|
||||
avail = "{m} points" },
|
||||
de = { label = "Quiz", question = "Frage", answers = "Quiz-Lösungen",
|
||||
answer = "Lösungen", check = "Prüfen", reset = "Zurücksetzen",
|
||||
right = "Richtig", wrong = "Nicht ganz",
|
||||
score = "{n} von {m} Fragen richtig",
|
||||
["true"] = "wahr", ["false"] = "falsch",
|
||||
hint = "Kreuzen Sie jede Aussage an, die Sie für wahr halten.", page = "S." },
|
||||
hint = "Kreuzen Sie jede Aussage an, die Sie für wahr halten.", page = "S.",
|
||||
qpoints = "{n}/{m} Punkte", totalpoints = "{n} von {m} Punkten",
|
||||
avail = "{m} Punkte" },
|
||||
}
|
||||
|
||||
local labels = {}
|
||||
local opts = { pdf_answers = "end" }
|
||||
local opts = { pdf_answers = "end", points = 3, penalty = 1 }
|
||||
|
||||
local TICKED, EMPTY = "\u{2612}", "\u{2610}" -- ☒ ☐, what pandoc's task_lists writes
|
||||
|
||||
@@ -119,6 +125,14 @@ local function read_meta(meta)
|
||||
if meta.quiz["pdf-answers"] ~= nil then
|
||||
opts.pdf_answers = str(meta.quiz["pdf-answers"])
|
||||
end
|
||||
-- numeric, so they go through tonumber and never through the label loop
|
||||
-- above: a label is a string, and arithmetic on a string fails silently.
|
||||
if meta.quiz.points ~= nil then
|
||||
opts.points = tonumber(str(meta.quiz.points)) or opts.points
|
||||
end
|
||||
if meta.quiz.penalty ~= nil then
|
||||
opts.penalty = tonumber(str(meta.quiz.penalty)) or opts.penalty
|
||||
end
|
||||
end
|
||||
|
||||
if quarto ~= nil and quarto.doc ~= nil then
|
||||
@@ -181,45 +195,68 @@ local function split_why(blocks)
|
||||
return body, why
|
||||
end
|
||||
|
||||
-- one question -> { statement = Blocks, options = { {ok, body, why} }, why = Blocks }
|
||||
local function parse_question(div)
|
||||
-- one question -> { statement, options = { {ok, body, why} }, why, points, penalty }
|
||||
-- `dflt` is what the quiz div (or the book metadata) set; a question may override
|
||||
-- either number with its own points= / penalty= attribute.
|
||||
local function parse_question(div, dflt)
|
||||
local statement, options, qwhy = pandoc.Blocks({}), {}, pandoc.Blocks({})
|
||||
for _, b in ipairs(div.content) do
|
||||
if is_why(b) then
|
||||
qwhy:extend(b.content)
|
||||
elseif b.t == "BulletList" then
|
||||
local consumed = true
|
||||
local found = {}
|
||||
-- Every item has to be a task item for the list to be the options. A
|
||||
-- list that is PARTLY ticked is almost always a typo rather than an
|
||||
-- ordinary bullet list in the statement, and silently swallowing it
|
||||
-- costs the author a whole question, so say so.
|
||||
local found, plain = {}, 0
|
||||
for _, item in ipairs(b.content) do
|
||||
local mark, blocks = task_marker(item)
|
||||
if mark == nil then consumed = false; break end
|
||||
local body, why = split_why(blocks)
|
||||
found[#found + 1] = { ok = (mark == TICKED), body = body, why = why }
|
||||
if mark == nil then
|
||||
plain = plain + 1
|
||||
else
|
||||
local body, why = split_why(blocks)
|
||||
found[#found + 1] = { ok = (mark == TICKED), body = body, why = why }
|
||||
end
|
||||
end
|
||||
if consumed and #found > 0 then
|
||||
if plain == 0 and #found > 0 then
|
||||
for _, o in ipairs(found) do options[#options + 1] = o end
|
||||
else
|
||||
if #found > 0 then
|
||||
io.stderr:write("[quiz] a bullet list mixes " .. #found
|
||||
.. " task item(s) with " .. plain .. " plain one(s), so none of it"
|
||||
.. " became options -- write every option as `- [x]` or `- [ ]`\n")
|
||||
end
|
||||
statement:insert(b) -- an ordinary bullet list belongs to the statement
|
||||
end
|
||||
else
|
||||
statement:insert(b)
|
||||
end
|
||||
end
|
||||
return { statement = statement, options = options, why = qwhy }
|
||||
local a = div.attributes or {}
|
||||
return {
|
||||
statement = statement, options = options, why = qwhy,
|
||||
points = tonumber(a.points) or dflt.points,
|
||||
penalty = tonumber(a.penalty) or dflt.penalty,
|
||||
}
|
||||
end
|
||||
|
||||
local function parse_quiz(el)
|
||||
local intro, questions = pandoc.Blocks({}), {}
|
||||
local a = el.attributes or {}
|
||||
local dflt = {
|
||||
points = tonumber(a.points) or opts.points,
|
||||
penalty = tonumber(a.penalty) or opts.penalty,
|
||||
}
|
||||
for _, b in ipairs(el.content) do
|
||||
if is_question(b) then
|
||||
questions[#questions + 1] = parse_question(b)
|
||||
questions[#questions + 1] = parse_question(b, dflt)
|
||||
else
|
||||
intro:insert(b)
|
||||
end
|
||||
end
|
||||
-- a quiz written without ::: {.question} is one question
|
||||
if #questions == 0 then
|
||||
local single = parse_question(el)
|
||||
local single = parse_question(el, dflt)
|
||||
if #single.options > 0 then
|
||||
return pandoc.Blocks({}), { single }
|
||||
end
|
||||
@@ -248,11 +285,16 @@ local function raw(fmt, text) return pandoc.RawBlock(fmt, text) end
|
||||
------------------------------------------------------------------ html
|
||||
|
||||
local function html_question(q, i, total)
|
||||
local out = pandoc.Blocks({ raw("html", '<div class="quiz-q">') })
|
||||
if total > 1 then
|
||||
out:insert(raw("html", '<p class="quiz-q-head"><strong>'
|
||||
.. esc_html(labels.question .. " " .. i) .. "</strong></p>"))
|
||||
end
|
||||
local out = pandoc.Blocks({ raw("html",
|
||||
'<div class="quiz-q" data-points="' .. tostring(q.points)
|
||||
.. '" data-penalty="' .. tostring(q.penalty) .. '">') })
|
||||
-- The head is emitted even for a one-question quiz: it is where the score
|
||||
-- lands after Check, so it cannot be conditional on there being a number.
|
||||
out:insert(raw("html", '<p class="quiz-q-head">'
|
||||
.. (total > 1
|
||||
and ("<strong>" .. esc_html(labels.question .. " " .. i) .. "</strong>")
|
||||
or "")
|
||||
.. '<span class="quiz-q-score" hidden></span></p>'))
|
||||
out:extend(q.statement)
|
||||
|
||||
out:insert(raw("html", '<ul class="quiz-opts">'))
|
||||
@@ -286,6 +328,8 @@ local function html_quiz(num, title, intro, questions)
|
||||
local out = pandoc.Blocks({ raw("html",
|
||||
'<div class="quiz" id="quiz-' .. esc_html(num) .. '"'
|
||||
.. ' data-quiz-score="' .. esc_html(labels.score) .. '"'
|
||||
.. ' data-quiz-points="' .. esc_html(labels.totalpoints) .. '"'
|
||||
.. ' data-quiz-qpoints="' .. esc_html(labels.qpoints) .. '"'
|
||||
.. ' data-quiz-right="' .. esc_html(labels.right) .. '"'
|
||||
.. ' data-quiz-wrong="' .. esc_html(labels.wrong) .. '">') })
|
||||
|
||||
@@ -319,8 +363,19 @@ end
|
||||
|
||||
local function latex_question(q, i, total)
|
||||
local out = pandoc.Blocks({})
|
||||
-- The points a question is worth are printed in the statement, because a
|
||||
-- reader working on paper has no Check button to tell them afterwards.
|
||||
local avail = fill(labels.avail, 0, q.points)
|
||||
if total > 1 then
|
||||
out:insert(pandoc.Para({ pandoc.Strong({ pandoc.Str(labels.question .. " " .. i) }) }))
|
||||
out:insert(pandoc.Para({
|
||||
pandoc.Strong({ pandoc.Str(labels.question .. " " .. i) }),
|
||||
enspace(),
|
||||
pandoc.RawInline("latex", "{\\small\\itshape (" .. esc_tex(avail) .. ")}"),
|
||||
}))
|
||||
else
|
||||
out:insert(pandoc.Para({
|
||||
pandoc.RawInline("latex", "{\\small\\itshape (" .. esc_tex(avail) .. ")}"),
|
||||
}))
|
||||
end
|
||||
out:extend(q.statement)
|
||||
|
||||
|
||||
Reference in new issue
Block a user