Commit Graph

228 Commits

Author SHA1 Message Date
Vijay Janapa Reddi
9fb7e14876 Removes and re-adds several image files.
This commit removes several existing image files
and re-adds them. This is likely due to some
process that needed to be run over all images,
or that they were unintentionally removed
before.

Updates image validation script to include autofix
functionality to address format mismatches.
2025-07-11 21:53:02 -04:00
Vijay Janapa Reddi
b7395d942c Adds script to extract headers from .qmd files
Creates a script that extracts section headers from .qmd files,
outputting them in a formatted table showing filename, header level,
and header text. It supports processing either a single file or all
.qmd files within a directory.
2025-07-11 18:09:22 -04:00
Vijay Janapa Reddi
8d72833ecf Adds image validation pre-commit hook
Adds a pre-commit hook to validate image files.
This ensures that images are not corrupted and have the correct format.

Also, renames several png images to jpg or gif and updates references in the qmd files.
2025-07-11 18:09:15 -04:00
Vijay Janapa Reddi
d955f9be5c Updates section IDs and quiz JSON files
Ensures consistency between section IDs in QMD files and corresponding references in quiz JSON files. The script now automatically updates these references when section IDs change, maintaining synchronization between content and assessments.
2025-07-06 19:03:18 -04:00
Vijay Janapa Reddi
07aa99e7f0 Enhances quiz generation with dynamic book context
Improves quiz question quality and relevance by providing the LLM with contextual information about the textbook structure and chapter progression.

- Introduces dynamic book outline generation from `_quarto.yml`, enabling the LLM to understand chapter dependencies and progression.
- Enhances the prompt with chapter context, difficulty guidelines, and previous quiz data.
- Implements real-time progress tracking for parallel quiz generation, providing better visibility into the process.
- Adds thread safety measures to prevent conflicts during book outline generation.
2025-07-06 09:15:50 -04:00
Vijay Janapa Reddi
ade2045bb7 Adds script to delete old workflow runs
Adds a script that uses the GitHub CLI to delete all but the most recent GitHub Actions workflow run.

This helps to keep the number of runs manageable and avoid exceeding storage limits.
2025-07-02 16:57:09 -04:00
Vijay Janapa Reddi
d1e798a2b8 Automates TeX Live package management
Replaces the manual package extraction script with an automated tool.

This tool analyzes project files, extracts LaTeX package dependencies,
and generates a list of required TeX Live packages and collections.
It improves maintainability and ensures all necessary packages are
installed. The pre-commit configuration is updated to run this tool
automatically before committing changes.
2025-07-02 15:04:20 -04:00
Vijay Janapa Reddi
5ca0ec9bdd Adds script to extract TeX Live packages
Implements a script that analyzes Quarto projects to
automatically extract LaTeX package dependencies. The script
parses both TEX header files and Quarto YAML configurations
to identify required TeX Live packages and collections. It then
uses `tlmgr` to map LaTeX package names to their corresponding
TeX Live packages, streamlining the dependency installation
process for building Quarto projects.
2025-07-02 14:41:04 -04:00
Vijay Janapa Reddi
6c2d2ed820 Counts quiz answer sections.
Adds functionality to count the number of quiz answer sections
within a QMD file during the cleaning process. This allows for
more comprehensive analysis of the file's structure, especially
when using the dry-run option.
2025-06-30 12:25:12 -04:00
Vijay Janapa Reddi
bad6c5fff0 Preserves quiz frontmatter, removes quiz content
Updates the quiz cleaning process to retain the 'quiz'
key in the frontmatter, but removes associated content
from the body of the document. This ensures the Lua
filter continues to function while preventing the
insertion of quiz content.
2025-06-30 12:24:40 -04:00
Vijay Janapa Reddi
2a6d83107b Replaces sed with python script for blank line collapsing
Refactors the blank line collapsing logic from a bash command to a dedicated python script.

This change improves cross-platform compatibility, particularly addressing issues with sed implementations on different operating systems. It also enhances code readability and maintainability by using a python script.
2025-06-30 11:08:25 -04:00
Vijay Janapa Reddi
fa86068984 Adds project dependencies and setup guide
Adds a comprehensive requirements file and a scripts README
documenting dependencies, pre-commit setup, and project structure.

This enhancement streamlines project setup and ensures consistent
dependency management, improving maintainability and collaboration.
2025-06-30 10:22:13 -04:00
Vijay Janapa Reddi
9340ca3b06 Removes Section label type from unreferenced labels
The section label type is removed from the list of label types to be checked for unreferenced labels.
This is likely due to a change in how section labels are handled or a decision to exclude them from this particular check.
2025-06-30 10:21:47 -04:00
Vijay Janapa Reddi
cf2f953d1a Improves quiz insertion logic and answer extraction
Skips 'Self-Check Answers' sections when extracting sections.

Implements a more robust insertion strategy for quizzes. It now collects all insertion points, sorts them in reverse order, and then performs the insertions. This prevents line number shifts from affecting subsequent insertions, ensuring quizzes are inserted at the correct locations.

