Themes can have header image

This commit is contained in:
nemunaire 2018-11-25 03:20:03 +01:00
commit 0effdbcf5e
4 changed files with 20 additions and 9 deletions

View file

@ -2,6 +2,7 @@ package fic
import (
"fmt"
"path"
)
// exportedExercice is a structure representing a challenge, as exposed to players.
@ -21,6 +22,7 @@ type exportedTheme struct {
URLId string `json:"urlid"`
Authors string `json:"authors"`
Intro string `json:"intro"`
Image string `json:"image,omitempty"`
Exercices map[string]exportedExercice `json:"exercices"`
}
@ -47,11 +49,18 @@ func ExportThemes() (interface{}, error) {
exercice.TriedTeamCount(),
}
}
imgpath := ""
if len(theme.Image) > 0 {
imgpath = path.Join(FilesDir, theme.Image)
}
ret[fmt.Sprintf("%d", theme.Id)] = exportedTheme{
theme.Name,
theme.URLId,
theme.Authors,
theme.Intro,
imgpath,
exos,
}
}