backend: Display a message when the exercice is disabled

This commit is contained in:
nemunaire 2023-04-06 15:38:53 +02:00
parent 089e604679
commit d8462cf58e
4 changed files with 37 additions and 1 deletions

30
backend/locked.go Normal file
View file

@ -0,0 +1,30 @@
package main
import (
"encoding/json"
"log"
"os"
"srs.epita.fr/fic-server/libfic"
)
var TeamLockedExercices = map[int64]map[string]bool{}
func treatLocked(pathname string, team *fic.Team) {
fd, err := os.Open(pathname)
if err != nil {
log.Printf("[ERR] Unable to open %q: %s", pathname, err)
return
}
var locked map[string]bool
jdec := json.NewDecoder(fd)
if err := jdec.Decode(&locked); err != nil {
log.Printf("[ERR] Unable to parse JSON %q: %s", pathname, err)
return
}
TeamLockedExercices[team.Id] = locked
log.Printf("Team %q (tid=%d) has locked %d exercices", team.Name, team.Id, len(locked))
}