Can Unlock challenge up to a certain level
This commit is contained in:
parent
e922171f17
commit
0a8d0dad30
@ -283,6 +283,7 @@ func deleteNextSettings(c *gin.Context) {
|
|||||||
func ApplySettings(config *settings.Settings) {
|
func ApplySettings(config *settings.Settings) {
|
||||||
fic.PartialValidation = config.PartialValidation
|
fic.PartialValidation = config.PartialValidation
|
||||||
fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth
|
fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth
|
||||||
|
fic.UnlockedChallengeUpTo = config.UnlockedChallengeUpTo
|
||||||
fic.DisplayAllFlags = config.DisplayAllFlags
|
fic.DisplayAllFlags = config.DisplayAllFlags
|
||||||
fic.DisplayMCQBadCount = config.DisplayMCQBadCount
|
fic.DisplayMCQBadCount = config.DisplayMCQBadCount
|
||||||
fic.FirstBlood = config.FirstBlood
|
fic.FirstBlood = config.FirstBlood
|
||||||
|
@ -189,6 +189,13 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row pr-1">
|
||||||
|
<label class="custom-control custom-checkbox col-5" ng-class="{'text-primary': !config.unlockedChallengeUpTo != !dist_config.unlockedChallengeUpTo}">
|
||||||
|
Débloquer jusqu'au niveau :
|
||||||
|
</label>
|
||||||
|
<input type="number" class="form-control form-control-sm col-7" ng-model="config.unlockedChallengeUpTo" min="1" integer ng-class="{'border-primary': config.unlockedChallengeUpTo != dist_config.unlockedChallengeUpTo}">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<label class="custom-control custom-checkbox">
|
<label class="custom-control custom-checkbox">
|
||||||
<input class="custom-control-input" type="checkbox" ng-model="config.partialValidation">
|
<input class="custom-control-input" type="checkbox" ng-model="config.partialValidation">
|
||||||
|
@ -75,9 +75,10 @@ func reloadSettings(config *settings.Settings) {
|
|||||||
fic.WChoiceCoefficient = config.WChoiceCurCoefficient
|
fic.WChoiceCoefficient = config.WChoiceCurCoefficient
|
||||||
fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient
|
fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient
|
||||||
ChStarted = config.Start.Unix() > 0 && time.Since(config.Start) >= 0
|
ChStarted = config.Start.Unix() > 0 && time.Since(config.Start) >= 0
|
||||||
if lastRegeneration != config.Generation || fic.PartialValidation != config.PartialValidation || fic.UnlockedChallengeDepth != config.UnlockedChallengeDepth || fic.DisplayAllFlags != config.DisplayAllFlags || fic.FirstBlood != config.FirstBlood || fic.SubmissionCostBase != config.SubmissionCostBase || fic.SubmissionUniqueness != config.SubmissionUniqueness {
|
if lastRegeneration != config.Generation || fic.PartialValidation != config.PartialValidation || fic.UnlockedChallengeDepth != config.UnlockedChallengeDepth || fic.UnlockedChallengeUpTo != config.UnlockedChallengeUpTo || fic.DisplayAllFlags != config.DisplayAllFlags || fic.FirstBlood != config.FirstBlood || fic.SubmissionCostBase != config.SubmissionCostBase || fic.SubmissionUniqueness != config.SubmissionUniqueness {
|
||||||
fic.PartialValidation = config.PartialValidation
|
fic.PartialValidation = config.PartialValidation
|
||||||
fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth
|
fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth
|
||||||
|
fic.UnlockedChallengeUpTo = config.UnlockedChallengeUpTo
|
||||||
fic.DisplayAllFlags = config.DisplayAllFlags
|
fic.DisplayAllFlags = config.DisplayAllFlags
|
||||||
|
|
||||||
fic.FirstBlood = config.FirstBlood
|
fic.FirstBlood = config.FirstBlood
|
||||||
|
@ -11,6 +11,9 @@ import (
|
|||||||
// UnlockedChallengeDepth is the number of challenges to unlock ahead (0: only the next one, -1: all)
|
// UnlockedChallengeDepth is the number of challenges to unlock ahead (0: only the next one, -1: all)
|
||||||
var UnlockedChallengeDepth int
|
var UnlockedChallengeDepth int
|
||||||
|
|
||||||
|
// UnlockedChallengeUpTo is the number of level to unlock
|
||||||
|
var UnlockedChallengeUpTo int
|
||||||
|
|
||||||
// WchoiceCoefficient is the current coefficient applied on the cost of changing flag into choices
|
// WchoiceCoefficient is the current coefficient applied on the cost of changing flag into choices
|
||||||
var WChoiceCoefficient = 1.0
|
var WChoiceCoefficient = 1.0
|
||||||
|
|
||||||
@ -117,6 +120,13 @@ func (t *Team) HasAccess(e *Exercice) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if UnlockedChallengeUpTo > 1 {
|
||||||
|
lvl, err := e.GetLevel()
|
||||||
|
if err == nil && lvl <= UnlockedChallengeUpTo {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for i := UnlockedChallengeDepth; i >= 0; i-- {
|
for i := UnlockedChallengeDepth; i >= 0; i-- {
|
||||||
// An exercice without dependency is accessible
|
// An exercice without dependency is accessible
|
||||||
if e.Depend == nil {
|
if e.Depend == nil {
|
||||||
|
@ -67,6 +67,8 @@ type Settings struct {
|
|||||||
PartialValidation bool `json:"partialValidation,omitempty"`
|
PartialValidation bool `json:"partialValidation,omitempty"`
|
||||||
// UnlockedChallengeDepth don't show (or permit to solve) to team challenges they are not unlocked through dependancies.
|
// UnlockedChallengeDepth don't show (or permit to solve) to team challenges they are not unlocked through dependancies.
|
||||||
UnlockedChallengeDepth int `json:"unlockedChallengeDepth"`
|
UnlockedChallengeDepth int `json:"unlockedChallengeDepth"`
|
||||||
|
// UnlockedChallengeUpTo unlock challenge up to a given level of deps.
|
||||||
|
UnlockedChallengeUpTo int `json:"unlockedChallengeUpTo"`
|
||||||
// SubmissionUniqueness don't count multiple times identical tries.
|
// SubmissionUniqueness don't count multiple times identical tries.
|
||||||
SubmissionUniqueness bool `json:"submissionUniqueness,omitempty"`
|
SubmissionUniqueness bool `json:"submissionUniqueness,omitempty"`
|
||||||
// CountOnlyNotGoodTries don't count as a try when one good response is given at least.
|
// CountOnlyNotGoodTries don't count as a try when one good response is given at least.
|
||||||
|
Loading…
Reference in New Issue
Block a user