List not yet corrected users
continuous-integration/drone/push Build is passing Details

This commit is contained in:
nemunaire 2020-11-30 10:31:38 +01:00
parent 0fa59dd858
commit dabc01ea11
2 changed files with 61 additions and 7 deletions

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("UserResponse", function($resource) {
.factory("UserResponses", function($resource) {
return $resource("/api/users/:userId/surveys/:surveyId/responses/:respId", { userId: '@id', surveyId: '@id', respId: '@id' })
})
.factory("Grades", function($resource) {
@ -333,8 +333,25 @@ angular.module("AtsebaytApp")
})
})
.controller("ResponsesController", function($scope, AllResponses) {
.controller("ResponsesController", function($scope, AllResponses, $rootScope, $location) {
$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) {
@ -388,7 +405,11 @@ angular.module("AtsebaytApp")
.controller("UserController", function($scope, $routeParams, $rootScope, User) {
$rootScope.qactive = false;
$rootScope.uactive = true;
$scope.user = User.get({ userId: $routeParams.userId})
if ($scope.id_user) {
$scope.user = User.get({ userId: $scope.id_user})
} else {
$scope.user = User.get({ userId: $routeParams.userId})
}
})
.controller("QuestionController", function($scope, Survey, SurveyQuest, AllResponses, UserResponses, CorrectionTemplate, $http, $routeParams) {
@ -522,9 +543,17 @@ angular.module("AtsebaytApp")
}
})
.controller("QuestionsController", function($scope, SurveyQuest, MyResponse, UserResponse, $http, $routeParams, $location) {
.controller("QuestionsController", function($scope, SurveyQuest, MyResponse, UserResponses, $http, $routeParams, $location, $rootScope) {
$rootScope.usersResponses = null;
$scope.questions = SurveyQuest.query({ surveyId: $scope.survey.id });
$scope.questions.$promise.then(function (questions) {$scope.showSubmit = true;}, function (response) {
$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.addToast({
variant: "danger",
title: $scope.survey.title,
@ -535,7 +564,7 @@ angular.module("AtsebaytApp")
if ($routeParams.userId == null) {
$scope.myresponses = MyResponse.query({ surveyId: $scope.survey.id });
} else {
$scope.myresponses = UserResponse.query({ userId: $routeParams.userId, surveyId: $scope.survey.id });
$scope.myresponses = UserResponses.query({ userId: $routeParams.userId, surveyId: $scope.survey.id });
}
$scope.myresponses.$promise.then(function (responses) {
$scope.questions.$promise.then(function (questions) {

View File

@ -7,7 +7,9 @@
</small>
</h2>
<table class="table table-hover table-striped mb-5" ng-controller="QuestionsController" ng-if="survey.id" ng-cloak>
<div ng-controller="QuestionsController" ng-if="survey.id" ng-cloak>
<table class="table table-hover table-striped mb-5">
<thead>
<tr>
<th>Question</th>
@ -28,3 +30,26 @@
</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>