diff --git a/grades.go b/grades.go index b79c7a4..b6d762c 100644 --- a/grades.go +++ b/grades.go @@ -28,15 +28,6 @@ func init() { })(ps, body) })(uauth, ps, body) }, loggedUser)) - router.GET("/api/surveys/:sid/grades", apiAuthHandler(surveyAuthHandler(func(s Survey, uauth *User, _ []byte) HTTPResponse { - if scores, err := s.GetGrades(); err != nil { - return APIErrorResponse{err: err} - } else if scores == nil { - return APIResponse{"N/A"} - } else { - return APIResponse{scores} - } - }), adminRestricted)) router.GET("/api/grades", apiAuthHandler(func(uauth *User, ps httprouter.Params, body []byte) HTTPResponse { if uauth != nil && uauth.IsAdmin { if score, err := GetAllGrades(); err != nil { diff --git a/htdocs/js/atsebayt.js b/htdocs/js/atsebayt.js index def21a9..8810178 100644 --- a/htdocs/js/atsebayt.js +++ b/htdocs/js/atsebayt.js @@ -58,7 +58,7 @@ angular.module("AtsebaytApp") .factory("MyResponse", function($resource) { return $resource("/api/surveys/:surveyId/responses/:respId", { surveyId: '@id', respId: '@id' }) }) - .factory("UserResponses", function($resource) { + .factory("UserResponse", function($resource) { return $resource("/api/users/:userId/surveys/:surveyId/responses/:respId", { userId: '@id', surveyId: '@id', respId: '@id' }) }) .factory("Grades", function($resource) { @@ -333,25 +333,8 @@ angular.module("AtsebaytApp") }) }) - .controller("ResponsesController", function($scope, AllResponses, $rootScope, $location) { + .controller("ResponsesController", function($scope, AllResponses) { $scope.responses = AllResponses.query({ surveyId: $scope.survey.id, questId: $scope.question.id }); - $scope.responses.$promise.then(function (responses) { - if (!$rootScope.usersResponses) { - $rootScope.usersResponses = {} - } - responses.forEach(function (response) { - if (!response.time_scored) { - if ($rootScope.usersResponses[response.id_user] === undefined) { - $rootScope.usersResponses[response.id_user] = [] - } - $rootScope.usersResponses[response.id_user].push(response.id_question) - } - }); - }) - - $rootScope.showUserSurvey = function () { - $location.url("users/" + this.id_user + "/surveys/" + this.survey.id); - } }) .controller("ScoreController", function($scope, SurveyScore) { @@ -405,11 +388,7 @@ angular.module("AtsebaytApp") .controller("UserController", function($scope, $routeParams, $rootScope, User) { $rootScope.qactive = false; $rootScope.uactive = true; - if ($scope.id_user) { - $scope.user = User.get({ userId: $scope.id_user}) - } else { - $scope.user = User.get({ userId: $routeParams.userId}) - } + $scope.user = User.get({ userId: $routeParams.userId}) }) .controller("QuestionController", function($scope, Survey, SurveyQuest, AllResponses, UserResponses, CorrectionTemplate, $http, $routeParams) { @@ -543,17 +522,9 @@ angular.module("AtsebaytApp") } }) - .controller("QuestionsController", function($scope, SurveyQuest, MyResponse, UserResponses, $http, $routeParams, $location, $rootScope) { - $rootScope.usersResponses = null; + .controller("QuestionsController", function($scope, SurveyQuest, MyResponse, UserResponse, $http, $routeParams, $location) { $scope.questions = SurveyQuest.query({ surveyId: $scope.survey.id }); - $scope.questions.$promise.then(function (questions) { - $scope.showSubmit = true; - var mapQuestions = {}; - questions.forEach(function (question) { - mapQuestions[question.id] = question; - }); - $scope.mapQuestions = mapQuestions; - }, function (response) { + $scope.questions.$promise.then(function (questions) {$scope.showSubmit = true;}, function (response) { $scope.addToast({ variant: "danger", title: $scope.survey.title, @@ -564,7 +535,7 @@ angular.module("AtsebaytApp") if ($routeParams.userId == null) { $scope.myresponses = MyResponse.query({ surveyId: $scope.survey.id }); } else { - $scope.myresponses = UserResponses.query({ userId: $routeParams.userId, surveyId: $scope.survey.id }); + $scope.myresponses = UserResponse.query({ userId: $routeParams.userId, surveyId: $scope.survey.id }); } $scope.myresponses.$promise.then(function (responses) { $scope.questions.$promise.then(function (questions) { diff --git a/htdocs/views/responses.html b/htdocs/views/responses.html index 894b559..d03cfbe 100644 --- a/htdocs/views/responses.html +++ b/htdocs/views/responses.html @@ -7,9 +7,7 @@ -
- - +
@@ -30,26 +28,3 @@
Question
- -
-

Restant à corriger

- - - - - - - - - - - - - -
ÉtudiantQuestions
{{ user.login }} -
- {{ mapQuestions[question].title }} -
-
-
-