admin: new page to display exercices flags
This commit is contained in:
parent
15ae32090f
commit
3f692984c7
@ -29,6 +29,10 @@ angular.module("FICApp", ["ngRoute", "ngResource", "ngSanitize"])
|
|||||||
controller: "ExerciceController",
|
controller: "ExerciceController",
|
||||||
templateUrl: "views/exercice.html"
|
templateUrl: "views/exercice.html"
|
||||||
})
|
})
|
||||||
|
.when("/exercices/:exerciceId/flags", {
|
||||||
|
controller: "ExerciceController",
|
||||||
|
templateUrl: "views/exercice-flags.html"
|
||||||
|
})
|
||||||
.when("/exercices/:exerciceId/resolution", {
|
.when("/exercices/:exerciceId/resolution", {
|
||||||
controller: "ExerciceController",
|
controller: "ExerciceController",
|
||||||
templateUrl: "views/exercice-resolution.html"
|
templateUrl: "views/exercice-resolution.html"
|
||||||
@ -262,7 +266,9 @@ angular.module("FICApp")
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.factory("ExerciceFlagChoices", function($resource) {
|
.factory("ExerciceFlagChoices", function($resource) {
|
||||||
return $resource("/api/exercices/:exerciceId/flags/:flagId/choices", { exerciceId: '@idExercice', flagId: '@id' })
|
return $resource("/api/exercices/:exerciceId/flags/:flagId/choices/:choiceId", { exerciceId: '@idExercice', flagId: '@idFlag', choiceId: '@id' }, {
|
||||||
|
'update': {method: 'PUT'},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.factory("ExerciceFlagDeps", function($resource) {
|
.factory("ExerciceFlagDeps", function($resource) {
|
||||||
return $resource("/api/exercices/:exerciceId/flags/:flagId/dependancies", { exerciceId: '@idExercice', flagId: '@id' })
|
return $resource("/api/exercices/:exerciceId/flags/:flagId/dependancies", { exerciceId: '@idExercice', flagId: '@id' })
|
||||||
@ -1632,6 +1638,12 @@ angular.module("FICApp")
|
|||||||
.controller("ExerciceFlagsController", function($scope, ExerciceFlag, $routeParams, $rootScope, $http) {
|
.controller("ExerciceFlagsController", function($scope, ExerciceFlag, $routeParams, $rootScope, $http) {
|
||||||
$scope.flags = ExerciceFlag.query({ exerciceId: $routeParams.exerciceId });
|
$scope.flags = ExerciceFlag.query({ exerciceId: $routeParams.exerciceId });
|
||||||
|
|
||||||
|
$scope.flags.$promise.then(function(flags) {
|
||||||
|
flags.forEach(function(flag, fid) {
|
||||||
|
flags[fid].values = [''];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$scope.changeValue = function(flag) {
|
$scope.changeValue = function(flag) {
|
||||||
flag.value = undefined;
|
flag.value = undefined;
|
||||||
flag.show_raw = true;
|
flag.show_raw = true;
|
||||||
@ -1656,6 +1668,13 @@ angular.module("FICApp")
|
|||||||
$rootScope.staticFilesNeedUpdate++;
|
$rootScope.staticFilesNeedUpdate++;
|
||||||
}
|
}
|
||||||
$scope.testFlag = function(flag) {
|
$scope.testFlag = function(flag) {
|
||||||
|
if (flag.values) {
|
||||||
|
var val = flag.value;
|
||||||
|
treatFlagKey(flag);
|
||||||
|
flag.test_str = flag.value;
|
||||||
|
flag.value = val;
|
||||||
|
}
|
||||||
|
|
||||||
if (flag.test_str) {
|
if (flag.test_str) {
|
||||||
$http({
|
$http({
|
||||||
url: "/api/exercices/" + $routeParams.exerciceId + "/flags/" + flag.id + "/try",
|
url: "/api/exercices/" + $routeParams.exerciceId + "/flags/" + flag.id + "/try",
|
||||||
@ -1691,6 +1710,41 @@ angular.module("FICApp")
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
.controller("ExerciceFlagChoicesController", function($scope, ExerciceFlagChoices, $routeParams) {
|
||||||
|
$scope.choices = ExerciceFlagChoices.query({ exerciceId: $routeParams.exerciceId, flagId: $scope.flag.id })
|
||||||
|
|
||||||
|
$scope.flag.wantchoices = function() {
|
||||||
|
$scope.flag.choices = {};
|
||||||
|
$scope.choices.forEach(function(choice) {
|
||||||
|
$scope.flag.choices[choice.value] = choice.label
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$scope.choices.$promise.then(function(choices) {
|
||||||
|
if ($scope.flag.choices_cost == 0 && choices.length > 0) {
|
||||||
|
$scope.flag.wantchoices()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
$scope.addChoice = function() {
|
||||||
|
$scope.choices.push(new ExerciceFlagChoices())
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.saveChoice = function() {
|
||||||
|
if (this.choice.id)
|
||||||
|
this.choice.$update({exerciceId: $routeParams.exerciceId, flagId: this.flag.id})
|
||||||
|
else
|
||||||
|
this.choice.$save({exerciceId: $routeParams.exerciceId, flagId: this.flag.id})
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.deleteChoice = function() {
|
||||||
|
if (this.choice.id)
|
||||||
|
this.choice.$delete({exerciceId: $routeParams.exerciceId, flagId: this.flag.id}, function() {
|
||||||
|
$scope.choices = ExerciceFlagChoices.query({ exerciceId: $routeParams.exerciceId, flagId: $scope.flag.id })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
.controller("ExerciceFlagDepsController", function($scope, $routeParams, ExerciceFlagDeps) {
|
.controller("ExerciceFlagDepsController", function($scope, $routeParams, ExerciceFlagDeps) {
|
||||||
$scope.init = function(flag) {
|
$scope.init = function(flag) {
|
||||||
$scope.deps = ExerciceFlagDeps.query({ exerciceId: $routeParams.exerciceId, flagId: flag.id });
|
$scope.deps = ExerciceFlagDeps.query({ exerciceId: $routeParams.exerciceId, flagId: flag.id });
|
||||||
|
159
admin/static/views/exercice-flags.html
Normal file
159
admin/static/views/exercice-flags.html
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
<div ng-controller="ExerciceFlagsController">
|
||||||
|
<button type="button" ng-click="syncFlags()" class="btn btn-light float-right"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Synchroniser</button>
|
||||||
|
<h2>
|
||||||
|
<a href="exercices/{{exercice.id}}">{{exercice.title}}</a> <small class="text-muted">Flags</small>
|
||||||
|
<div class="btn-group" role="group" ng-if="themes[exercice.id_theme].exercices[exercice.id]">
|
||||||
|
<a href="exercices/{{ themes[exercice.id_theme].exercices[exercice.id].previous }}/flags" title="Exercice précédent" ng-class="{'disabled': !themes[exercice.id_theme].exercices[exercice.id].previous}" class="btn btn-sm btn-light"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></a>
|
||||||
|
<a href="exercices/{{ themes[exercice.id_theme].exercices[exercice.id].next }}/flags" title="Exercice suivant" ng-class="{'disabled': !themes[exercice.id_theme].exercices[exercice.id].next}" class="btn btn-sm btn-light"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></a>
|
||||||
|
</div>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div class="card border-success mb-3">
|
||||||
|
<div class="card-header bg-success text-light">
|
||||||
|
<button type="button" ng-click="addFlag()" class="btn btn-primary float-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Ajouter</button>
|
||||||
|
<h4 class="m-0">Drapeaux</h4>
|
||||||
|
</div>
|
||||||
|
<div class="list-group">
|
||||||
|
<div ng-repeat="flag in flags" class="list-group-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<form ng-submit="saveFlag()" class="form-horizontal" id="flag-{{flag.id}}">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="float-right" ng-show="flag.id">
|
||||||
|
<button type="submit" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
<label for="klabel{{flag.id}}" class="col-form-label-sm">Intitulé</label>
|
||||||
|
<input type="text" id="klabel{{flag.id}}" ng-model="flag.label" class="form-control form-control-sm" placeholder="Intitulé" title="Intitulé">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="float-right">
|
||||||
|
<button type="button" ng-click="deleteFlag()" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
<label for="khelp{{flag.id}}" class="col-form-label-sm">Placeholder</label>
|
||||||
|
<input type="text" id="khelp{{flag.id}}" ng-model="flag.help" class="form-control form-control-sm" placeholder="Indication de formatage" title="Indication de formatage">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="kvalue{{flag.id}}" class="col-form-label-sm">Valeur</label>
|
||||||
|
<div class="input-group" ng-if="flag.id && !flag.show_raw">
|
||||||
|
<input type="text" id="kvalue{{flag.id}}" ng-model="flag.value" class="form-control form-control-sm" placeholder="Condensat" title="Condensat">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-sm btn-outline-secondary" ng-click="changeValue(flag)" title="Cliquez pour éditer la valeur brute du flag, au lieu du checksum" type="button"><span class="glyphicon glyphicon-erase" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<input type="text" id="kflag{{flag.id}}" ng-model="flag.flag" class="form-control form-control-sm" placeholder="Chaîne brute à valider" ng-if="!flag.id || flag.show_raw" title="Chaîne brute à valider">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="kvre{{flag.id}}" class="col-form-label-sm">Validator regexp</label>
|
||||||
|
<input type="text" id="kvre{{flag.id}}" ng-model="flag.validator_regexp" class="form-control form-control-sm" placeholder="Regexp selecting validation string" title="Regexp selecting validation string">
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-auto custom-control custom-checkbox ml-1">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="kicase{{flag.id}}" ng-model="flag.ignorecase">
|
||||||
|
<label class="custom-control-label" for="kicase{{flag.id}}">Ignore case</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto custom-control custom-checkbox ml-1">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="kmline{{flag.id}}" ng-model="flag.multiline">
|
||||||
|
<label class="custom-control-label" for="kmline{{flag.id}}">Multiline</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="text" id="kccost{{flag.id}}" ng-model="flag.choices_cost" class="form-control form-control-sm" placeholder="Choices cost" title="Choices cost" integer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<div ng-controller="ExerciceFlagDepsController" ng-init="init(flag)">
|
||||||
|
Dépendances :
|
||||||
|
<ul ng-if="deps.length > 0">
|
||||||
|
<dependancy ng-repeat="dep in deps" dep="dep"></dependancy>
|
||||||
|
</ul>
|
||||||
|
<span ng-if="deps.length == 0"> sans</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-4" ng-controller="ExerciceFlagChoicesController">
|
||||||
|
<div class="btn-toolbar justify-content-end mb-2" role="toolbar">
|
||||||
|
<div class="btn-group" role="group">
|
||||||
|
<button type="button" ng-click="addChoice()" class="btn btn-sm btn-primary"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Ajouter choix</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ng-repeat="choice in choices" ng-if="choices.length > 0">
|
||||||
|
<div class="row">
|
||||||
|
<label for="clabel_{{choice.id}}" class="col-sm-3 col-form-label-sm">Intitulé</label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
<input type="text" id="clabel_{{choice.id}}" ng-model="choice.label" class="form-control form-control-sm">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<button type="button" ng-click="saveChoice()" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="cvalue_{{choice.id}}" class="col-sm-3 col-form-label-sm">Valeur</label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
<input type="text" id="cvalue_{{choice.id}}" ng-model="choice.value" class="form-control form-control-sm">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<button type="button" ng-click="deleteChoice()" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr ng-if="!$last">
|
||||||
|
</div>
|
||||||
|
<span ng-if="choices.length == 0">Aucun choix</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form ng-submit="testFlag(flag)" class="row bg-dark" style="border-radius: 5px; padding: 5px 0">
|
||||||
|
<div class="col-11">
|
||||||
|
<flag-key kid="flag.id" key="flag" settings="{'wchoiceCurrentCoefficient': 1.0}" wantchoices="flag.wantchoices"></flag-key>
|
||||||
|
</div>
|
||||||
|
<div class="col-1">
|
||||||
|
<button class="btn btn-warning" type="submit"><span class="glyphicon glyphicon-play" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card border-success mb-3" ng-controller="ExerciceMCQFlagsController">
|
||||||
|
<div class="card-header bg-success text-light">
|
||||||
|
<button type="button" ng-click="addQuizz()" class="btn btn-primary float-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Ajouter</button>
|
||||||
|
<h4 class="m-0">Quizz</h4>
|
||||||
|
</div>
|
||||||
|
<div class="list-group">
|
||||||
|
<form ng-submit="saveQuiz()" class="list-group-item" ng-repeat="(qk,q) in quiz">
|
||||||
|
<div class="form-group row" id="quiz-{{q.id}}">
|
||||||
|
<input type="text" id="qlabel{{q.id}}" ng-model="q.title" class="col form-control" placeholder="Intitulé">
|
||||||
|
<div class="col-auto" ng-show="q.id">
|
||||||
|
<button type="button" ng-click="deleteQuiz()" class="btn btn-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row" ng-repeat="(ck,choice) in q.entries">
|
||||||
|
<div class="col form-check">
|
||||||
|
<label class="custom-control custom-checkbox">
|
||||||
|
<input class="custom-control-input" type="checkbox" ng-model="choice.response">
|
||||||
|
<span class="custom-control-label">
|
||||||
|
<input type="text" id="kchoice{{q.id}}-{{choice.id}}" ng-model="choice.label" class="form-control form-control-sm" placeholder="Intitulé">
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<button type="button" ng-click="deleteChoice()" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-auto">
|
||||||
|
<button type="button" ng-click="addChoice()" class="btn btn-primary"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Ajouter un choix</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ng-controller="ExerciceMCQDepsController" ng-init="init(q)">
|
||||||
|
Dépendances :
|
||||||
|
<ul ng-if="deps.length > 0">
|
||||||
|
<dependancy ng-repeat="dep in deps" dep="dep"></dependancy>
|
||||||
|
</ul>
|
||||||
|
<span ng-if="deps.length == 0"> sans</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -5,8 +5,9 @@
|
|||||||
<a href="exercices/{{ themes[exercice.id_theme].exercices[exercice.id].previous }}" title="Exercice précédent" ng-class="{'disabled': !themes[exercice.id_theme].exercices[exercice.id].previous}" class="btn btn-sm btn-light"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></a>
|
<a href="exercices/{{ themes[exercice.id_theme].exercices[exercice.id].previous }}" title="Exercice précédent" ng-class="{'disabled': !themes[exercice.id_theme].exercices[exercice.id].previous}" class="btn btn-sm btn-light"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></a>
|
||||||
<a href="exercices/{{ themes[exercice.id_theme].exercices[exercice.id].next }}" title="Exercice suivant" ng-class="{'disabled': !themes[exercice.id_theme].exercices[exercice.id].next}" class="btn btn-sm btn-light"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></a>
|
<a href="exercices/{{ themes[exercice.id_theme].exercices[exercice.id].next }}" title="Exercice suivant" ng-class="{'disabled': !themes[exercice.id_theme].exercices[exercice.id].next}" class="btn btn-sm btn-light"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></a>
|
||||||
</div>
|
</div>
|
||||||
<a href="exercices/{{exercice.id}}/resolution" ng-disabled="!exercice.videoURI" class="float-right btn btn-sm btn-info"><span class="glyphicon glyphicon-facetime-video" aria-hidden="true"></span> Vidéo</a>
|
<a href="exercices/{{exercice.id}}/resolution" ng-disabled="!exercice.videoURI" class="float-right ml-2 btn btn-sm btn-info"><span class="glyphicon glyphicon-facetime-video" aria-hidden="true"></span> Vidéo</a>
|
||||||
<button type="button" ng-click="syncExo()" ng-class="{'disabled': inSync}" class="float-right btn btn-sm btn-light"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Synchroniser</button>
|
<a href="exercices/{{exercice.id}}/flags" class="float-right ml-2 btn btn-sm btn-success"><span class="glyphicon glyphicon-flag" aria-hidden="true"></span> Flags</a>
|
||||||
|
<button type="button" ng-click="syncExo()" ng-class="{'disabled': inSync}" class="float-right ml-2 btn btn-sm btn-light"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Synchroniser</button>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div class="row mb-5">
|
<div class="row mb-5">
|
||||||
|
@ -1,51 +1,3 @@
|
|||||||
var alertNbLines = true;
|
|
||||||
|
|
||||||
function treatFlagKey(flag) {
|
|
||||||
if (flag.values !== undefined) {
|
|
||||||
if (flag.separator) {
|
|
||||||
for (var i = flag.values.length - 1; i >= 0; i--) {
|
|
||||||
if (flag.nb_lines && (flag.values[i] == undefined || !flag.values[i].length)) {
|
|
||||||
if (alertNbLines) {
|
|
||||||
alertNbLines = false;
|
|
||||||
if (!confirm("Lorsque plusieurs flags sont attendus pour une même question, ceux-ci ne sont pas validés un par un. Ils ne sont validés qu'une fois tous les champs remplis correctement. (Sauf mention contraire, l'ordre n'importe pas)"))
|
|
||||||
console.log(flag.values[9999].length); // Launch exception here to avoid form validation
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!flag.values[i].length) {
|
|
||||||
flag.values.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag.ignore_order)
|
|
||||||
flag.value = flag.values.slice().sort().join(flag.separator) + flag.separator;
|
|
||||||
else
|
|
||||||
flag.value = flag.values.join(flag.separator) + flag.separator;
|
|
||||||
|
|
||||||
if (flag.values.length == 0)
|
|
||||||
flag.values = [""];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
flag.value = flag.values[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag.found == null && flag.soluce !== undefined) {
|
|
||||||
if (flag.value && flag.soluce) {
|
|
||||||
if (flag.ignore_case)
|
|
||||||
flag.value = flag.value.toLowerCase();
|
|
||||||
if (flag.validator_regexp) {
|
|
||||||
var re = new RegExp(flag.validator_regexp, flag.ignore_case?'ui':'u');
|
|
||||||
var match = re.exec(flag.value);
|
|
||||||
match.shift();
|
|
||||||
flag.value = match.join("+");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag.soluce == b2sum(flag.value))
|
|
||||||
flag.found = new Date();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return flag.found !== undefined && flag.found !== false;
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||||
.config(function($routeProvider, $locationProvider) {
|
.config(function($routeProvider, $locationProvider) {
|
||||||
$routeProvider
|
$routeProvider
|
||||||
@ -126,43 +78,6 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||||||
$rootScope.notify_field = 0;
|
$rootScope.notify_field = 0;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.component('flagKey', {
|
|
||||||
bindings: {
|
|
||||||
kid: '=',
|
|
||||||
key: '=',
|
|
||||||
settings: '=',
|
|
||||||
wantchoices: '=',
|
|
||||||
},
|
|
||||||
controller: function() {
|
|
||||||
this.additem = function(key) {
|
|
||||||
this.key.values.push("");
|
|
||||||
};
|
|
||||||
},
|
|
||||||
template: `
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="sol_{{ $ctrl.kid }}_0" ng-class="{'text-light': !$ctrl.key.found}">{{ $ctrl.key.label }} :</label>
|
|
||||||
<span ng-if="$ctrl.key.found && $ctrl.key.value" ng-bind="$ctrl.key.value"></span>
|
|
||||||
<div class="input-group" ng-repeat="v in $ctrl.key.values track by $index" ng-class="{'mt-1': !$first}" ng-if="!$ctrl.key.found">
|
|
||||||
<input type="text" class="form-control flag" id="sol_{{ $ctrl.kid }}_{{ $index }}" autocomplete="off" name="sol_{{ $ctrl.kid }}_{{ $index }}" ng-model="$ctrl.key.values[$index]" ng-if="!$ctrl.key.choices && !$ctrl.key.multiline" placeholder="{{ $ctrl.key.help }}" title="{{ $ctrl.key.help }}">
|
|
||||||
<textarea class="form-control flag" id="sol_{{ $ctrl.kid }}_{{ $index }}" autocomplete="off" name="sol_{{ $ctrl.kid }}_{{ $index }}" ng-model="$ctrl.key.values[$index]" ng-if="!$ctrl.key.choices && $ctrl.key.multiline" placeholder="{{ $ctrl.key.help }}" title="{{ $ctrl.key.help }}"></textarea>
|
|
||||||
<select class="custom-select" id="sol_{{ $ctrl.kid }}" name="sol_{{ $ctrl.kid }}" ng-model="$ctrl.key.values[$index]" ng-if="$ctrl.key.choices" ng-options="l as v for (l, v) in $ctrl.key.choices"></select>
|
|
||||||
<div class="input-group-append" ng-if="$ctrl.key.choices_cost">
|
|
||||||
<button class="btn btn-success" type="button" ng-click="$ctrl.wantchoices($ctrl.kid)" ng-class="{disabled: $ctrl.key.wcsubmitted}" title="Cliquez pour échanger ce champ de texte par une liste de choix. L'opération vous coûtera {{ $ctrl.key.choices_cost * $ctrl.settings.wchoiceCurrentCoefficient }} points.">
|
|
||||||
<span class="glyphicon glyphicon-tasks" aria-hidden="true"></span>
|
|
||||||
Liste de propositions (<ng-pluralize count="$ctrl.key.choices_cost * $ctrl.settings.wchoiceCurrentCoefficient" when="{'one': '{} point', 'other': '{} points'}"></ng-pluralize>)
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="input-group-append" ng-if="$ctrl.key.separator && !$ctrl.key.nb_lines && $last">
|
|
||||||
<button class="btn btn-success" type="button" ng-click="$ctrl.additem(key)" title="Ajouter un élément.">
|
|
||||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<small class="form-text text-muted" ng-if="!$ctrl.key.found && $ctrl.key.help2.length > 0" ng-bind="$ctrl.key.help2"></small>
|
|
||||||
<span class="glyphicon glyphicon-ok form-control-feedback text-success" aria-hidden="true" ng-if="$ctrl.key.found" title="Flag trouvé à {{ $ctrl.key.found | date:'mediumTime'}}"></span>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
})
|
|
||||||
.controller("DataController", function($sce, $scope, $http, $rootScope, $interval, $location) {
|
.controller("DataController", function($sce, $scope, $http, $rootScope, $interval, $location) {
|
||||||
var actMenu = function() {
|
var actMenu = function() {
|
||||||
if ($scope.my && $scope.themes) {
|
if ($scope.my && $scope.themes) {
|
||||||
|
@ -1,3 +1,51 @@
|
|||||||
|
var alertNbLines = true;
|
||||||
|
|
||||||
|
function treatFlagKey(flag) {
|
||||||
|
if (flag.values !== undefined) {
|
||||||
|
if (flag.separator) {
|
||||||
|
for (var i = flag.values.length - 1; i >= 0; i--) {
|
||||||
|
if (flag.nb_lines && (flag.values[i] == undefined || !flag.values[i].length)) {
|
||||||
|
if (alertNbLines) {
|
||||||
|
alertNbLines = false;
|
||||||
|
if (!confirm("Lorsque plusieurs flags sont attendus pour une même question, ceux-ci ne sont pas validés un par un. Ils ne sont validés qu'une fois tous les champs remplis correctement. (Sauf mention contraire, l'ordre n'importe pas)"))
|
||||||
|
console.log(flag.values[9999].length); // Launch exception here to avoid form validation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!flag.values[i].length) {
|
||||||
|
flag.values.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag.ignore_order)
|
||||||
|
flag.value = flag.values.slice().sort().join(flag.separator) + flag.separator;
|
||||||
|
else
|
||||||
|
flag.value = flag.values.join(flag.separator) + flag.separator;
|
||||||
|
|
||||||
|
if (flag.values.length == 0)
|
||||||
|
flag.values = [""];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
flag.value = flag.values[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag.found == null && flag.soluce !== undefined) {
|
||||||
|
if (flag.value && flag.soluce) {
|
||||||
|
if (flag.ignore_case)
|
||||||
|
flag.value = flag.value.toLowerCase();
|
||||||
|
if (flag.validator_regexp) {
|
||||||
|
var re = new RegExp(flag.validator_regexp, flag.ignore_case?'ui':'u');
|
||||||
|
var match = re.exec(flag.value);
|
||||||
|
match.shift();
|
||||||
|
flag.value = match.join("+");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag.soluce == b2sum(flag.value))
|
||||||
|
flag.found = new Date();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flag.found !== undefined && flag.found !== false;
|
||||||
|
}
|
||||||
|
|
||||||
String.prototype.capitalize = function() {
|
String.prototype.capitalize = function() {
|
||||||
return this
|
return this
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
@ -130,6 +178,45 @@ angular.module("FICApp")
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
angular.module("FICApp")
|
||||||
|
.component('flagKey', {
|
||||||
|
bindings: {
|
||||||
|
kid: '=',
|
||||||
|
key: '=',
|
||||||
|
settings: '=',
|
||||||
|
wantchoices: '=',
|
||||||
|
},
|
||||||
|
controller: function() {
|
||||||
|
this.additem = function(key) {
|
||||||
|
this.key.values.push("");
|
||||||
|
};
|
||||||
|
},
|
||||||
|
template: `
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="sol_{{ $ctrl.kid }}_0" ng-class="{'text-light': !$ctrl.key.found}">{{ $ctrl.key.label }} :</label>
|
||||||
|
<span ng-if="$ctrl.key.found && $ctrl.key.value" ng-bind="$ctrl.key.value"></span>
|
||||||
|
<div class="input-group" ng-repeat="v in $ctrl.key.values track by $index" ng-class="{'mt-1': !$first}" ng-if="!$ctrl.key.found">
|
||||||
|
<input type="text" class="form-control flag" id="sol_{{ $ctrl.kid }}_{{ $index }}" autocomplete="off" name="sol_{{ $ctrl.kid }}_{{ $index }}" ng-model="$ctrl.key.values[$index]" ng-if="!$ctrl.key.choices && !$ctrl.key.multiline" placeholder="{{ $ctrl.key.help }}" title="{{ $ctrl.key.help }}">
|
||||||
|
<textarea class="form-control flag" id="sol_{{ $ctrl.kid }}_{{ $index }}" autocomplete="off" name="sol_{{ $ctrl.kid }}_{{ $index }}" ng-model="$ctrl.key.values[$index]" ng-if="!$ctrl.key.choices && $ctrl.key.multiline" placeholder="{{ $ctrl.key.help }}" title="{{ $ctrl.key.help }}"></textarea>
|
||||||
|
<select class="custom-select" id="sol_{{ $ctrl.kid }}" name="sol_{{ $ctrl.kid }}" ng-model="$ctrl.key.values[$index]" ng-if="$ctrl.key.choices" ng-options="l as v for (l, v) in $ctrl.key.choices"></select>
|
||||||
|
<div class="input-group-append" ng-if="$ctrl.key.choices_cost">
|
||||||
|
<button class="btn btn-success" type="button" ng-click="$ctrl.wantchoices($ctrl.kid)" ng-class="{disabled: $ctrl.key.wcsubmitted}" title="Cliquez pour échanger ce champ de texte par une liste de choix. L'opération vous coûtera {{ $ctrl.key.choices_cost * $ctrl.settings.wchoiceCurrentCoefficient }} points.">
|
||||||
|
<span class="glyphicon glyphicon-tasks" aria-hidden="true"></span>
|
||||||
|
Liste de propositions (<ng-pluralize count="$ctrl.key.choices_cost * $ctrl.settings.wchoiceCurrentCoefficient" when="{'one': '{} point', 'other': '{} points'}"></ng-pluralize>)
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="input-group-append" ng-if="$ctrl.key.separator && !$ctrl.key.nb_lines && $last">
|
||||||
|
<button class="btn btn-success" type="button" ng-click="$ctrl.additem(key)" title="Ajouter un élément.">
|
||||||
|
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<small class="form-text text-muted" ng-if="!$ctrl.key.found && $ctrl.key.help2.length > 0" ng-bind="$ctrl.key.help2"></small>
|
||||||
|
<span class="glyphicon glyphicon-ok form-control-feedback text-success" aria-hidden="true" ng-if="$ctrl.key.found" title="Flag trouvé à {{ $ctrl.key.found | date:'mediumTime'}}"></span>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
});
|
||||||
|
|
||||||
angular.module("FICApp")
|
angular.module("FICApp")
|
||||||
.controller("CountdownController", function($scope, $rootScope, $interval) {
|
.controller("CountdownController", function($scope, $rootScope, $interval) {
|
||||||
var time;
|
var time;
|
||||||
|
Loading…
Reference in New Issue
Block a user