Rename Exercice's Keys as Flags
This commit is contained in:
parent
f36e1c4e4d
commit
d21f3b0b83
18 changed files with 252 additions and 252 deletions
|
|
@ -260,15 +260,15 @@ func (e Exercice) TriedCount() int64 {
|
|||
|
||||
// CheckResponse, given both flags and MCQ responses, figures out if thoses are correct (or if they are previously solved).
|
||||
// In the meanwhile, CheckResponse registers good answers given (but it does not mark the challenge as solved at the end).
|
||||
func (e Exercice) CheckResponse(respkeys map[string]string, respmcq map[int64]bool, t Team) (bool, error) {
|
||||
func (e Exercice) CheckResponse(respflags map[string]string, respmcq map[int64]bool, t Team) (bool, error) {
|
||||
if err := e.NewTry(t); err != nil {
|
||||
return false, err
|
||||
} else if keys, err := e.GetKeys(); err != nil {
|
||||
} else if flags, err := e.GetFlags(); err != nil {
|
||||
return false, err
|
||||
} else if mcqs, err := e.GetMCQ(); err != nil {
|
||||
return false, err
|
||||
} else if len(keys) < 1 && len(mcqs) < 1 {
|
||||
return true, errors.New("Exercice with no key registered")
|
||||
} else if len(flags) < 1 && len(mcqs) < 1 {
|
||||
return true, errors.New("Exercice with no flag registered")
|
||||
} else {
|
||||
valid := true
|
||||
diff := 0
|
||||
|
|
@ -292,16 +292,16 @@ func (e Exercice) CheckResponse(respkeys map[string]string, respmcq map[int64]bo
|
|||
}
|
||||
}
|
||||
|
||||
// Check keys
|
||||
for _, key := range keys {
|
||||
if res, ok := respkeys[key.Label]; !ok {
|
||||
// Check flags
|
||||
for _, flag := range flags {
|
||||
if res, ok := respflags[flag.Label]; !ok {
|
||||
valid = false
|
||||
} else if !key.Check(res) {
|
||||
if !PartialValidation || t.HasPartiallySolved(key) == nil {
|
||||
} else if !flag.Check(res) {
|
||||
if !PartialValidation || t.HasPartiallySolved(flag) == nil {
|
||||
valid = false
|
||||
}
|
||||
} else {
|
||||
key.FoundBy(t)
|
||||
flag.FoundBy(t)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue