Commit Graph

22 Commits

Author SHA1 Message Date
Zeljko Hrcek
56f310c476 Make new margin note box
Created a new callout block with a custom Lua filter that places it in the margin for PDF output.
2025-07-15 16:43:56 +02:00
Zeljko Hrcek
c89b9162cc Fix: quiz answers now inserted before part block if needed 2025-07-11 12:44:37 +02:00
Vijay Janapa Reddi
c8d0c333a8 Enhances quiz injection and part handling
Improves the quiz injection process by enhancing part header detection and flushing chapters/sections correctly.

- Refactors chapter/section flushing logic to ensure quizzes are inserted at the appropriate locations.
- Improves robustness of "part" header detection.
- Simplifies debug logging.
2025-07-08 00:23:45 -04:00
Vijay Janapa Reddi
8e72881719 Refactors quiz injection logic
Improves quiz injection process by restructuring the code to handle chapter and section processing more efficiently.

This change introduces a `flush_chapter` function to handle the insertion of self-check answers at the end of each chapter, along with associated logging. It also updates the main loop to process chapters and sections sequentially, ensuring quizzes are inserted correctly and consistently.
Removes extraneous title extraction logic and simplifies the overall quiz injection workflow.
2025-07-07 21:14:34 -04:00
Vijay Janapa Reddi
131200805b Adds quiz configuration options
Introduces configurable options for quiz injection,
including file pattern, scan directory, and auto-discovery
behavior for PDF builds. This allows for greater
flexibility in managing quiz files and their integration
into the document.

Additionally adds debug logging for config values.
2025-07-07 20:57:19 -04:00
Vijay Janapa Reddi
8a4bd94765 Enables auto-discovery of quiz files for PDF builds
Improves quiz loading for combined PDF documents (books) by automatically discovering and processing quiz files located within a specified directory.

This change addresses the issue of quiz files not being loaded correctly when Quarto combines multiple files into a single PDF document. It now searches for quiz files in the "contents/core" directory and automatically loads them, streamlining the quiz injection process.

Also adds extra debugging output to help diagnose issues and improves chapter title extraction for better context during quiz insertion.
2025-07-07 20:25:29 -04:00
Vijay Janapa Reddi
f17a686d4d Enhances quiz loading and insertion process
Improves quiz functionality by providing detailed logging and error reporting during the loading and insertion of quiz sections.

Tracks the source file for each quiz section, providing better traceability.

Adds comprehensive summary reports to show the success and failure rates of file loading and section insertion, and provides a breakdown of sections by file.

Updates logging messages to improve clarity and informativeness.
2025-07-07 15:50:57 -04:00
Vijay Janapa Reddi
24ba54c725 Adds Self-Check Answers section header
Adds a section header before the Self-Check Answers
to improve document structure and readability.
2025-07-06 18:46:04 -04:00
Vijay Janapa Reddi
0f5b179c94 Improves quiz injection and logging
Refactors quiz injection logic to streamline the process.

Removes verbose logging statements that cluttered the output.

Adds a check to prevent processing files with no quizzes.

Now only inserts answer sections if needed.
2025-07-06 18:42:38 -04:00
Vijay Janapa Reddi
675accc860 Updates quiz identifier generation
Changes quiz identifiers to a more descriptive format.
This improves quiz tracking and debugging.

