Add progress stats

This commit is contained in:
nemunaire 2016-01-24 15:22:53 +01:00
parent 6863891ba2
commit 257a9977ea
2 changed files with 33 additions and 22 deletions

View File

@ -54,6 +54,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
$rootScope.time.end = false; $rootScope.time.end = false;
$rootScope.time.expired = false; $rootScope.time.expired = false;
} }
$rootScope.time.duration = time.du;
$rootScope.time.remaining = remain; $rootScope.time.remaining = remain;
$rootScope.time.hours = Math.floor(remain / 3600); $rootScope.time.hours = Math.floor(remain / 3600);
$rootScope.time.minutes = Math.floor((remain % 3600) / 60); $rootScope.time.minutes = Math.floor((remain % 3600) / 60);
@ -116,8 +117,14 @@ angular.module("FICApp")
}); });
$http.get("/themes.json").success(function(themes) { $http.get("/themes.json").success(function(themes) {
$scope.themes = themes; $scope.themes = themes;
$scope.max_gain = 0;
angular.forEach(themes, function(theme, key) { angular.forEach(themes, function(theme, key) {
this[key].exercice_count = Object.keys(theme.exercices).length; this[key].exercice_count = Object.keys(theme.exercices).length;
this[key].gain = 0;
angular.forEach(theme.exercices, function(ex, k) {
this.gain += ex.gain;
}, theme);
$scope.max_gain += theme.gain;
}, themes); }, themes);
actMenu(); actMenu();
}); });

View File

@ -30,42 +30,46 @@
</p> </p>
</div> </div>
<div class="panel panel-default" ng-show="(my.team_id && stats)"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">Progressions</h3> <h3 class="panel-title">Progression</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<strong>Vous</strong> <strong>Vous</strong>
<div class="progress progress-striped"> <div class="progress progress-striped">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60" <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60"
aria-valuemin="0" aria-valuemax="100" style="width: 18%;"> aria-valuemin="0" aria-valuemax="100" style="width: {{ my.score * 100 / max_gain }}%;">
<span class="sr-only">18% Complete</span> <span class="sr-only">{{ my.score * 100 / max_gain }}% Complete</span>
</div>
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="60"
aria-valuemin="0" aria-valuemax="100" style="width: 18%;">
<span class="sr-only">18% Complete</span>
</div> </div>
</div> </div>
<strong>Le temps</strong> <strong>Le temps </strong>
<div class="progress"> <div class="progress">
<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60" <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="60"
aria-valuemin="0" aria-valuemax="100" style="width: 50%;"> aria-valuemin="0" aria-valuemax="100" style="width: {{ 100 - time.remaining / time.duration * 100 }}%;">
<span class="sr-only">90 minutes restantes</span> <span class="sr-only">{{ time.remaining }} secondes restantes</span>
</div> </div>
</div> </div>
<strong>La meilleure équipe</strong> <div ng-show="rank.length && rank[0].id != my.team_id">
<div class="progress"> <strong>La meilleure équipe ({{ rank[0].name }})</strong>
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60" <div class="progress">
aria-valuemin="0" aria-valuemax="100" style="width: 28%;"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60"
<span class="sr-only">18% Complete</span> aria-valuemin="0" aria-valuemax="100" style="width: {{ rank[0].score * 100 / max_gain }}%;">
</div> <span class="sr-only">{{ rank[0].score * 100 / max_gain }}% Complete</span>
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="60" </div>
aria-valuemin="0" aria-valuemax="100" style="width: 18%;"> </div>
<span class="sr-only">18% Complete</span> </div>
</div>
<div ng-show="rank[0].id == my.team_id && rank.length > 1">
<strong>La seconde équipe ({{ rank[1].name }})</strong>
<div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60"
aria-valuemin="0" aria-valuemax="100" style="width: {{ rank[1].score * 100 / max_gain }}%;">
<span class="sr-only">{{ rank[1].score * 100 / max_gain }}% Complete</span>
</div>
</div>
</div> </div>
</div> </div>