admin: general statistics page

This commit is contained in:
nemunaire 2017-12-26 23:57:16 +01:00
parent ea3f3b709d
commit bc135d00c5
4 changed files with 38 additions and 2 deletions

View File

@ -33,6 +33,10 @@ angular.module("FICApp", ["ngRoute", "ngResource", "ngSanitize"])
controller: "TeamsListController",
templateUrl: "views/team-print.html"
})
.when("/teams/export", {
controller: "TeamsListController",
templateUrl: "views/team-export.html"
})
.when("/teams/:teamId", {
controller: "TeamController",
templateUrl: "views/team-edit.html"
@ -152,6 +156,13 @@ String.prototype.capitalize = function() {
}
angular.module("FICApp")
.filter("countHints", function() {
return function(input) {
if (input == undefined)
return 0;
return input.reduce(function(sum, n){ return sum + (n.content || n.file) ? 1 : 0; }, 0);
}
})
.filter("capitalize", function() {
return function(input) {
if (input != undefined)
@ -832,6 +843,8 @@ angular.module("FICApp")
}
})
.controller("TeamController", function($scope, $rootScope, $location, Team, TeamMember, $routeParams, $http) {
if ($scope.team && $scope.team.id)
$routeParams.teamId = $scope.team.id;
$scope.team = Team.get({ teamId: $routeParams.teamId });
$scope.fields = ["name", "color"];
@ -885,7 +898,7 @@ angular.module("FICApp")
$scope.deleteTeam = function() {
backName = this.team.name;
this.team.$remove(function() { $rootScope.newBox('success', 'Team ' + backName + ' successfully removed.'); $location.url("/teams/"); },
function(response) { console.log($rootScope.newBox); $rootScope.newBox('danger', 'An error occurs during suppression of the team:', response.data); });
function(response) { $rootScope.newBox('danger', 'An error occurs during suppression of the team:', response.data); });
}
$scope.showStats = function() {
$location.url("/teams/" + $scope.team.id + "/stats");

View File

@ -0,0 +1,22 @@
<div ng-repeat="team in teams" ng-click="show(team.id)" ng-controller="TeamController">
<div ng-controller="TeamExercicesController">
<div ng-if="teams[my.team_id].rank">
<h2>{{ team.name }} <small>{{ teams[my.team_id].rank }}/{{ nb_teams }} &ndash; <ng-pluralize count="my.score" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize></small></h2>
<div class="row">
<div class="col-md" ng-repeat="(tid,theme) in themes">
<h4 ng-bind="theme.name"></h4>
<ul class="list-unstyled">
<li ng-repeat="(eid,exercice) in theme.exercices" ng-if="my.exercices[eid] && (my.exercices[eid].tries || (my.exercices[eid].hints | countHints))">
<nobr ng-class="{'text-info': !my.exercices[eid].tries && !my.exercices[eid].solved_rank, 'text-warning': my.exercices[eid].tries && !my.exercices[eid].solved_rank, 'text-success': my.exercices[eid].solved_rank}">
<a href="/{{ my.exercices[eid].theme_id }}/{{ eid }}" target="_blank" title="{{ my.exercices[eid].statement }}">{{ exercice.title }}</a>
(<span ng-if="my.exercices[eid].solved_rank" title="{{ my.exercices[eid].solved_time | date:'mediumDate' }} à {{ my.exercices[eid].solved_time | date:'mediumTime' }}">{{ my.exercices[eid].solved_rank }}<sup>e</sup> &ndash; </span><em><ng-pluralize count="my.exercices[eid].tries" when="{'one': '{}&nbsp;tentative', 'other': '{}&nbsp;tentatives'}"></ng-pluralize><span ng-if="my.exercices[eid].hints | countHints"><span ng-if="my.exercices[eid].tries"> &ndash; </span>{{ my.exercices[eid].hints | countHints }} indices</span></em>)
</nobr>
</li>
</ul>
</div>
</div>
<hr>
</div>
</div>
</div>

View File

@ -2,6 +2,7 @@
&Eacute;quipes
<button ng-click="show('new')" class="float-right btn btn-sm btn-primary"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Ajouter une équipe</button>
<button ng-click="show('print')" class="float-right btn btn-sm btn-secondary" style="margin-right: 10px;"><span class="glyphicon glyphicon-print" aria-hidden="true"></span> Imprimer les équipes</button>
<button ng-click="show('export')" class="float-right btn btn-sm btn-secondary" style="margin-right: 10px;"><span class="glyphicon glyphicon-export" aria-hidden="true"></span> Statistiques générales</button>
</h2>
<p><input type="search" class="form-control" placeholder="Search" ng-model="query"></p>

View File

@ -35,7 +35,7 @@
<dl>
<div style="float: left;padding: 0 5px; margin: 5px; border: 1px solid #ccc; border-radius: 3px; min-width: 5vw" ng-repeat="(tid,theme) in themes" class="text-center">
<dt>{{ theme.name }}</dt>
<dt ng-bind="theme.name"></dt>
<dd>
<ul class="list-unstyled">
<li ng-repeat="(eid,exercice) in theme.exercices" ng-if="my.exercices[eid] && my.exercices[eid].solved_rank"><a href="/{{ my.exercices[eid].theme_id }}/{{ eid }}" target="_blank"><abbr title="{{ my.exercices[eid].statement }}">{{ exercice.title }}</abbr></a> (<abbr title="{{ my.exercices[eid].solved_time | date:'mediumDate' }} à {{ my.exercices[eid].solved_time | date:'mediumTime' }}">{{ my.exercices[eid].solved_rank }}<sup>e</sup></abbr>)</li>