Ensures that only non-empty answer blocks are added to the final output.
2025-06-28 12:59:06 -04:00
Vijay Janapa Reddi
db21f9a2ff Generated quizzes in parallel 2025-06-28 12:29:21 -04:00
Vijay Janapa Reddi
27311d89b5 Cleaning up 2025-06-28 11:27:19 -04:00
Vijay Janapa Reddi
9ccde27fa6 Fixes header parsing logic
Corrects an issue in `find_safe_insertion_points` where header parsing
could be bypassed within code or div blocks, leading to incorrect
insertion points. This change ensures that header parsing only occurs
outside of code and div blocks, preventing premature breaking of the
insertion point search.
2025-06-28 11:11:56 -04:00
Vijay Janapa Reddi
05c4699b96 Removes cached quizzes file.
Deletes the compiled Python cache file for the quizzes module.
This ensures that the latest version of the code is always used,
preventing potential issues related to outdated bytecode.
2025-06-28 11:11:25 -04:00
Vijay Janapa Reddi
f107461fb7 Cleaning up code (likely bug in script) 2025-06-28 11:08:27 -04:00
Vijay Janapa Reddi
b867178800 Renames "Quiz Answers" to "Self-Check Answers"
Updates the section header for quiz answers to "Self-Check Answers" across multiple core content files.

This change aims to better reflect the intended purpose of these sections as self-assessment tools for learners.
2025-06-28 10:16:09 -04:00
Vijay Janapa Reddi
4d84f9ab1e Disables book chapters and renames quiz section
Disables most of the book's chapter entries in `_quarto.yml`.

Renames "Quiz Answers" section to "Self-Check Answers" in the quiz generation script.
This change improves code readability and maintainability by using a consistent naming convention.

WIP on 874-part-title
2025-06-28 10:06:08 -04:00
Vijay Janapa Reddi
e89795cea3 Update the formatting for quiz answers 2025-06-28 09:58:01 -04:00
Vijay Janapa Reddi
36b4511a1e Formats answers with consistent "Answer" prefix.
Ensures all answer types are formatted with a consistent
"*Answer*: " prefix for clarity and uniformity.
2025-06-28 09:49:14 -04:00
Vijay Janapa Reddi
5e47555263 Merge branch 'dev' into 874-part-title 2025-06-28 09:29:43 -04:00
Vijay Janapa Reddi
bae55f7ab8 First major draft of all quizzes generated and integrated and scripts work 2025-06-28 09:27:04 -04:00
Vijay Janapa Reddi
17bf9a5ed7 Adds keyboard shortcuts to the quiz editor
Improves user experience by adding keyboard shortcuts for common actions within the quiz editor interface.

The shortcuts include navigation (previous/next), saving, regenerating, and toggling the first five checkboxes. A markdown element was added to inform the user of the available shortcuts.
2025-06-28 08:08:30 -04:00
Zeljko Hrcek
e67b575290 Customize TOC part formatting, callout block colors and font size
Added "Part" label before part number in TOC with custom spacing and color.
Also updated styles of custom callout blocks to visually distinguish them from Quarto defaults.
2025-06-28 13:25:00 +02:00
Vijay Janapa Reddi
147a5a0fba Cleaning up quizzes, doing another iteration 2025-06-28 00:39:58 -04:00
Vijay Janapa Reddi
e8592fb6c7 Improves section ID management with content hashing
Enhances section ID generation by incorporating content hashing for improved stability and accuracy.

This change ensures that IDs are content-aware, preventing unnecessary ID changes across multiple repair runs if the actual content remains the same.

Additionally, it introduces smart block detection to automatically ignore headers inside code blocks, divs, and callouts, preventing incorrect processing of documentation examples and code comments.
2025-06-27 23:07:57 -04:00
Vijay Janapa Reddi
ec49497d62 Improves header processing accuracy
Refactors header processing logic to correctly identify headers by introducing block tracking.

This change fixes an issue where headers within code blocks or div blocks were being incorrectly processed, leading to inaccurate section ID management.

The solution involves introducing functions to track the state of 'inside_skip_div' and 'inside_code_block' to prevent header processing within these blocks, ensuring that only valid headers are processed.
2025-06-27 23:06:57 -04:00
Vijay Janapa Reddi
e64e5e095c Fixed a bug in -repair followed by repair 2025-06-27 23:02:13 -04:00
Vijay Janapa Reddi
664f1fcc66 cleaning owrks 2025-06-27 22:23:43 -04:00
Vijay Janapa Reddi
9475f1d3d6 Updated the script for section generation 2025-06-27 22:09:43 -04:00
Vijay Janapa Reddi
c5d1130593 Skips code blocks when extracting headers
Ensures that section headers are not extracted from code blocks within documents, preventing incorrect header identification.
2025-06-27 21:30:01 -04:00
Vijay Janapa Reddi
115bd9d6fc Enables insert mode for directories
Allows the 'insert' mode to process all quiz JSON files within a specified directory, streamlining the quiz insertion process.

