qa: Use GetThemesExtended to include standalones exercices

This commit is contained in:
nemunaire 2024-09-18 11:54:52 +02:00
commit a82e3642a8
2 changed files with 22 additions and 2 deletions

View file

@ -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{}