Able to sync and export standalone exercices

This commit is contained in:
nemunaire 2024-03-15 17:46:50 +01:00
parent 76f830b332
commit adb0e36dd4
15 changed files with 159 additions and 31 deletions

View file

@ -25,12 +25,12 @@ type exportedExercice struct {
// exportedTheme is a structure representing a Theme, as exposed to players.
type exportedTheme struct {
Name string `json:"name"`
Name string `json:"name,omitempty"`
URLId string `json:"urlid"`
Locked bool `json:"locked,omitempty"`
Authors string `json:"authors"`
Authors string `json:"authors,omitempty"`
Headline string `json:"headline,omitempty"`
Intro string `json:"intro"`
Intro string `json:"intro,omitempty"`
Image string `json:"image,omitempty"`
PartnerImage string `json:"partner_img,omitempty"`
PartnerLink string `json:"partner_href,omitempty"`
@ -43,12 +43,17 @@ func ExportThemes() (interface{}, error) {
if themes, err := GetThemes(); err != nil {
return nil, err
} else {
themes = append(themes, &Theme{URLId: "_", Path: "exercices"})
ret := map[string]exportedTheme{}
for _, theme := range themes {
exos := []exportedExercice{}
if exercices, err := theme.GetExercices(); err != nil {
return nil, err
} else if theme.URLId == "_" && len(exercices) == 0 {
// If no standalone exercices, don't append them
continue
} else {
for _, exercice := range exercices {
if exercice.Disabled && theme.Locked {