Ensures proper formatting of the "Quiz Answers" section by stripping trailing whitespace and adding a consistent number of newlines.
2025-06-27 18:31:34 -04:00
Vijay Janapa Reddi
a95f3eee9e Improves FILL-type question formatting
Enhances the formatting of FILL-type question answers by extracting the key word before the first period and displaying it prominently.
Adds logic to handle cases where no period exists.
2025-06-27 18:05:44 -04:00
Vijay Janapa Reddi
f3c05927d5 Orders QMD files using _quarto.yml for quizzes
Prioritizes .qmd file order in quiz generation based on the
`_quarto.yml` file's chapters section, if present. This ensures
quizzes are generated in the intended order, enhancing content
consistency.  Falls back to default file order when `_quarto.yml`
is absent.  Includes improvements to MCQ formatting and learning objective output.
2025-06-27 17:03:08 -04:00
Vijay Janapa Reddi
bd54a6a8f4 Improves handling of QMD file quiz references
Refactors the handling of quiz file references in QMD/MD files. Instead of relying on a dedicated function to find the quiz file, it now directly extracts the quiz file name from the 'quiz:' variable in the YAML frontmatter.

This change also adds more robust error handling, including checks for:
- The existence of the 'quiz:' variable in the frontmatter.
- The existence of the specified quiz file.
- General file reading errors.

These improvements provide clearer error messages to the user in case of misconfiguration.
2025-06-27 09:27:49 -04:00
Vijay Janapa Reddi
106ca25de4 Improves quiz and answer formatting
Updates the quiz and answer formatting to improve
readability and consistency by adding/removing blank lines
around callout blocks.

Also, concatenates answer blocks with single newlines instead of
double newlines to prevent extra spacing.
2025-06-26 18:34:21 -04:00
Vijay Janapa Reddi
c72d2059b2 Adds dependencies for genai scripts
Adds required packages for generative AI scripts,
including OpenAI, Gradio, jsonschema, PyYAML, and pypandoc,
to enable necessary functionalities.
2025-06-26 13:24:23 -04:00
Vijay Janapa Reddi
5a2173763e Added insertion support (back) 2025-06-26 12:33:51 -04:00
Vijay Janapa Reddi
5f978c3182 Updated to use Pandoc AST for section processing 2025-06-24 00:53:45 -04:00
Vijay Janapa Reddi
109490ca40 Filters headers inside Quarto blocks
Updates the section extraction logic to ignore level 2 headers (##) that appear within Quarto blocks.

The prior regex-based approach was unable to reliably determine section boundaries in the presence of Quarto syntax.

This change iterates through lines and keeps track of whether the current line resides inside any of the Quarto blocks (":::", "::::", "```", "---").
Only when outside these blocks does it process a "##" line as a potential header.
2025-06-24 00:17:39 -04:00
Vijay Janapa Reddi
8536548f6e Enhances quiz generation and processing logic.
Refines the quiz generation process with improved instructions and clearer guidelines for the AI model to create more effective and relevant quiz questions.

Improves YAML parsing for quiz metadata extraction to provide more robustness.

Enhances output file naming and path management to streamline quiz generation workflow.

Also ensures a line break after frontmatter to resolve formatting issues in QMD files.
2025-06-23 23:37:33 -04:00
Vijay Janapa Reddi
54f9524b4c Enhances quiz generation and editing workflow
Improves the quiz generation script with enhanced question quality guidelines, chapter-level coherence checks, and GUI enhancements.
These updates ensure better quiz question variety and alignment with chapter content, reduces question redundancy, and improves the overall user experience during review and editing, by adding functionality to pass previous quiz data to the generation process to avoid redundancy.
2025-06-23 19:30:07 -04:00
Vijay Janapa Reddi
50215b9513 Adds quiz generation and management tool
Implements a comprehensive tool for generating, managing, and
maintaining quiz questions for a machine learning systems textbook.

This includes functionality for AI-powered quiz generation, a GUI for
reviewing/editing, quiz insertion/removal, and file verification.
2025-06-23 15:31:15 -04:00
Vijay Janapa Reddi
f19db4cc83 Enhances quiz generation and cleaning scripts
Improves quiz generation by adding chapter context and difficulty progression, and by providing clearer guidance and anti-patterns to avoid.
Refactors quiz cleaning to correctly remove quiz-related content and metadata.
Adds utility functions to find corresponding quiz/qmd files, and extract chapter info.
2025-06-23 15:27:18 -04:00
Vijay Janapa Reddi
0d6a10b18b Excludes unnumbered headers from ID verification
Ensures that headers with the class {.unnumbered} are skipped during section ID verification, aligning with the script's intended behavior.
This prevents false positives and improves the accuracy of the verification process.
2025-06-23 12:58:42 -04:00
Vijay Janapa Reddi
35bd5461bc Updates section IDs for consistent linking
Updates section IDs in qmd files to ensure consistent internal linking and navigation across the document.

Removes IDs from unnumbered headers to prevent conflicts and improve document structure.
2025-06-23 12:54:57 -04:00
Vijay Janapa Reddi
172eebbcad Updated with new has that considers section content 2025-06-23 12:35:02 -04:00