settings: add new coefficient for all exercices

This commit is contained in:
nemunaire 2019-01-17 13:26:49 +01:00
commit 4a4d0f634a
5 changed files with 19 additions and 7 deletions

View file

@ -15,6 +15,9 @@ var PartialValidation bool
// Otherwise, all MCQ has to be correct for being validated.
var PartialMCQValidation bool
// ExerciceCurrentCoefficient is the current coefficient applied on solved exercices
var ExerciceCurrentCoefficient = 1.0
// Exercice represents a challenge inside a Theme.
type Exercice struct {
Id int64 `json:"id"`
@ -310,7 +313,7 @@ func (e Exercice) UpdateTry(t Team, nbdiff int) error {
// Solved registers that the given Team solves the challenge.
func (e Exercice) Solved(t Team) error {
if _, err := DBExec("INSERT INTO exercice_solved (id_exercice, id_team, time, coefficient) VALUES (?, ?, ?, ?)", e.Id, t.Id, time.Now(), e.Coefficient); err != nil {
if _, err := DBExec("INSERT INTO exercice_solved (id_exercice, id_team, time, coefficient) VALUES (?, ?, ?, ?)", e.Id, t.Id, time.Now(), e.Coefficient * ExerciceCurrentCoefficient); err != nil {
return err
} else {
return nil