New settings to only count bad submissions
This commit is contained in:
parent
b887288c78
commit
cd73622cae
9 changed files with 61 additions and 18 deletions
|
|
@ -315,8 +315,8 @@ func (e Exercice) NewTry(t Team, cksum []byte) error {
|
|||
|
||||
// UpdateTry applies modifications to the latest try registered for the given Team.
|
||||
// Updated values are time and the given nbdiff.
|
||||
func (e Exercice) UpdateTry(t Team, nbdiff int) error {
|
||||
if _, err := DBExec("UPDATE exercice_tries SET nbdiff = ?, time = ? WHERE id_exercice = ? AND id_team = ? ORDER BY time DESC LIMIT 1", nbdiff, time.Now(), e.Id, t.Id); err != nil {
|
||||
func (e Exercice) UpdateTry(t Team, nbdiff int, oneGood bool) error {
|
||||
if _, err := DBExec("UPDATE exercice_tries SET nbdiff = ?, onegood = ?, time = ? WHERE id_exercice = ? AND id_team = ? ORDER BY time DESC LIMIT 1", nbdiff, oneGood, time.Now(), e.Id, t.Id); err != nil {
|
||||
return err
|
||||
} else {
|
||||
return nil
|
||||
|
|
@ -422,6 +422,7 @@ func (e Exercice) CheckResponse(cksum []byte, respflags map[int]string, respmcq
|
|||
} else {
|
||||
valid := true
|
||||
diff := 0
|
||||
goodResponses := 0
|
||||
|
||||
// Check MCQs
|
||||
for _, mcq := range mcqs {
|
||||
|
|
@ -432,6 +433,7 @@ func (e Exercice) CheckResponse(cksum []byte, respflags map[int]string, respmcq
|
|||
}
|
||||
} else if !PartialMCQValidation && d == 0 {
|
||||
mcq.FoundBy(t)
|
||||
goodResponses += 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -439,6 +441,7 @@ func (e Exercice) CheckResponse(cksum []byte, respflags map[int]string, respmcq
|
|||
if valid {
|
||||
for _, mcq := range mcqs {
|
||||
mcq.FoundBy(t)
|
||||
goodResponses += 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -452,11 +455,12 @@ func (e Exercice) CheckResponse(cksum []byte, respflags map[int]string, respmcq
|
|||
}
|
||||
} else {
|
||||
flag.FoundBy(t)
|
||||
goodResponses += 1
|
||||
}
|
||||
}
|
||||
|
||||
if diff > 0 {
|
||||
e.UpdateTry(t, diff)
|
||||
if diff > 0 || goodResponses > 0 {
|
||||
e.UpdateTry(t, diff, goodResponses > 0)
|
||||
}
|
||||
|
||||
return valid, nil
|
||||
|
|
|
|||
Reference in a new issue