Quiz generator

From NaveedTechLab/skills-library · View interactive version

Quiz generator is an AI agent skill from the GitHub repository NaveedTechLab/skills-library. ALWAYS generate interactive quizzes using the Quiz component (50 comprehensive questions total). Generates 50 college-level conceptual questions with immediate feedback per question. Quiz component automatically displays 15-20 questions per batch, randomized each retake. Features: immediate feedback

How to use this skill

Skill file

Quiz Generator: College-Level Interactive Chapter Assessments

Version: 5.0.0 | Consolidates: quiz-answer-redistributor v3.0.0 | Alignment: Constitution v3.1.2, Co-Learning Partnership, "Specs Are the New Syntax" | KEY FEATURES: 50 total questions, automated answer redistribution with intelligent explanation regeneration, 15-20 displayed per batch, immediate feedback per question, randomized batching on retake, no pass/fail threshold, evals-aligned questions

Quiz Component Location: book-source/src/components/Quiz.tsx (globally registered—no imports needed)

Usage Reference: book-source/src/components/QUIZ_USAGE.md (example structure + best practices)

Example Quiz: book-source/src/components/references/example-quiz.md (full working example with all patterns)


Purpose

Generate high-quality, college-level MCQ quizzes (50 comprehensive questions total) using the globally-registered Quiz component (<Quiz />). The component automatically:

Output is ALWAYS a Quiz component with 50 questions, NEVER static markdown quizzes.

Core Principles:


When to Activate

This skill should be used when creating end-of-chapter assessments. CRITICAL: This skill ALWAYS generates interactive quizzes using the Quiz component—NEVER static markdown quizzes. ALWAYS 50 QUESTIONS TOTAL.

Activate this skill when:

Trigger phrases:

MANDATORY REQUIREMENTS:

  1. Use Quiz component (NEVER static markdown)
  2. Generate 50 total questions (comprehensive chapter coverage)
  3. Component displays 15-20 per batch (randomized each retake)
  4. Randomize correctOption indices evenly across 0-3
  5. Explanations MUST address why wrong answers are incorrect
  6. NO passing score threshold—just score tracking
  7. Immediate feedback shown after each answer
  8. 🚨 CRITICAL: ALL options within ±3 words of each other per question (prevents test-takers from guessing by selecting longest/shortest option)
  9. 🚨 MANDATORY VALIDATION: Manually count words for EVERY option in EVERY question (all 50 questions) before submitting quiz
  10. 🚨 CRITICAL: Verify correct answer is NOT correlated with option length (longest option must NOT be more frequently correct)

Key Concepts

College-Level Conceptual Questions

Shift from Recall to Understanding:

❌ Recall (Avoid):

"What is a Python list?" → Tests memorization

✅ Conceptual (Target):

"Given this code with list operations, what misconception does this error reveal?" → Tests understanding

Why College-Level?

  1. Job readiness: Professional developers need to understand WHY, not just WHAT
  2. AI-era skills: With AI generating code, understanding concepts matters more than syntax recall
  3. Transfer learning: Conceptual knowledge transfers; memorized facts don't
  4. Better assessment: Conceptual questions predict programming competence

Cognitive Level Target:


Immediate Feedback Learning Model

Quiz component shows feedback IMMEDIATELY after each answer (not delayed until results page). This enables:

  1. Real-time learning: Students learn from mistakes instantly, not after quiz completion
  2. Deeper engagement: Immediate reinforcement = higher retention
  3. Misconception correction: Explain WHY their wrong answer was incorrect right away
  4. Better explanations: Space for 100-200 word explanations per question (comprehensive, not rushed)

Feedback shows:

Example feedback structure:

✓ CORRECT!
[Explanation of why this is right...]

vs.

✗ INCORRECT
Why your answer was wrong:
You selected: "append() is immutable"
This is incorrect. The correct answer is: "append() modifies the list in place"

