qa: Use GetThemesExtended to include standalones exercices
This commit is contained in:
parent
38fa6ec1de
commit
a82e3642a8
@ -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{}
|
||||
|
@ -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())})
|
||||
|
Loading…
Reference in New Issue
Block a user