Refactor flags
Both QCM and Key are Flag
This commit is contained in:
parent
e029ec5414
commit
a66d6885e7
13 changed files with 318 additions and 249 deletions
|
@ -362,7 +362,7 @@ func (e Exercice) TriedCount() int64 {
|
|||
func (e Exercice) CheckResponse(cksum []byte, respflags map[int64]string, respmcq map[int64]bool, t Team) (bool, error) {
|
||||
if err := e.NewTry(t, cksum); err != nil {
|
||||
return false, err
|
||||
} else if flags, err := e.GetFlags(); err != nil {
|
||||
} else if flags, err := e.GetFlagKeys(); err != nil {
|
||||
return false, err
|
||||
} else if mcqs, err := e.GetMCQ(); err != nil {
|
||||
return false, err
|
||||
|
@ -375,11 +375,11 @@ func (e Exercice) CheckResponse(cksum []byte, respflags map[int64]string, respmc
|
|||
// Check MCQs
|
||||
for _, mcq := range mcqs {
|
||||
if d := mcq.Check(respmcq); d > 0 {
|
||||
if !PartialValidation || t.HasPartiallyRespond(mcq) == nil {
|
||||
if !PartialValidation || t.HasPartiallySolved(mcq) == nil {
|
||||
valid = false
|
||||
diff += d
|
||||
}
|
||||
} else if !PartialMCQValidation {
|
||||
} else if !PartialMCQValidation && d == 0 {
|
||||
mcq.FoundBy(t)
|
||||
}
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ func (e Exercice) CheckResponse(cksum []byte, respflags map[int64]string, respmc
|
|||
for _, flag := range flags {
|
||||
if res, ok := respflags[flag.Id]; !ok && (!PartialValidation || t.HasPartiallySolved(flag) == nil) {
|
||||
valid = false
|
||||
} else if !flag.Check([]byte(res)) {
|
||||
} else if flag.Check([]byte(res)) != 0 {
|
||||
if !PartialValidation || t.HasPartiallySolved(flag) == nil {
|
||||
valid = false
|
||||
}
|
||||
|
|
Reference in a new issue