Partial resolution of exercices

This commit is contained in:
nemunaire 2016-12-04 19:08:46 +01:00
commit 3cd6cd959d
8 changed files with 46 additions and 24 deletions

View file

@ -197,7 +197,7 @@ angular.module("FICApp")
})
.controller("SubmissionController", function($scope, $http, $rootScope, $timeout) {
$scope.flags = []
$scope.flags = [];
$rootScope.sberr = "";
var waitMy = function() {
@ -205,12 +205,16 @@ angular.module("FICApp")
$timeout.cancel($scope.cbs);
$scope.cbs = $timeout(waitMy, 420);
} else {
$scope.flags = [];
angular.forEach($scope.my.exercices[$rootScope.current_exercice].keys, function(key,kid) {
this.push({
var o = {
id: kid,
name: key,
value: ""
});
};
if ($scope.my.exercices[$rootScope.current_exercice].solved_matrix != null)
o.found = $scope.my.exercices[$rootScope.current_exercice].solved_matrix[kid];
this.push(o);
}, $scope.flags);
}
}
@ -219,23 +223,10 @@ angular.module("FICApp")
$scope.ssubmit = function() {
var flgs = {}
var filled = true;
angular.forEach($scope.flags, function(flag,kid) {
flgs[flag.name] = flag.value;
filled = filled && flag.value.length > 0;
});
if (!filled) {
$rootScope.messageClass = {"text-danger": true};
$rootScope.sberr = "Tous les champs sont obligatoires.";
$timeout(function() {
if ($rootScope.sberr == "Tous les champs sont obligatoires.") {
$rootScope.sberr = "";
}
}, 2345);
return;
}
$http({
url: "/submit/" + $rootScope.current_exercice,
method: "POST",

View file

@ -52,9 +52,10 @@
</ul>
<div class="panel-body" ng-show="!my.exercices[current_exercice].submitted || sberr">
<form ng-controller="SubmissionController" ng-submit="ssubmit()">
<div class="form-group" ng-repeat="key in flags">
<div class="form-group" ng-repeat="key in flags" ng-class="{'has-success': key.found, 'has-feedback': key.found}">
<label for="sol_{{ key.id }}">{{ key.name }} :</label>
<input type="text" class="form-control" id="sol_{{ key.id }}" name="sol_{{ index }}" ng-model="key.value">
<input type="text" class="form-control" id="sol_{{ key.id }}" name="sol_{{ index }}" ng-model="key.value" ng-disabled="key.found">
<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true" ng-show="key.found"></span>
</div>
<div class="form-group text-right">
<button type="submit" class="btn btn-danger" id="sbmt">Soumettre</button>