Compare commits

..

No commits in common. "dabc01ea113d8ae29cd311e55fffb64b1cade7ab" and "8b58bf57eff7e53e5e91c6a44d4a6906bbec9816" have entirely different histories.

3 changed files with 7 additions and 70 deletions

View file

@ -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 {

View file

@ -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) {

View file

@ -7,9 +7,7 @@
</small>
</h2>
<div ng-controller="QuestionsController" ng-if="survey.id" ng-cloak>
<table class="table table-hover table-striped mb-5">
<table class="table table-hover table-striped mb-5" ng-controller="QuestionsController" ng-if="survey.id" ng-cloak>
<thead>
<tr>
<th>Question</th>
@ -30,26 +28,3 @@
</tr>
</tbody>
</table>
<div ng-if="usersResponses">
<h3>Restant à corriger</h3>
<table class="table table-hover table-striped mb-5">
<thead>
<tr>
<th>Étudiant</th>
<th>Questions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(id_user,questions) in usersResponses" ng-click="showUserSurvey()">
<td ng-controller="UserController">{{ user.login }}</td>
<td>
<div ng-repeat="question in questions">
{{ mapQuestions[question].title }}
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>