frontend: interface can open hints

This commit is contained in:
nemunaire 2016-12-09 11:55:58 +01:00 committed by Pierre-Olivier Mercier
parent 573d9650d0
commit 077cecdf1a
2 changed files with 32 additions and 3 deletions

View file

@ -175,7 +175,7 @@ angular.module("FICApp")
}
$rootScope.refresh();
})
.controller("ExerciceController", function($scope, $routeParams, $http, $rootScope) {
.controller("ExerciceController", function($scope, $routeParams, $http, $rootScope, $timeout) {
$rootScope.current_theme = $routeParams.theme;
if ($routeParams.exercice) {
@ -198,6 +198,35 @@ angular.module("FICApp")
}
}
$scope.hsubmit = function(hint) {
hint.submitted = true;
$http({
url: "/openhint/" + $rootScope.current_exercice,
method: "POST",
data: {
id: hint.id
}
}).success(function(data, status, header, config) {
var checkDiffHint = function() {
$http.get("/my.json").success(function(my) {
angular.forEach(my.exercices[$rootScope.current_exercice].hints, function(h,hid){
if (hint.id == h.id) {
if (hint.content != h.content) {
$rootScope.refresh();
} else {
$timeout.cancel($scope.cbh);
$scope.cbh = $timeout(checkDiffHint, 750);
}
}
});
});
};
checkDiffHint();
}).error(function(data, status, header, config) {
hint.submitted = false;
console.error(data.errmsg);
});
};
})
.controller("SubmissionController", function($scope, $http, $rootScope, $timeout) {
$scope.flags = [];