Skip to content

grokify/h5p-go

Repository files navigation

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
  • 🔒 Type-Safe Schema Implementation - Official H5P content type schemas
  • 🏗️ Question Set Builder - Fluent API for building interactive content
  • Validation - Built-in H5P compliance validation
  • 🎯 Multiple Question Types - Support for various H5P content types
  • 🔄 JSON Serialization - Complete marshaling/unmarshaling support

🚀 Quick Start

Installation

go get github.com/grokify/h5p-go

Create Your First Quiz

package main

import (
    "fmt"
    "log"
    "github.com/grokify/h5p-go"
)

func main() {
    // Create answers
    answers := []h5p.Answer{
        h5p.CreateAnswer("Paris", true),
        h5p.CreateAnswer("London", false),
        h5p.CreateAnswer("Berlin", false),
    }
    
    // Build question set
    questionSet, err := h5p.NewQuestionSetBuilder().
        SetTitle("Geography Quiz").
        SetProgressType("textual").
        SetPassPercentage(60).
        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 content:\n%s\n", string(jsonData))
}

Using Type-Safe Schemas

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

// Create strongly-typed content
params := &schemas.MultiChoiceParams{
    Question: "What is 2 + 2?",
    Answers: []schemas.AnswerOption{
        {Text: "4", Correct: true},
        {Text: "5", Correct: false},
    },
    Behaviour: &schemas.Behaviour{
        Type: "single",
        EnableRetry: true,
    },
}

question := h5p.NewMultiChoiceQuestion(params)

📚 Documentation

Full Documentation →

Quick Links

Key Topics

🏗️ Architecture

h5p-go/
├── schemas/          # Official H5P content type schemas
├── semantics/        # Universal H5P semantics format  
├── builder.go        # Fluent API for content creation
├── questionset.go    # Core question set functionality
└── h5p_package.go    # Complete H5P package management

🧪 Testing

go test ./...

Run specific tests:

go test -v -run TestQuestionSet    # Question set tests
go test -v -run TestTyped          # Typed schema tests
go test -v -run TestH5PPackage     # Package management tests

📏 Standards Compliance

This library implements the official H5P specifications:

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

See our Contributing Guide for detailed information.

📜 License

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

🙏 Acknowledgments

  • H5P Group for the H5P framework and specifications
  • The Go community for excellent tooling and libraries

About

Go SDK for HTML 5 Package (H5P) - https://h5p.org/

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages