fix(quizzes): remove chapter numbering from HTML quiz callouts

- Add numbered: false to quiz-question and quiz-answer groups in HTML config
- HTML now shows 'Self-Check: Question 3' instead of 'Self-Check: Question 1.3'
- PDF retains chapter numbering as configured in _quarto-pdf.yml
- Simple solution without changing quiz system or class names
This commit is contained in:
Vijay Janapa Reddi
2025-08-04 00:24:11 -04:00
parent 9a2d006520
commit a8d8f4ccc4
2 changed files with 27 additions and 10 deletions

View File

@@ -26,6 +26,9 @@ project:
preview:
browser: true
navigate: true
render:
- contents/core/introduction/introduction.qmd
- contents/core/ml_systems/ml_systems.qmd
website:
# High-level navigation enhancements
@@ -507,22 +510,24 @@ format:
custom-numbered-blocks:
groups:
quiz-question:
colors: ["E1F3F8", "119EC7"]
collapse: false
quiz-answer:
colors: ["FAEAF1", "980e5a"]
colors: ["E6F4F7", "119EC7"] # Updated to refined teal palette
collapse: true
numbered: false # Drop chapter numbering for HTML (PDF will keep it)
quiz-answer:
colors: ["E8F2EA", "4a7c59"] # Updated to muted forest green
collapse: true
numbered: false # Drop chapter numbering for HTML (PDF will keep it)
resource-slides:
colors: ["E9F3E3", "55984D"]
collapse: false
collapse: true
numbered: false
resource-videos:
colors: ["f9f5f0", "8b5e3c"]
collapse: false
collapse: true
numbered: false
resource-exercises:
colors: ["f7f0fa", "815AA4"]
collapse: false
collapse: true
numbered: false
chapter-connection:
colors: ["FDF2F7", "ED3237"]
@@ -536,7 +541,7 @@ custom-numbered-blocks:
numbered: false
chapter-recall:
colors: ["FFF4E6", "E67E22"]
collapse: false
collapse: true
numbered: false
classes:
callout-quiz-question:

View File

@@ -123,8 +123,20 @@ local function process_quiz_questions(questions, section_id)
table.insert(al, '<a href="#' .. qid .. '" class="answer-label">← Back to Questions</a>')
end
return create_quiz_div(qid, "callout-quiz-question", table.concat(ql, "\n\n")),
create_quiz_div(aid, "callout-quiz-answer", table.concat(al, "\n\n"))
-- Use different class names for HTML vs PDF to control numbering
local question_class, answer_class
if FORMAT == "latex" then
-- PDF: Keep chapter numbering (e.g., "Self-Check: Question 1.3")
question_class = "callout-quiz-question"
answer_class = "callout-quiz-answer"
else
-- HTML: Use classes without chapter numbering (e.g., "Self-Check: Question 3")
question_class = "callout-quiz-question-html"
answer_class = "callout-quiz-answer-html"
end
return create_quiz_div(qid, question_class, table.concat(ql, "\n\n")),
create_quiz_div(aid, answer_class, table.concat(al, "\n\n"))
end
-- 5) Meta phase: read one or more paths from meta.quiz