How the Quiz Data JSON Structure Is Organized in ML-For-Beginners

The ML-For-Beginners repository stores quiz data in a standardized JSON format where each file contains a module title and an array of question objects with fields for options, correct answer indices, and explanations.

The microsoft/ML-For-Beginners curriculum uses a consistent quiz data JSON structure to deliver interactive assessments across all learning modules. This standardized schema enables both the frontend JavaScript renderer and Python-based notebooks to load questions dynamically without requiring custom parsers for each lesson.

Top-Level JSON Schema

The quiz files follow a flat, predictable hierarchy defined at the repository level. Each JSON document contains two primary keys: module and quiz.

The module field stores a human-readable string identifying the lesson context, while the quiz field contains an ordered array of question objects. This structure appears consistently across all quiz files, from introductory machine learning concepts to advanced model training modules.

{
  "module": "Module X – <Module Title>",
  "quiz": [
    {
      "id": 1,
      "question": "What does … ?",
      "options": [
        "Choice A",
        "Choice B",
        "Choice C",
        "Choice D"
      ],
      "answerIndex": 2,
      "explanation": "A short explanation of why the selected answer is correct."
    }
  ]
}

Field Definitions and Data Types

Understanding the quiz data JSON structure requires familiarity with six core properties that define each question object.

id A numeric identifier unique within the specific quiz file. This integer facilitates answer key mapping and progress tracking across sessions.

question The prompt text presented to learners. This field supports plain text or markdown formatting for inline code, mathematical notation, or emphasis.

options An ordered array of strings representing the possible answer choices. The sequence matters because the answerIndex field references positions within this array using zero-based indexing.

answerIndex An integer specifying the zero-based position of the correct answer within the options array. For example, an answerIndex of 2 indicates the third option is correct.

explanation (optional) A string containing pedagogical feedback displayed after answer submission. This field clarifies misconceptions and reinforces learning objectives, though its presence is not mandatory for quiz functionality.

Consuming the JSON Structure

The ML-For-Beginners repository implements generic loaders that parse the quiz data JSON structure without hardcoding module-specific logic.

JavaScript Frontend Implementation The frontend/src/quizRenderer.js component fetches quiz files via standard HTTP requests and binds the JSON properties to DOM elements. The renderer accesses data.module for the header title, iterates over data.quiz to generate question cards, and validates user selections against answerIndex.

async function loadQuiz(url) {
  const response = await fetch(url);
  const data = await response.json();

  document.querySelector('#module-title').textContent = data.module;

  data.quiz.forEach(renderQuestion);
}

Python Notebook Integration Jupyter notebooks within the curriculum use the standard json library to load quizzes for inline assessment. This approach enables instructors to embed interactive checks directly within lesson notebooks.

import json, pathlib

def load_quiz(file_path: pathlib.Path):
    with file_path.open('r', encoding='utf-8') as f:
        quiz_data = json.load(f)

    print(f"Module: {quiz_data['module']}")
    for q in quiz_data['quiz']:
        print(f"\nQ{q['id']}: {q['question']}")
        for i, opt in enumerate(q['options']):
            print(f"  {i+1}. {opt}")

Key Source Files

The quiz data JSON structure is defined and consumed across several critical paths in the repository.

  • quiz/intro_to_ml_quiz.json – Contains assessment questions for the Introduction to Machine Learning module, demonstrating the base schema with basic ML terminology questions.

  • quiz/data_preprocessing_quiz.json – Implements the JSON structure for data cleaning and preparation concepts, featuring questions with code snippets in the question fields.

  • quiz/model_training_quiz.json – Stores advanced assessment data covering supervised learning algorithms, utilizing the explanation field extensively to clarify algorithm selection criteria.

  • frontend/src/quizRenderer.js – The generic rendering engine that parses the standardized JSON structure and manages user interaction logic, answer validation, and progress tracking.

Summary

  • The ML-For-Beginners repository uses a standardized quiz data JSON structure that enables consistent assessment delivery across all learning modules.
  • Each quiz file contains a module string and a quiz array of question objects with fields for id, question, options, answerIndex, and optional explanation.
  • The zero-based answerIndex property determines correct answers by referencing positions within the ordered options array.
  • Both JavaScript frontend components and Python notebooks consume this JSON structure using generic loaders that require no module-specific customization.
  • Quiz files reside in the quiz/ directory, with the generic renderer implemented in frontend/src/quizRenderer.js.

Frequently Asked Questions

What is the quiz data JSON structure in ML-For-Beginners?

The quiz data JSON structure is a standardized schema used throughout the microsoft/ML-For-Beginners repository to store assessment questions. It consists of a top-level object containing a module title string and a quiz array, where each element represents a question with properties for the prompt, answer options, correct answer index, and optional explanation.

How is the correct answer stored in the JSON?

Correct answers are stored using the answerIndex field, which contains a zero-based integer referencing the position of the correct choice within the options array. For example, if the second option in the list is correct, the answerIndex value will be 1. This design allows the frontend renderer to validate user selections by simple index comparison without storing duplicate answer strings.

Can I load the quiz data using Python?

Yes, the JSON structure is language-agnostic and can be loaded using Python’s built-in json module or libraries like pathlib for file handling. Since the schema uses standard JSON types—strings, integers, and arrays—no custom parsers are required. You can open the quiz files located in the quiz/ directory and access the module and quiz keys directly to iterate through questions and options.

Where are the quiz files located in the repository?

Quiz files are stored in the quiz/ directory at the repository root. Specific examples include quiz/intro_to_ml_quiz.json for the introductory module, quiz/data_preprocessing_quiz.json for data cleaning concepts, and quiz/model_training_quiz.json for advanced algorithms. The generic quiz renderer that consumes these files is implemented in frontend/src/quizRenderer.js.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →