backend: Don't consider non error in MCQ as good response
This commit is contained in:
parent
0a8d0dad30
commit
4b1b5445f7
@ -463,10 +463,11 @@ func (e *Exercice) CheckResponse(cksum []byte, respflags map[int]string, respmcq
|
|||||||
// Validate MCQs if no error
|
// Validate MCQs if no error
|
||||||
if valid {
|
if valid {
|
||||||
for _, mcq := range mcqs {
|
for _, mcq := range mcqs {
|
||||||
mcq.FoundBy(t)
|
if mcq.FoundBy(t) == nil {
|
||||||
goodResponses += 1
|
goodResponses += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check flags
|
// Check flags
|
||||||
for _, flag := range flags {
|
for _, flag := range flags {
|
||||||
|
@ -13,7 +13,7 @@ type Flag interface {
|
|||||||
GetOrder() int8
|
GetOrder() int8
|
||||||
Check(val interface{}) int
|
Check(val interface{}) int
|
||||||
IsOptionnal() bool
|
IsOptionnal() bool
|
||||||
FoundBy(t *Team)
|
FoundBy(t *Team) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFlag returns a list of flags comming with the challenge.
|
// GetFlag returns a list of flags comming with the challenge.
|
||||||
|
@ -335,8 +335,9 @@ func (k *FlagKey) Check(v interface{}) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FoundBy registers in the database that the given Team solved the flag.
|
// FoundBy registers in the database that the given Team solved the flag.
|
||||||
func (k *FlagKey) FoundBy(t *Team) {
|
func (k *FlagKey) FoundBy(t *Team) (err error) {
|
||||||
DBExec("INSERT INTO flag_found (id_flag, id_team, time) VALUES (?, ?, ?)", k.Id, t.Id, time.Now())
|
_, err = DBExec("INSERT INTO flag_found (id_flag, id_team, time) VALUES (?, ?, ?)", k.Id, t.Id, time.Now())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetExercice returns the parent Exercice where this flag can be found.
|
// GetExercice returns the parent Exercice where this flag can be found.
|
||||||
|
@ -178,7 +178,8 @@ func (k *FlagLabel) Check(v interface{}) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FoundBy registers in the database that the given Team solved the flag.
|
// FoundBy registers in the database that the given Team solved the flag.
|
||||||
func (k *FlagLabel) FoundBy(t *Team) {
|
func (k *FlagLabel) FoundBy(t *Team) error {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetExercice returns the parent Exercice where this flag can be found.
|
// GetExercice returns the parent Exercice where this flag can be found.
|
||||||
|
@ -341,6 +341,7 @@ func (m *MCQ) Check(v interface{}) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FoundBy registers in the database that the given Team solved the MCQ.
|
// FoundBy registers in the database that the given Team solved the MCQ.
|
||||||
func (m *MCQ) FoundBy(t *Team) {
|
func (m *MCQ) FoundBy(t *Team) (err error) {
|
||||||
DBExec("INSERT INTO mcq_found (id_mcq, id_team, time) VALUES (?, ?, ?)", m.Id, t.Id, time.Now())
|
_, err = DBExec("INSERT INTO mcq_found (id_mcq, id_team, time) VALUES (?, ?, ?)", m.Id, t.Id, time.Now())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user