Skip to content

H5P Go SDK

Build Status Lint Status Go Report Card Docs License

A Go library for creating, manipulating, and validating H5P (HTML5 Package) content, with support for the official H5P file format and schemas.

✨ Features

  • 📦 Full H5P Package Support: Create and extract .h5p ZIP files with proper structure
  • 🔒 Type-Safe Schema Implementation: Official H5P MultiChoice schema with Go structs
  • 🏗️ Question Set Builder: Fluent API for building interactive question sets
  • Validation: Built-in validation for H5P compliance
  • 🎯 Multiple Question Types: Support for single-answer and multi-answer questions
  • 📋 Official Schema Compliance: Uses actual H5P semantics definitions
  • 🔄 JSON Serialization: Full marshaling/unmarshaling support

🚀 Quick Start

go get github.com/grokify/h5p-go
package main

import (
    "fmt"
    "log"

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

func main() {
    // Create a question set using the builder pattern
    builder := h5p.NewQuestionSetBuilder()

    answers := []h5p.Answer{
        h5p.CreateAnswer("Paris", true),
        h5p.CreateAnswer("London", false),
        h5p.CreateAnswer("Berlin", false),
        h5p.CreateAnswer("Madrid", false),
    }

    questionSet, err := builder.
        SetTitle("Geography Quiz").
        SetProgressType("textual").
        SetPassPercentage(60).
        SetIntroduction("Welcome to our geography quiz!").
        AddMultipleChoiceQuestion("What is the capital of France?", answers).
        Build()

    if err != nil {
        log.Fatal(err)
    }

    // Export to JSON
    jsonData, _ := questionSet.ToJSON()
    fmt.Printf("Generated H5P Question Set:\n%s\n", string(jsonData))
}

📚 What's Next?

🏛️ Architecture

The H5P Go SDK is organized into several key components:

  • Core Types (questionset.go, h5p_package.go) - Fundamental data structures
  • Builder Pattern (builder.go) - Fluent API for creating content
  • Official Schemas (schemas/) - Type-safe H5P content type definitions
  • Semantics Engine (semantics/) - Universal H5P semantics format support
  • Package Management - Full .h5p file creation and extraction

🔧 Key Capabilities

Question Sets

Build interactive question sets with multiple question types, scoring, and rich feedback systems.

Type-Safe Schemas

Work with official H5P content type schemas using strongly-typed Go structs.

H5P Package Management

Create, modify, and validate complete H5P packages ready for deployment.

Standards Compliance

Full compliance with official H5P specifications and content type definitions.

🤝 Contributing

We welcome contributions! See our Contributing Guide for details.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.