v0.4.0¶
Release Date: March 15, 2026
Highlights¶
- Extensions support for vendor-specific question metadata with
h5pGonamespace
Added¶
ExtensionsandH5PGoExtensiontypes for question metadata (94ece1e)- Builder pattern methods:
WithTopic(),WithTags(),WithDifficulty(),WithLearningObjective(),WithSource()(94ece1e) Extensionsfield onQuestionandMultiChoiceQuestionstructs (94ece1e)NewMultiChoiceQuestionWithExtensions()andWithExtensions()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¶
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: