-
Notifications
You must be signed in to change notification settings - Fork 7
"Fill in the blank" question type #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ewels
wants to merge
12
commits into
main
Choose a base branch
from
claude/mkdocs-quiz-issue-9-01R2CRD6PBvhfKE7nYkbbV8Y
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implements a new fill-in-the-blank question type using [[answer]] syntax, as requested in issue #9. This allows quiz authors to create questions where users type in answers rather than selecting from multiple choices. Key features: - Double square bracket syntax [[answer]] marks blanks in questions - Supports single or multiple blanks per question - Case-insensitive answer validation (trimmed and lowercased) - Markdown formatting works around blanks - HTML-escaped answers in data attributes for security - Full integration with existing quiz features (content sections, progress tracking, localStorage) - CSS styling for inline text inputs with visual feedback - Shows correct answers as placeholders when show_correct is enabled Implementation details: - Plugin automatically detects quiz type based on content ([[...]] patterns) - Python: New _process_fill_in_blank_quiz() method handles parsing and HTML generation - JavaScript: Extended validation logic to compare input values with data-answer attributes - CSS: New .quiz-blank-input styles for inline text fields - Tests: 11 comprehensive tests covering various scenarios All 57 tests passing.
Update fill-in-the-blank quiz processing to use horizontal rule (---) as separator between question and optional content section. This allows arbitrary markdown in the question area while maintaining clear separation of the after-answer content. Changes: - Modified _process_fill_in_blank_quiz() to look for '---' separator - Updated inline documentation and examples - Added test for fill-in-blank with horizontal rule separator - All 58 tests pass Example: <quiz> The answer is [[foo]]. --- This content is only shown after answering. </quiz> Fixes #9
Add comprehensive documentation for fill-in-the-blank quiz type with horizontal rule separator for optional content sections. Changes: - Added fill-in-the-blank section to examples.md with: - Single blank example - Multiple blanks example - Fill-in-blank with content using horizontal rule (---) - Complex example with markdown formatting - Updated features list in README.md and index.md to mention fill-in-the-blank - Updated CLAUDE.md to reflect horizontal rule separator The horizontal rule (---) provides clear separation between question and after-answer content, allowing arbitrary markdown in the question area.
Fix two issues with fill-in-the-blank quizzes: 1. Form interactivity bug: After incorrect submission, submit button is now kept visible (when disable_after_submit is false) so users can edit their answers and resubmit without clicking "Try Again" first. 2. Enhanced feedback: When show_correct is enabled, incorrect answers now show a bullet-pointed list with: - Each incorrect answer displayed with strikethrough - An arrow (→) pointing to the correct answer - Format: ~~wrong answer~~ → correct answer Changes: - quiz.js lines 857-898: Updated submit handler feedback - quiz.js lines 619-672: Updated localStorage restoration feedback - quiz.js lines 810-813: Clear innerHTML on reset - quiz.js lines 157-161: Clear innerHTML on resetAll All 58 tests pass including 12 fill-in-blank tests.
When localStorage restores an incorrect answer state on page load for quizzes without content sections, the code threw "Cannot read property 'classList' of null" error, breaking ALL quiz functionality on the page. The bug occurred because the code tried to access section.classList without checking if the section element exists. Quizzes without content sections (no <section> tag) have section === null. Fixed by adding null checks before all section.classList operations: - Line 595, 622, 696, 735: Restore state from localStorage - Line 817: Reset handler - Line 859, 923: Submit handler This fixes the critical bug where entering a wrong answer on first page load would break all quiz interactivity for every quiz on the page. All 58 tests pass.
Resolved conflicts in mkdocs_quiz/js/quiz.js by: - Keeping fill-in-blank implementation with detailed bullet-list feedback - Adding translation support using t() function for all user-facing strings - Maintaining null checks for section element to prevent JS errors Changes: - Wrapped "Correct answer!" with t() at lines 621, 896, 968 - Wrapped "Incorrect answer" messages with t() at lines 665, 904, 990 - Preserved fill-in-blank detailed feedback with strikethrough formatting Merged changes include: - Translation support (pt_BR, fr_FR) and TranslationManager - CLI improvements for translation management - Additional documentation for translations All 58 tests pass including 12 fill-in-blank tests.
…cts) Resolved merge conflicts and incorporated upstream improvements: Conflicts resolved: - CLAUDE.md: Merged fill-in-blank docs with markdown_extensions info - mkdocs_quiz/plugin.py: Kept both fill-in-blank format and asterisk bullets note - mkdocs_quiz/js/quiz.js: Kept fill-in-blank implementation, added bug fixes - tests/test_plugin.py: Kept both fill-in-blank tests and new markdown_extensions tests Bug fixes from upstream applied to quiz.js: - Fix duplicate event handlers on Material instant navigation (f6271ca) - Prevent page scroll to top when answering quizzes (03b2eac) - Added stopPropagation() to submit handler - Added preventDefault() to auto-submit change handler - Made submit events properly bubbleable and cancelable Upstream changes merged: - Translation system improvements (multiple new languages) - Markdown extensions support in quiz content - Asterisk bullet support (* [x] and * [ ]) - Various bug fixes and improvements All 85 tests pass (1 skipped).
…ttp://127.0.0.1:29351/git/ewels/mkdocs-quiz into claude/mkdocs-quiz-issue-9-01R2CRD6PBvhfKE7nYkbbV8Y
Fill-in-blank quizzes now properly use:
- Configured markdown extensions from mkdocs.yml for both question text
and content sections (previously used default extensions only)
- Translation system for "Submit" button and "Question {n}" text
(previously hardcoded in English)
Changes:
- Updated _process_fill_in_blank_quiz() signature to accept
TranslationManager and MkDocsConfig parameters
- Pass config to convert_inline_markdown() and get_markdown_converter()
for proper markdown extension support
- Use t.get() for translatable strings (Submit, Question {n})
- Added form attributes (action, onsubmit) for consistency with
multiple-choice quizzes
- Added test_fill_in_blank_markdown_extensions() to verify markdown
extension support
This ensures fill-in-blank quizzes have feature parity with
multiple-choice quizzes introduced in recent PRs.
All 86 tests pass (1 skipped).
- Add explicit type annotation for blank_match to resolve Optional[Match] error - Rename variable from 'match' to 'blank_match' to avoid variable redefinition - Apply prettier formatting to CLAUDE.md (add blank line for readability) - All pre-commit checks now pass: ruff, prettier, mypy, translation checks - All 86 tests pass
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9