Ensures quiz sections are correctly identified by checking
for header level 2.
2025-07-06 18:17:21 -04:00
Vijay Janapa Reddi
8fec1aac84 Improves quiz navigation
Adds newline characters to quiz question and answer links
for better readability and spacing in the rendered output.
Also updates the "See Answer" and "Back to Question" labels
to use more appropriate phrasing.
2025-07-06 11:15:56 -04:00
Vijay Janapa Reddi
f48b891b08 Fixes quiz injection in nested sections
Ensures quizzes are injected correctly in nested
sections by tracking section levels and flushing
previous sections only when encountering a header
of the same or higher level. Also resets quiz flags
when a section without a quiz is encountered.
2025-07-03 12:02:55 -04:00
Vijay Janapa Reddi
e6d558dd62 Improves quiz loading and processing clarity
Enhances the quiz injection process by adding more descriptive
logging messages with clearer formatting. This improves
debuggability and provides better feedback during quiz loading,
registration, question processing, and insertion. Includes
status indicators and section identifiers in the logs.
2025-07-02 21:17:13 -04:00
Vijay Janapa Reddi
ecd30db6c8 Refactors quiz injection for section-based processing
Improves quiz injection by processing quizzes section by section.
This allows for better organization and avoids premature flushing
of answers when quizzes appear within a section, especially in
longer chapters. Also, formats the choices in questions and answers with line breaks.
2025-07-02 21:15:25 -04:00
Zeljko Hrcek
b67920c932 LUA filter for quizzes has been fixed
Fixed Lua filter to enable inserting questions and answers in PDF output.
Added automatic numbering for question and answer blocks.
Matched block header font in HTML output with the book’s main font.
2025-07-02 13:12:46 +02:00
Vijay Janapa Reddi
ff15086836 Script will inject quizzes automatically from the JSON files 2025-07-01 09:27:43 -04:00
Vijay Janapa Reddi
440fb1d815 Enhances quiz numbering and chapter detection
Improves the quiz functionality by adding chapter number prefixes to quiz numbers for better organization and context.

It implements a robust chapter number detection mechanism, first attempting to extract the chapter number from the book metadata, then falling back to parsing the input file path or working directory. A default value of 1 is used if all methods fail.

This change also updates the "Back to Question" link in the answer section to include the quiz number.
2025-07-01 07:17:25 -04:00
Vijay Janapa Reddi
e7be68ae52 Adds section number to quiz answer links
Enhances quiz navigation by including the section
number in the "See Answer" link, improving user
experience and clarity.

This change allows users to easily identify which
section the answer corresponds to, especially in
documents with multiple quizzes.
2025-07-01 06:47:47 -04:00
Vijay Janapa Reddi
80b3a8fa70 Improves quiz block formatting and navigation
Updates quiz block formatting to use a link for "See Answers"
instead of a raw markdown reference.

Adds a "Back to Self-Check Questions" link to the answer block,
improving navigation between questions and answers.

Updates regex for question id gsub to handle `#sec-` prefixes.
2025-06-30 15:54:19 -04:00
Vijay Janapa Reddi
d670c916d4 Improves quiz injection with JSON data
Refactors the quiz injection filter to load quiz data from JSON files specified in the YAML metadata.

This includes:

- Implements more robust path resolution for quiz files, handling cases where the file might be in different locations relative to the pandoc process.
- Switches from markdown string building to using pandoc's structured document representation, allowing for easier and more reliable formatting of quiz questions and answers.
- Supports multiple choice, fill-in-the-blank, short answer, and ordering questions.
- Adds a "Self-Check Answers" section at the end of the document containing formatted answers and learning objectives.
2025-06-30 15:45:15 -04:00
Vijay Janapa Reddi
8103144a69 Adds quiz injection from JSON files
Implements a Lua filter that injects quizzes and answers into the Pandoc document from a JSON file specified in the YAML metadata.

The filter searches for the quiz file in multiple locations and registers sections for quiz injection. It formats quiz questions as markdown callouts and collects answer blocks to be appended at the end of the document under a "Self-Check Answers" section. This provides a mechanism for embedding interactive quizzes directly into course content.
2025-06-30 12:22:01 -04:00
Vijay Janapa Reddi
2575c574f7 Formats quizzes as callout blocks
Formats quizzes as callouts with answers section.

Enhances quiz presentation by formatting them as callouts.

Compiles all answers in a dedicated section, improving user experience.
2025-06-19 13:00:23 -04:00