From 077cecdf1a704c872e26dd3fab8dc8850f3a8355 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Fri, 9 Dec 2016 11:55:58 +0100 Subject: [PATCH] frontend: interface can open hints --- frontend/static/js/app.js | 31 ++++++++++++++++++++++++++++++- frontend/static/views/theme.html | 4 ++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/frontend/static/js/app.js b/frontend/static/js/app.js index c0b83083..7f381fe4 100644 --- a/frontend/static/js/app.js +++ b/frontend/static/js/app.js @@ -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 = []; diff --git a/frontend/static/views/theme.html b/frontend/static/views/theme.html index 9b33a031..ebaf8c8c 100644 --- a/frontend/static/views/theme.html +++ b/frontend/static/views/theme.html @@ -32,8 +32,8 @@