Partial resolution of exercices

This commit is contained in:
nemunaire 2016-12-04 19:08:46 +01:00
commit 3cd6cd959d
8 changed files with 46 additions and 24 deletions

View file

@ -5,6 +5,8 @@ import (
"time"
)
var PartialValidation bool
type Exercice struct {
Id int64 `json:"id"`
Title string `json:"title"`
@ -201,13 +203,14 @@ func (e Exercice) CheckResponse(resps map[string]string, t Team) (bool, error) {
valid := true
for _, key := range keys {
if _, ok := resps[key.Type]; !ok {
if res, ok := resps[key.Type]; !ok {
valid = false
break
}
if !key.Check(resps[key.Type]) {
valid = false
break
} else if !key.Check(res) {
if !PartialValidation || t.HasPartiallySolved(key) == nil {
valid = false
}
} else {
key.FoundBy(t)
}
}