diff --git a/libfic/theme.go b/libfic/theme.go index 3151381d..1b7b808f 100644 --- a/libfic/theme.go +++ b/libfic/theme.go @@ -56,6 +56,26 @@ func GetThemes() ([]*Theme, error) { } } +// GetThemesExtended returns a list of Themes including standalone exercices. +func GetThemesExtended() ([]*Theme, error) { + if themes, err := GetThemes(); err != nil { + return nil, err + } else { + // Append standalone exercices fake-themes + stdthm := &Theme{ + Name: "Défis indépendants", + URLId: "_", + Path: "exercices", + } + + if exercices, err := stdthm.GetExercices(); err == nil && len(exercices) > 0 { + themes = append(themes, stdthm) + } + + return themes, nil + } +} + // GetTheme retrieves a Theme from its identifier. func GetTheme(id int64) (*Theme, error) { t := &Theme{} diff --git a/qa/api/qa.go b/qa/api/qa.go index 66a71ac6..a76aa0d3 100644 --- a/qa/api/qa.go +++ b/qa/api/qa.go @@ -118,7 +118,7 @@ func getExerciceQA(c *gin.Context) { func exportQA(c *gin.Context) { var report string - themes, err := fic.GetThemes() + themes, err := fic.GetThemesExtended() if err != nil { log.Println("Unable to GetThemes: ", err.Error()) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to list themes: %s", err.Error())}) @@ -191,7 +191,7 @@ type ExportReport struct { func exportQAJSON(c *gin.Context) { report := map[string]ExportTheme{} - themes, err := fic.GetThemes() + themes, err := fic.GetThemesExtended() if err != nil { log.Println("Unable to GetThemes: ", err.Error()) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to list themes: %s", err.Error())})