From 4a4d0f634a0cbaf64c61ae748012a363e4cde630 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Thu, 17 Jan 2019 13:26:49 +0100 Subject: [PATCH] settings: add new coefficient for all exercices --- admin/static/views/settings.html | 16 +++++++++++----- backend/main.go | 1 + frontend/static/views/defi.html | 2 +- libfic/exercice.go | 5 ++++- settings/settings.go | 2 ++ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/admin/static/views/settings.html b/admin/static/views/settings.html index 4fa80130..192d4573 100644 --- a/admin/static/views/settings.html +++ b/admin/static/views/settings.html @@ -60,15 +60,21 @@
- -
+ + +
- -
+ +
+ + +
+ +
@@ -76,7 +82,7 @@
- +
diff --git a/backend/main.go b/backend/main.go index 9c6c306d..71b859ba 100644 --- a/backend/main.go +++ b/backend/main.go @@ -49,6 +49,7 @@ var skipInitialGeneration = false func reloadSettings(config settings.FICSettings) { fic.HintCoefficient = config.HintCurCoefficient fic.WChoiceCoefficient = config.WChoiceCurCoefficient + fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient if lastRegeneration != config.Generation || fic.PartialValidation != config.PartialValidation || fic.FirstBlood != config.FirstBlood || fic.SubmissionCostBase != config.SubmissionCostBase || fic.SubmissionUniqueness != config.SubmissionUniqueness { fic.PartialValidation = config.PartialValidation if config.EnableExerciceDepend { diff --git a/frontend/static/views/defi.html b/frontend/static/views/defi.html index b3202752..da234b65 100644 --- a/frontend/static/views/defi.html +++ b/frontend/static/views/defi.html @@ -30,7 +30,7 @@

    -
  • Gain : {{ 1 + settings.firstBlood | coeff }} prem's {{ themes[current_theme].exercices[current_exercice].curcoeff | coeff }} bonus
  • +
  • Gain : {{ 1 + settings.firstBlood | coeff }} prem's {{ themes[current_theme].exercices[current_exercice].curcoeff * settings.exerciceCurrentCoefficient | coeff }} bonus
  • Résolu par : .
diff --git a/libfic/exercice.go b/libfic/exercice.go index 0a6fcb45..ea2a3795 100644 --- a/libfic/exercice.go +++ b/libfic/exercice.go @@ -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 diff --git a/settings/settings.go b/settings/settings.go index d45a46aa..99719100 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -42,6 +42,8 @@ type FICSettings struct { FirstBlood float64 `json:"firstBlood"` // SubmissionCostBase is a complex number representing the cost of each attempts. SubmissionCostBase float64 `json:"submissionCostBase"` + // ExerciceCurrentCoefficient is the current coefficient applied globaly to exercices. + ExerciceCurCoefficient float64 `json:"exerciceCurrentCoefficient"` // HintCurrentCoefficient is the current coefficient applied to hint discovery. HintCurCoefficient float64 `json:"hintCurrentCoefficient"` // WChoiceCurCoefficient is the current coefficient applied to wanted choices.