Documentation
¶
Index ¶
- type Answer
- type BackgroundImage
- type Content
- type Copyright
- type FeedbackRange
- type FileReference
- type H5PPackage
- type Library
- type LibraryDefinition
- type LibraryDependency
- type MultiChoiceQuestion
- type PackageDefinition
- type Question
- type QuestionSet
- type QuestionSetBuilder
- func (b *QuestionSetBuilder) AddMultipleChoiceQuestion(question string, answers []Answer) *QuestionSetBuilder
- func (b *QuestionSetBuilder) AddOverallFeedback(ranges []FeedbackRange) *QuestionSetBuilder
- func (b *QuestionSetBuilder) Build() (*QuestionSet, error)
- func (b *QuestionSetBuilder) SetBackgroundImage(path, mime string) *QuestionSetBuilder
- func (b *QuestionSetBuilder) SetIntroduction(introduction string) *QuestionSetBuilder
- func (b *QuestionSetBuilder) SetPassPercentage(percentage int) *QuestionSetBuilder
- func (b *QuestionSetBuilder) SetProgressType(progressType string) *QuestionSetBuilder
- func (b *QuestionSetBuilder) SetStartButtonText(text string) *QuestionSetBuilder
- func (b *QuestionSetBuilder) SetTitle(title string) *QuestionSetBuilder
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Answer ¶
type Answer struct { Text string `json:"text"` Correct bool `json:"correct"` Feedback string `json:"feedback,omitempty"` }
Legacy types - use schemas.MultiChoiceParams instead Kept for backward compatibility, will be deprecated
func CreateAnswer ¶
type BackgroundImage ¶
type Content ¶
type Content struct { QuestionSet *QuestionSet `json:"questionSet,omitempty"` Params interface{} `json:",omitempty"` }
type FeedbackRange ¶
func CreateFeedbackRange ¶
func CreateFeedbackRange(from, to int, text string) FeedbackRange
type FileReference ¶
type FileReference struct {
Path string `json:"path"`
}
type H5PPackage ¶
type H5PPackage struct { PackageDefinition *PackageDefinition `json:"-"` Content *Content `json:"-"` Libraries []*Library `json:"-"` }
func LoadH5PPackage ¶
func LoadH5PPackage(filePath string) (*H5PPackage, error)
func NewH5PPackage ¶
func NewH5PPackage() *H5PPackage
func (*H5PPackage) AddLibrary ¶
func (pkg *H5PPackage) AddLibrary(lib *Library)
func (*H5PPackage) CreateZipFile ¶
func (pkg *H5PPackage) CreateZipFile(outputPath string) error
func (*H5PPackage) SetContent ¶
func (pkg *H5PPackage) SetContent(content *Content)
func (*H5PPackage) SetPackageDefinition ¶
func (pkg *H5PPackage) SetPackageDefinition(def *PackageDefinition)
type Library ¶
type Library struct { Definition *LibraryDefinition `json:"-"` Semantics interface{} `json:"-"` MachineName string `json:"-"` Files map[string][]byte `json:"-"` }
type LibraryDefinition ¶
type LibraryDefinition struct { Title string `json:"title"` MachineName string `json:"machineName"` MajorVersion int `json:"majorVersion"` MinorVersion int `json:"minorVersion"` PatchVersion int `json:"patchVersion"` Runnable bool `json:"runnable"` Author string `json:"author,omitempty"` License string `json:"license,omitempty"` Description string `json:"description,omitempty"` PreloadedJs []FileReference `json:"preloadedJs,omitempty"` PreloadedCss []FileReference `json:"preloadedCss,omitempty"` DropLibraryCss []FileReference `json:"dropLibraryCss,omitempty"` Dependencies []LibraryDependency `json:"preloadedDependencies,omitempty"` }
type LibraryDependency ¶
type MultiChoiceQuestion ¶
type MultiChoiceQuestion struct { Library string `json:"library"` Params *schemas.MultiChoiceParams `json:"params"` }
MultiChoiceQuestion represents a typed H5P MultiChoice question
func NewMultiChoiceQuestion ¶
func NewMultiChoiceQuestion(params *schemas.MultiChoiceParams) *MultiChoiceQuestion
NewMultiChoiceQuestion creates a new typed MultiChoice question
func (*MultiChoiceQuestion) ToQuestion ¶
func (mcq *MultiChoiceQuestion) ToQuestion() *Question
ToQuestion converts a MultiChoiceQuestion to a generic Question
type PackageDefinition ¶
type PackageDefinition struct { Title string `json:"title"` Language string `json:"language"` MainLibrary string `json:"mainLibrary"` EmbedTypes []string `json:"embedTypes"` License string `json:"license,omitempty"` DefaultLanguage string `json:"defaultLanguage,omitempty"` Author string `json:"author,omitempty"` PreloadedDependencies []LibraryDependency `json:"preloadedDependencies"` EditorDependencies []LibraryDependency `json:"editorDependencies,omitempty"` }
type Question ¶
type Question struct { Library string `json:"library"` Params interface{} `json:"params"` }
type QuestionSet ¶
type QuestionSet struct { ProgressType string `json:"progressType,omitempty"` PassPercentage int `json:"passPercentage,omitempty"` BackgroundImage *BackgroundImage `json:"backgroundImage,omitempty"` Questions []Question `json:"questions"` ShowIntroPage bool `json:"showIntroPage,omitempty"` StartButtonText string `json:"startButtonText,omitempty"` Introduction string `json:"introduction,omitempty"` Title string `json:"title,omitempty"` ShowResultPage bool `json:"showResultPage,omitempty"` Message string `json:"message,omitempty"` SolutionButtonText string `json:"solutionButtonText,omitempty"` OverallFeedback []FeedbackRange `json:"overallFeedback,omitempty"` }
func FromJSON ¶
func FromJSON(data []byte) (*QuestionSet, error)
func (*QuestionSet) ToJSON ¶
func (qs *QuestionSet) ToJSON() ([]byte, error)
func (*QuestionSet) Validate ¶
func (qs *QuestionSet) Validate() error
type QuestionSetBuilder ¶
type QuestionSetBuilder struct {
// contains filtered or unexported fields
}
Example ¶
builder := NewQuestionSetBuilder() answers := []Answer{ CreateAnswer("Paris", true), CreateAnswer("London", false), CreateAnswer("Berlin", false), CreateAnswer("Madrid", false), } feedbackRanges := []FeedbackRange{ CreateFeedbackRange(0, 50, "You need more practice!"), CreateFeedbackRange(51, 80, "Good job!"), CreateFeedbackRange(81, 100, "Excellent work!"), } questionSet, err := builder. SetTitle("Geography Quiz"). SetProgressType("textual"). SetPassPercentage(60). SetIntroduction("Welcome to our geography quiz!"). SetStartButtonText("Start Quiz"). AddMultipleChoiceQuestion("What is the capital of France?", answers). AddOverallFeedback(feedbackRanges). Build() if err != nil { log.Fatal(err) } jsonData, err := questionSet.ToJSON() if err != nil { log.Fatal(err) } fmt.Printf("Generated H5P Question Set:\n%s\n", string(jsonData)) loadedQuestionSet, err := FromJSON(jsonData) if err != nil { log.Fatal(err) } err = loadedQuestionSet.Validate() if err != nil { log.Fatal(err) } fmt.Printf("Question set validated successfully!\n") fmt.Printf("Number of questions: %d\n", len(loadedQuestionSet.Questions)) fmt.Printf("Pass percentage: %d%%\n", loadedQuestionSet.PassPercentage)
func NewQuestionSetBuilder ¶
func NewQuestionSetBuilder() *QuestionSetBuilder
func (*QuestionSetBuilder) AddMultipleChoiceQuestion ¶
func (b *QuestionSetBuilder) AddMultipleChoiceQuestion(question string, answers []Answer) *QuestionSetBuilder
func (*QuestionSetBuilder) AddOverallFeedback ¶
func (b *QuestionSetBuilder) AddOverallFeedback(ranges []FeedbackRange) *QuestionSetBuilder
func (*QuestionSetBuilder) Build ¶
func (b *QuestionSetBuilder) Build() (*QuestionSet, error)
func (*QuestionSetBuilder) SetBackgroundImage ¶
func (b *QuestionSetBuilder) SetBackgroundImage(path, mime string) *QuestionSetBuilder
func (*QuestionSetBuilder) SetIntroduction ¶
func (b *QuestionSetBuilder) SetIntroduction(introduction string) *QuestionSetBuilder
func (*QuestionSetBuilder) SetPassPercentage ¶
func (b *QuestionSetBuilder) SetPassPercentage(percentage int) *QuestionSetBuilder
func (*QuestionSetBuilder) SetProgressType ¶
func (b *QuestionSetBuilder) SetProgressType(progressType string) *QuestionSetBuilder
func (*QuestionSetBuilder) SetStartButtonText ¶
func (b *QuestionSetBuilder) SetStartButtonText(text string) *QuestionSetBuilder
func (*QuestionSetBuilder) SetTitle ¶
func (b *QuestionSetBuilder) SetTitle(title string) *QuestionSetBuilder
Click to show internal directories.
Click to hide internal directories.