admin: new route to get exercice stats
This commit is contained in:
parent
c2887a1812
commit
ee2f65aae7
3 changed files with 57 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ func init() {
|
|||
router.PATCH("/api/exercices/:eid", apiHandler(exerciceHandler(partUpdateExercice)))
|
||||
router.DELETE("/api/exercices/:eid", apiHandler(exerciceHandler(deleteExercice)))
|
||||
|
||||
router.GET("/api/exercices/:eid/stats", apiHandler(exerciceHandler(getExerciceStats)))
|
||||
router.GET("/api/exercices/:eid/history.json", apiHandler(exerciceHandler(getExerciceHistory)))
|
||||
router.DELETE("/api/exercices/:eid/history.json", apiHandler(exerciceHandler(delExerciceHistory)))
|
||||
|
||||
|
|
@ -136,6 +137,15 @@ func showExercice(exercice fic.Exercice, body []byte) (interface{}, error) {
|
|||
return exercice, nil
|
||||
}
|
||||
|
||||
func getExerciceStats(exercice fic.Exercice, body []byte) (interface{}, error) {
|
||||
team_tries, tries := exercice.TriesByTeam()
|
||||
return map[string]interface{}{
|
||||
"solved": exercice.SolvedTeams(),
|
||||
"total_tried": tries,
|
||||
"team_tries": team_tries,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getExerciceHistory(exercice fic.Exercice, body []byte) (interface{}, error) {
|
||||
return exercice.GetHistory()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1197,6 +1197,12 @@ angular.module("FICApp")
|
|||
} else {
|
||||
$scope.exercice = Exercice.get({ exerciceId: $routeParams.exerciceId });
|
||||
}
|
||||
$http({
|
||||
url: "/api/exercices/" + $routeParams.exerciceId + "/stats",
|
||||
method: "GET"
|
||||
}).then(function(response) {
|
||||
$scope.stats = response.data;
|
||||
});
|
||||
$http({
|
||||
url: "/api/themes.json",
|
||||
method: "GET"
|
||||
|
|
|
|||
Reference in a new issue