Explanation:
Lists are mutable (changeable) in Python. The append() method modifies the original list
in place and returns None (doesn't return a new list). This is different from strings,
which are immutable. Understanding mutability is crucial for debugging...

50-Question Bank with Randomized Batching

Why 50 questions?

How batching works:

  1. You provide all 50 questions to the Quiz component
  2. Component shuffles all 50 on mount
  3. Component displays questions 1-15 (or 1-20) for user to answer
  4. User completes batch, sees results page
  5. User clicks "Try Another Batch" → Component reshuffles all 50
  6. Component displays a NEW random batch of 15-20 (completely different questions)

Example flow:

Session 1: User sees questions [3, 47, 12, 28, 5, 11, ...] (15-20 questions)
Completes, sees results: 14/18 correct

User clicks "Try Another Batch" →

Session 2: User sees questions [42, 8, 31, 1, 19, 35, ...] (15-20 DIFFERENT questions)
Takes quiz again: 16/19 correct

Session 3: User clicks "Try Another Batch" →

Component shows completely DIFFERENT shuffle: [25, 9, 48, 2, 18, ...]

Option Length Validation (CRITICAL - Test Validity)

THE PROBLEM: Options of unequal length allow test-takers to guess correctly without reading questions. Example:

THE SOLUTION: ALL options within ±3 words of each other across all 50 questions.

Validation Procedure (MANDATORY):

  1. Count words for EVERY option in EVERY question (all 50 questions):

```

Question: "Why is X important?"

A: "It improves performance quickly" (4 words)

B: "It simplifies code structure" (4 words)

C: "It prevents common bugs" (4 words)

D: "It helps developers work together" (5 words) ✓ All within ±3 range (4-5 is acceptable)

```

  1. Flag any question failing the ±3 word rule:

```

❌ FAIL:

A: "Yes" (2 words)

B: "The framework processes requests asynchronously in a single event loop without blocking" (12 words)

→ Difference: 10 words → FAIL (>3 word difference)

✅ PASS:

A: "AI amplifies existing practices" (4 words)

B: "AI fixes all problems" (4 words)

C: "AI changes developer roles" (4 words)

D: "AI prevents errors completely" (4 words)

→ All within 4-4 range → PASS

```

  1. Verify length distribution (no correlation with correctness):
  1. Document validation in handoff:

```

Option Length Validation Complete:

✓ All 50 questions checked

✓ All options within ±3 word range

✓ No length-correctness correlation

✓ Longest option correct in 6 questions

✓ Shortest option correct in 7 questions

✓ Middle-length correct in 12 questions

```

Why ±3 words matters:

📖 Reference: option-length-validation.md for detailed examples and verification scripts


Answer Randomization with Quiz Component

Requirements:

Quiz Component Format:

{
  question: "Your question?",
  options: ["Option A", "Option B", "Option C", "Option D"],
  correctOption: 2,  // Index 0-3, NOT 1-4!
  explanation: "Why this is correct AND why other options are wrong..."
}

Workflow: Generate → Redistribute → Validate

LLMs are excellent at content creation but struggle with strict procedural constraints like answer distribution. Therefore, this skill uses a two-step process:

Step 1: Generate Quiz (Content Creation)

  1. Write all 50 questions first (focus on quality, don't worry about correctOption distribution)
  2. Use natural answer placement (what makes pedagogical sense)

Step 2: Automated Redistribution (Procedural Validation)

After quiz generation, automatically fix answer distribution bias using the bundled Python script:

python .claude/skills/quiz-generator/scripts/redistribute_answers_v2.py <quiz_file_path> <sequence_letter>

Example:

python .claude/skills/quiz-generator/scripts/redistribute_answers_v2.py \
  book-source/docs/04-Python-Fundamentals/14-data-types/quiz.md A

Available Sequences (A-H):

What the Redistributor Does:

  1. Parses quiz questions from MDX
  2. Swaps option positions to match the chosen sequence
  3. Intelligently regenerates explanations to reference new answer positions
  4. Validates ALL explanations ensure correctOption and explanation match
  5. Reports comprehensive statistics

Critical Features:

Output Report Example:

Successfully re-distributed quiz using Sequence C

Execution Summary:
* Questions Processed: 50
* Options Swapped: 18
* Explanations Updated: 18
* Validation: ALL CHECKS PASSED

Final Distribution:
* Index 0: 12
* Index 1: 12
* Index 2: 13
* Index 3: 13

All 50 explanations verified. Each explanation correctly references the corresponding correct answer option.

📖 Reference: answer-distribution.md for verification methods


Explanation Quality (Critical for Immediate Feedback)

Quiz component shows explanations immediately after each answer. Comprehensive explanations enable deeper learning:

Good Explanations (100-150 words):

  1. Explain WHY correct (2-3 sentences)
  2. Address why EACH distractor is wrong (1-2 sentences each × 3 distractors = 6-8 sentences)
  3. Add context/examples (real-world connection, misconception clarification)

Example:

explanation: "Lists are mutable (changeable) in Python, so append() modifies the original
list in place. This is different from strings, which are immutable—you can't change them
after creation. The extend() method adds multiple items (like appending a list), but
append() adds a single item. Insert() requires both value and position. Understanding
mutability is crucial for debugging variable scope issues and understanding function
side effects. When a function calls append() on a list parameter, it modifies the
original list outside the function—a common source of bugs."

Source Field (Lesson Attribution)

The source field links each question to the specific lesson it addresses. This helps students know which lesson material to review.

Format: "Lesson N: [Lesson Title]"

Source Extraction:

Examples:

source: "Lesson 1: Understanding Mutability"
source: "Lesson 3: Scope and Closures"
source: "Lesson 2: Unit Test Design"

Display in Feedback:


Quiz Architecture

Fixed Constraints (Non-Negotiable)

question_count: 50  # Comprehensive bank (50 total questions)
questions_per_batch: 15-20  # Questions displayed per session (component shuffles)
options_per_question: 4  # Always exactly 4 options
question_format: multiple_choice  # Only MCQ
correct_answer_distribution: random_equal  # indices 0-3 equally distributed (~12-13 per index)
feedback_timing: immediate  # Shown after each answer (not delayed)
passing_score: NONE  # No pass/fail threshold—just score tracking
file_naming: ##_chapter_##_quiz.md  # e.g., 05_chapter_02_quiz.md
output_format: Markdown with Quiz component  # <Quiz {...} questions={[...50 questions...]} />
component_globally_registered: true  # No imports needed

CRITICAL ANTI-PATTERNS:


File Structure (Quiz Component Format)

---
sidebar_position: X  # e.g., 05 (lesson count + 1)
title: "Chapter X: [Topic] Quiz"
---

# Chapter X: [Topic] Quiz

Brief introduction (1-2 sentences describing what students will assess).

<Quiz
  title="Chapter X: [Topic] Assessment"
  questions={[
    {
      question: "Question 1 text here? (Conceptual, not recall)",
      options: [
        "Option A (specific text for this concept)",
        "Option B (specific text for this concept)",
        "Option C (specific text for this concept) ← CORRECT",
        "Option D (specific text for this concept)"
      ],
      correctOption: 2,  // Index 0-3 (NOT 1-4!)
      explanation: "COMPREHENSIVE explanation (100-150 words): Explain why C is correct (2-3 sentences).
        Then address why each distractor is wrong: Why A is wrong (1-2 sentences). Why B is wrong (1-2 sentences).
        Why D is wrong (1-2 sentences). Real-world connection or misconception clarification (1-2 sentences).
        Total should be 100-150 words addressing all four options.",
      source: "Lesson 1: Understanding Mutability"
    },
    {
      question: "Question 2 text?",
      options: [
        "Option A (distinct alternative misconception)",
        "Option B (distinct alternative misconception)",
        "Option C (distinct alternative misconception)",
        "Option D (correct answer) ← CORRECT"
      ],
      correctOption: 3,
      explanation: "Full explanation addressing why D is correct and why A, B, C are incorrect...",
      source: "Lesson 2: Reference vs. Value"
    },
    // ... 48 more questions (total: 50 questions)
    // Quiz component will shuffle and display 15-20 per session
  ]}
  questionsPerBatch={18}  // Optional: customize questions per session (default: 15)
/>

Key Requirements (CRITICAL):

📖 Reference: file-naming.md for naming conventions | example-quiz.md for complete working example


The Generation Process (Overview)

Chapter Content → Analyze Concepts → Generate 50 Questions →
Design Distractors → Randomize Answers → Write Explanations →
Format Quiz Component → Validate → ##_chapter_##_quiz.md

7-Stage Process Summary

  1. Analyze Chapter Structure: Identify all core concepts and learning objectives (comprehensive, not highlights)
  2. Generate 50 Conceptual Questions: Write 50 understanding-focused questions covering all chapter material
  3. Design Meaningful Distractors: Create 3 distractors per question testing specific misconceptions
  4. Randomize Correct Answers: Shuffle correctOption indices (0-3) across all 50 questions; verify ~12-13 per index
  5. Write Comprehensive Explanations: 100-150 words per question explaining why correct AND why each distractor is wrong
  6. Format Quiz Component: Use <Quiz {...} questions={[...50 questions...]} /> with all 50 in questions array
  7. Validate Distribution: Verify 50 questions, equal-length explanation clarity, randomized correctOption spread

📖 Reference: generation-process.md for detailed stage-by-stage workflow


Quality Standards

Content Quality

Immediate Feedback Quality

Answer Randomization Quality (CRITICAL)

Explanation Quality

Option Length Quality (CRITICAL - Prevents Cheating)

Component Format Quality

📖 Reference: quality-checklist.md for complete validation criteria


Common Pitfalls (Top 7)

  1. Fewer than 50 Questions (CRITICAL): Only generating 15-20 questions
  1. Index Confusion (CRITICAL): Using correctOption: 1-4 instead of 0-3
  1. Missing Source Field (CRITICAL): Not including source field for questions
  1. Including Passing Score: Adding passingScore prop
  1. Testing Recall: "What is X?" questions → Memorization
  1. Weak Distractors or Incomplete Explanations: Not addressing why each option is right/wrong
  1. Answer Patterns: Obvious distribution patterns in correctOption across 50 questions
  1. Option Length Bias (🚨 CRITICAL - TEST VALIDITY THREAT): Options of unequal length allow test-takers to achieve 60-70%+ accuracy by selecting longest/shortest option WITHOUT reading questions

Impact: Unequal lengths undermine the entire quiz's validity. Student might appear to understand when they're just following a pattern.

Examples:

Fix (MANDATORY):

1. Count words for ALL 50 questions (not spot-check, all of them)

2. Enforce ±3 word limit strictly (4, 5, 6, 7 words = PASS; 3, 6, 9 = FAIL)

3. Verify no length-correctness correlation (correct answer sometimes longest, sometimes shortest, mostly middle)

4. Document validation results before handoff

Validation Checklist:

📖 Reference: pitfalls-and-solutions.md for all common mistakes


File Naming Convention

Pattern: `##_chapter_##_quiz.md`

Where:

Examples:

Why this naming:

📖 Reference: file-naming.md for complete guidance


Integration with Book Workflow

Related Skills


When NOT to Use This


Performance Tips


Real Production Example

Python Fundamentals Chapter 4 Quiz (AI-Native Textbook project, 200+ students):

Chapter: Data Types and Mutability (5 lessons)
Output: 05_chapter_04_quiz.md
Questions: 50 MCQ, 15-20 per session batch
Topics covered:
  - Lists vs tuples (mutability)         → 10 questions
  - Dictionaries (key rules, methods)    → 10 questions
  - Sets (uniqueness, operations)        → 8 questions
  - String methods and immutability      → 12 questions
  - Type conversion edge cases           → 10 questions

Result: Students averaged 3.2 retakes per chapter
        (vs 1.1 for static quizzes in old curriculum)
        — randomized batching drives re-engagement

Related Infrastructure


Handoff Criteria

The quiz is ready for human review when:

Content Complete:

Answer Randomization Verified:

Option Length Validation Verified (🚨 MANDATORY):

Explanation Quality Verified (CRITICAL for Immediate Feedback):

Quiz Component Format Valid:

Human Review Checklist:

📖 Reference: quality-checklist.md for complete validation


Bundled Resources

This skill includes detailed reference documentation:

Use Read tool to access references as needed during quiz generation.


**Quiz Generator v4.0.0 ALWAYS creates interactive assessments using the globally-registered Quiz component with 50 COMPREHENSIVE QUESTIONS. NEVER creates static markdown quizzes or fewer than 50 questions. Component automatically displays 15-20 random questions per batch, shuffled differently on each retake. Features immediate feedback per question (correct option + explanation + why wrong if incorrect), no passing/failing threshold (just score tracking), progress tracking, answer validation, color-coded feedback, retake button, and full theme support.

Every quiz MUST:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.