Add a disabled state to exercices

This commit is contained in:
nemunaire 2023-03-20 11:23:03 +01:00
commit eb85b28f5b
10 changed files with 33 additions and 17 deletions

View file

@ -40,6 +40,8 @@ func treatWantChoices(pathname string, team *fic.Team) {
log.Printf("%s [ERR] Unable to retrieve the flag's underlying exercice: %s\n", id, err)
} else if !team.HasAccess(exercice) {
log.Printf("%s [!!!] The team asks to display choices whereas it doesn't have access to the exercice\n", id)
} else if exercice.Disabled {
log.Println("[!!!] The team submits something for a disabled exercice")
} else if err = team.DisplayChoices(flag); err != nil {
log.Printf("%s [ERR] %s\n", id, err)
} else {

View file

@ -38,6 +38,8 @@ func treatOpeningHint(pathname string, team *fic.Team) {
log.Printf("%s [ERR] Unable to retrieve the given hint: %s\n", id, err)
} else if exercice, err := hint.GetExercice(); err != nil {
log.Printf("%s [ERR] Unable to retrieve the hint's underlying exercice: %s\n", id, err)
} else if exercice.Disabled {
log.Println("[!!!] The team submits something for a disabled exercice")
} else if !team.HasAccess(exercice) {
log.Printf("%s [!!!] The team asks to open an hint whereas it doesn't have access to the exercice\n", id)
} else if !team.CanSeeHint(hint) {

View file

@ -44,6 +44,12 @@ func treatSubmission(pathname string, team *fic.Team, exercice_id string) {
return
}
// Check the exercice is not disabled
if exercice.Disabled {
log.Println("[!!!] The team submits something for a disabled exercice")
return
}
// Check the team can access this exercice
if !team.HasAccess(exercice) {
log.Println("[!!!] The team submits something for an exercice it doesn't have access yet")