frontend: add players possibility to report problems with exercices

This commit is contained in:
nemunaire 2020-01-20 15:56:02 +01:00
commit 9186bbc229
13 changed files with 206 additions and 0 deletions

View file

@ -57,6 +57,14 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
controller: "MyTeamController",
templateUrl: "views/team-edit.html"
})
.when("/issue", {
controller: "IssueController",
templateUrl: "views/issue.html"
})
.when("/issue/:eid", {
controller: "IssueController",
templateUrl: "views/issue.html"
})
.when("/rank", {
controller: "RankController",
templateUrl: "views/rank.html"
@ -636,6 +644,42 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
});
}
})
.controller("IssueController", function($scope, $http, $rootScope, $routeParams) {
$rootScope.current_tag = undefined;
$rootScope.current_exercice = $routeParams.eid;
$scope.issue = {
id_exercice: parseInt($routeParams.eid, 10),
subject: "",
description: "",
}
$scope.isubmit = function() {
$rootScope.sberr = "";
if ($scope.issue.subject.length < 3) {
$rootScope.messageClass = {"text-danger": true};
$rootScope.sberr = "L'object de votre rapport d'anomalie est trop court !";
return false;
}
$http({
url: "submit/issue",
method: "POST",
data: $scope.issue
}).then(function(response) {
$rootScope.messageClass = {"text-success": true};
$rootScope.message = response.data.errmsg;
$scope.issue.subject = "";
$scope.issue.description = "";
}, function(response) {
$rootScope.messageClass = {"text-danger": true};
$rootScope.message = response.data.errmsg;
if (response.status != 402) {
$rootScope.sberr = "Une erreur est survenue lors de l'envoi. Veuillez réessayer dans quelques instants.";
}
});
};
})
.controller("MyTeamController", function($scope, $http, $rootScope, $timeout, $location) {
$rootScope.current_theme = 0;
$rootScope.current_exercice = 0;