Skip to content

v0.4.0

Release Date: March 15, 2026

Highlights

  • Extensions support for vendor-specific question metadata with h5pGo namespace

Added

  • Extensions and H5PGoExtension types for question metadata (94ece1e)
  • Builder pattern methods: WithTopic(), WithTags(), WithDifficulty(), WithLearningObjective(), WithSource() (94ece1e)
  • Extensions field on Question and MultiChoiceQuestion structs (94ece1e)
  • NewMultiChoiceQuestionWithExtensions() and WithExtensions() helper methods (94ece1e)
  • Comprehensive tests for extensions JSON parsing and round-trip validation (94ece1e)

Dependencies

  • Bump actions/setup-go from 5 to 6 (f07e707)
  • Bump actions/checkout from 5 to 6 (623e37c)
  • Bump golangci/golangci-lint-action from 8 to 9 (e8f32f4)
  • Bump github/codeql-action from 3 to 4 (2435ff9)

Infrastructure

  • Update to shared CI workflows (f267f6b)
  • Rename workflow files for consistency (7be8b91)

Using Extensions

Extensions allow you to add vendor-specific metadata to questions while maintaining H5P compatibility. Standard H5P parsers will ignore unknown fields.

Basic Usage

import h5p "github.com/grokify/h5p-go"

// Create extension with builder pattern
ext := h5p.NewH5PGoExtension("1. Overview", 1).
    WithTopic("RAG Fundamentals").
    WithTags("rag", "retrieval").
    WithDifficulty("medium").
    WithLearningObjective("Understand RAG basics").
    WithSource("Chapter 1")

// Create question with extensions
question := h5p.NewMultiChoiceQuestionWithExtensions(
    "What is RAG?",
    []h5p.Answer{
        {Text: "Retrieval-Augmented Generation", Correct: true},
        {Text: "Random Answer Generator", Correct: false},
    },
    &h5p.Extensions{H5PGo: ext},
)

Extension Fields

Field Type Description
Section string Section/category the question belongs to
Topic string Specific topic within a section
Tags []string Flexible categorization labels
Difficulty string Difficulty level (easy/medium/hard)
QuestionNumber int Explicit ordering within a question set
LearningObjective string What the question tests
Source string Origin of the question content
Custom map[string]interface{} Arbitrary additional metadata

JSON Output

Extensions are serialized under the extensions field:

{
  "library": "H5P.MultiChoice",
  "params": { ... },
  "extensions": {
    "h5pGo": {
      "section": "1. Overview",
      "topic": "RAG Fundamentals",
      "tags": ["rag", "retrieval"],
      "difficulty": "medium",
      "questionNumber": 1,
      "learningObjective": "Understand RAG basics",
      "source": "Chapter 1"
    }
  }
}