admin: add exercice history.json

This commit is contained in:
nemunaire 2019-02-03 22:30:29 +01:00
commit b73eaa8b3f
4 changed files with 182 additions and 0 deletions

View file

@ -228,6 +228,9 @@ angular.module("FICApp")
update: {method: 'PUT'}
})
})
.factory("ExerciceHistory", function($resource) {
return $resource("/api/exercices/:exerciceId/history.json", { exerciceId: '@id' })
})
.factory("ExerciceFile", function($resource) {
return $resource("/api/exercices/:exerciceId/files/:fileId", { exerciceId: '@idExercice', fileId: '@id' }, {
update: {method: 'PUT'}
@ -1272,6 +1275,22 @@ angular.module("FICApp")
}
})
.controller("ExerciceHistoryController", function($scope, ExerciceHistory, $routeParams, $http, $rootScope) {
$scope.history = ExerciceHistory.query({ exerciceId: $routeParams.exerciceId });
$scope.delHistory = function(row) {
$http({
url: "/api/exercices/" + $routeParams.exerciceId + "/history.json",
method: "DELETE",
data: row
}).then(function(response) {
$rootScope.staticFilesNeedUpdate++;
$scope.history = ExerciceHistory.query({ exerciceId: $routeParams.exerciceId });
}, function(response) {
$rootScope.newBox('danger', 'An error occurs when removing history item: ', response.data.errmsg);
});
}
})
.controller("ExerciceFilesController", function($scope, ExerciceFile, $routeParams, $rootScope, $http) {
$scope.files = ExerciceFile.query({ exerciceId: $routeParams.exerciceId });

View file

@ -221,6 +221,35 @@
</div>
</div>
<div class="mt-2" style="overflow-y: scroll; height: 450px">
<h3>Historique</h3>
<table ng-controller="ExerciceHistoryController" class="table table-hover table-striped table-bordered bg-primary text-light">
<tbody>
<tr ng-repeat="row in history" ng-class="{'bg-ffound': row.kind == 'flag_found', 'bg-mfound': row.kind == 'mcq_found', 'bg-wchoices': row.kind == 'wchoices', 'bg-success': row.kind == 'solved', 'bg-info': row.kind == 'hint', 'bg-warning': row.kind == 'tries'}">
<td>
<nobr title="{{ row.time }}">{{ row.time | date:"mediumTime" }}</nobr><br>{{ row.kind }}
</td>
<td>
<span ng-if="row.team_id">
<a href="teams/{{ row.team_id }}">{{ row.team_name }}</a>
</span>
<span ng-if="row.secondary_title">
:
<a href="exercices/{{ row.primary }}#key-{{ row.secondary }}" ng-if="row.kind == 'flag_found' || row.kind == 'wchoices'">{{ row.secondary_title }}</a>
<a href="exercices/{{ row.primary }}#quizz-{{ row.secondary }}" ng-if="row.kind == 'mcq_found'">{{ row.secondary_title }}</a>
<a href="exercices/{{ row.primary }}#hint-{{ row.secondary }}" ng-if="row.kind == 'hint'">{{ row.secondary_title }}</a>
</span>
<span ng-if="!row.secondary_title && row.secondary && row.kind == 'solved'">(coeff x{{ row.secondary }})</span>
<span ng-if="!row.secondary_title && row.secondary && row.kind != 'solved'">: {{ row.secondary }}</span>
</td>
<td style="vertical-align: middle; padding: 0; background-color: {{ row.team_color }}">
<button type="button" ng-click="delHistory(row)" class="float-right btn btn-sm btn-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>