settings: change param to enable/disable depends by the depth

This commit is contained in:
nemunaire 2019-01-18 20:30:47 +01:00
parent 5d432cdcfc
commit 4ee70a8781
6 changed files with 12 additions and 15 deletions

View File

@ -51,11 +51,7 @@ func saveSettings(_ httprouter.Params, body []byte) (interface{}, error) {
func ApplySettings(config settings.FICSettings) { func ApplySettings(config settings.FICSettings) {
fic.PartialValidation = config.PartialValidation fic.PartialValidation = config.PartialValidation
if config.EnableExerciceDepend { fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth
fic.UnlockedChallengeDepth = 0
} else {
fic.UnlockedChallengeDepth = -1
}
fic.FirstBlood = config.FirstBlood fic.FirstBlood = config.FirstBlood
fic.SubmissionCostBase = config.SubmissionCostBase fic.SubmissionCostBase = config.SubmissionCostBase
fic.HintCoefficient = config.HintCurCoefficient fic.HintCoefficient = config.HintCurCoefficient

View File

@ -173,7 +173,7 @@ func main() {
DenyNameChange: false, DenyNameChange: false,
EnableResolutionRoute: false, EnableResolutionRoute: false,
PartialValidation: true, PartialValidation: true,
EnableExerciceDepend: true, UnlockedChallengeDepth:0,
}); err != nil { }); err != nil {
log.Fatal("Unable to initialize settings.json:", err) log.Fatal("Unable to initialize settings.json:", err)
} }

View File

@ -425,6 +425,7 @@ angular.module("FICApp")
.controller("SettingsController", function($scope, $rootScope, Settings, ROSettings, $location, $http, $interval) { .controller("SettingsController", function($scope, $rootScope, Settings, ROSettings, $location, $http, $interval) {
$scope.config = Settings.get(); $scope.config = Settings.get();
$scope.config.$promise.then(function(response) { $scope.config.$promise.then(function(response) {
response.enableExerciceDepend = response.unlockedChallengeDepth >= 0;
$rootScope.settings.start = new Date(response.start); $rootScope.settings.start = new Date(response.start);
$rootScope.settings.end = new Date(response.end); $rootScope.settings.end = new Date(response.end);
$rootScope.settings.generation = new Date(response.generation); $rootScope.settings.generation = new Date(response.generation);
@ -454,8 +455,11 @@ angular.module("FICApp")
var nEnd = this.config.end; var nEnd = this.config.end;
var nGen = this.config.generation; var nGen = this.config.generation;
var aTime = this.config.activateTime; var aTime = this.config.activateTime;
this.config.$update(function() { var state = this.config.enableExerciceDepend;
this.config.unlockedChallengeDepth = (this.config.enableExerciceDepend?this.config.unlockedChallengeDepth:-1)
this.config.$update(function(response) {
$rootScope.newBox('success', msg); $rootScope.newBox('success', msg);
response.enableExerciceDepend = response.unlockedChallengeDepth >= 0;
$rootScope.settings.start = new Date(nStart); $rootScope.settings.start = new Date(nStart);
$rootScope.settings.end = new Date(nEnd); $rootScope.settings.end = new Date(nEnd);
$rootScope.settings.generation = new Date(nGen); $rootScope.settings.generation = new Date(nGen);

View File

@ -139,6 +139,7 @@
<label class="custom-control custom-checkbox"> <label class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" ng-model="config.enableExerciceDepend"> <input class="custom-control-input" type="checkbox" ng-model="config.enableExerciceDepend">
<span class="custom-control-label">Activer les dépendances des exercices</span> <span class="custom-control-label">Activer les dépendances des exercices</span>
<input type="text" class="form-control form-control-sm" id="duration" ng-model="config.unlockedChallengeDepth" ng-disabled="!config.enableExerciceDepend" integer>
</label> </label>
</div> </div>

View File

@ -52,13 +52,9 @@ func reloadSettings(config settings.FICSettings) {
fic.WChoiceCoefficient = config.WChoiceCurCoefficient fic.WChoiceCoefficient = config.WChoiceCurCoefficient
fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient
ChStarted = time.Since(config.Start) >= 0 ChStarted = time.Since(config.Start) >= 0
if lastRegeneration != config.Generation || fic.PartialValidation != config.PartialValidation || 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.FirstBlood != config.FirstBlood || fic.SubmissionCostBase != config.SubmissionCostBase || fic.SubmissionUniqueness != config.SubmissionUniqueness {
fic.PartialValidation = config.PartialValidation fic.PartialValidation = config.PartialValidation
if config.EnableExerciceDepend { fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth
fic.UnlockedChallengeDepth = 0
} else {
fic.UnlockedChallengeDepth = -1
}
fic.FirstBlood = config.FirstBlood fic.FirstBlood = config.FirstBlood
fic.SubmissionCostBase = config.SubmissionCostBase fic.SubmissionCostBase = config.SubmissionCostBase

View File

@ -57,8 +57,8 @@ type FICSettings struct {
EnableResolutionRoute bool `json:"enableResolutionRoute"` EnableResolutionRoute bool `json:"enableResolutionRoute"`
// PartialValidation validates each correct given answers, don't expect Team to give all correct answer in a try. // PartialValidation validates each correct given answers, don't expect Team to give all correct answer in a try.
PartialValidation bool `json:"partialValidation"` PartialValidation bool `json:"partialValidation"`
// EnableExerciceDepend 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.
EnableExerciceDepend bool `json:"enableExerciceDepend"` UnlockedChallengeDepth int `json:"unlockedChallengeDepth"`
// SubmissionUniqueness don't count multiple times identical tries. // SubmissionUniqueness don't count multiple times identical tries.
SubmissionUniqueness bool `json:"submissionUniqueness"` SubmissionUniqueness bool `json:"submissionUniqueness"`
} }