qa: Back to the same situation
This commit is contained in:
parent
00f84e43ca
commit
1aa82bb2ef
27 changed files with 1336 additions and 22 deletions
|
@ -17,6 +17,8 @@ func declareExercicesRoutes(router *gin.RouterGroup) {
|
|||
exercicesRoutes := router.Group("/exercices/:eid")
|
||||
exercicesRoutes.Use(exerciceHandler)
|
||||
exercicesRoutes.GET("", showExercice)
|
||||
|
||||
declareQARoutes(exercicesRoutes)
|
||||
}
|
||||
|
||||
func exerciceHandler(c *gin.Context) {
|
||||
|
@ -42,8 +44,15 @@ func exerciceHandler(c *gin.Context) {
|
|||
}
|
||||
|
||||
func listExercices(c *gin.Context) {
|
||||
// List all exercices
|
||||
exercices, err := fic.GetExercices()
|
||||
var exercices []*fic.Exercice
|
||||
var err error
|
||||
|
||||
if theme, ok := c.Get("theme"); ok {
|
||||
exercices, err = theme.(*fic.Theme).GetExercices()
|
||||
} else {
|
||||
// List all exercices
|
||||
exercices, err = fic.GetExercices()
|
||||
}
|
||||
if err != nil {
|
||||
log.Println("Unable to GetExercices: ", err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to list exercices: %s", err.Error())})
|
||||
|
|
Reference in a new issue