New setting: introduce a decote/discount to exercice's gain
This commit is contained in:
parent
838ce2fb3f
commit
4451e41285
11 changed files with 123 additions and 24 deletions
|
|
@ -407,22 +407,34 @@ type exerciceStats struct {
|
|||
SolvedCount int64 `json:"solved_count"`
|
||||
FlagSolved []int64 `json:"flag_solved"`
|
||||
MCQSolved []int64 `json:"mcq_solved"`
|
||||
CurrentGain int64 `json:"current_gain"`
|
||||
}
|
||||
|
||||
func getExerciceStats(c *gin.Context) {
|
||||
e := c.MustGet("exercice").(*fic.Exercice)
|
||||
|
||||
current_gain := e.Gain
|
||||
if fic.DiscountedFactor > 0 {
|
||||
decoted_exercice, err := fic.GetDiscountedExercice(e.Id)
|
||||
if err == nil {
|
||||
current_gain = decoted_exercice.Gain
|
||||
} else {
|
||||
log.Println("Unable to fetch decotedExercice:", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, exerciceStats{
|
||||
TeamTries: e.TriedTeamCount(),
|
||||
TotalTries: e.TriedCount(),
|
||||
SolvedCount: e.SolvedCount(),
|
||||
FlagSolved: e.FlagSolved(),
|
||||
MCQSolved: e.MCQSolved(),
|
||||
CurrentGain: current_gain,
|
||||
})
|
||||
}
|
||||
|
||||
func getExercicesStats(c *gin.Context) {
|
||||
exercices, err := fic.GetExercices()
|
||||
exercices, err := fic.GetDiscountedExercices()
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
|
||||
}
|
||||
|
|
@ -436,6 +448,7 @@ func getExercicesStats(c *gin.Context) {
|
|||
SolvedCount: e.SolvedCount(),
|
||||
FlagSolved: e.FlagSolved(),
|
||||
MCQSolved: e.MCQSolved(),
|
||||
CurrentGain: e.Gain,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -307,6 +307,13 @@ func ApplySettings(config *settings.Settings) {
|
|||
fic.SubmissionCostBase = config.SubmissionCostBase
|
||||
fic.SubmissionUniqueness = config.SubmissionUniqueness
|
||||
fic.CountOnlyNotGoodTries = config.CountOnlyNotGoodTries
|
||||
|
||||
if config.DiscountedFactor != fic.DiscountedFactor {
|
||||
fic.DiscountedFactor = config.DiscountedFactor
|
||||
if err := fic.DBRecreateDiscountedView(); err != nil {
|
||||
log.Println("Unable to recreate exercices_discounted view:", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ResetSettings() error {
|
||||
|
|
@ -318,6 +325,7 @@ func ResetSettings() error {
|
|||
HintCurCoefficient: 1,
|
||||
WChoiceCurCoefficient: 1,
|
||||
GlobalScoreCoefficient: 1,
|
||||
DiscountedFactor: 0,
|
||||
AllowRegistration: false,
|
||||
CanJoinTeam: false,
|
||||
DenyTeamCreation: false,
|
||||
|
|
|
|||
Reference in a new issue