Coefficients transit and display on UI
This commit is contained in:
parent
974d474097
commit
a25e2edfd7
7 changed files with 64 additions and 20 deletions
|
@ -89,16 +89,25 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
time.he = (new Date()).getTime();
|
||||
sessionStorage.userService = angular.toJson(time);
|
||||
});
|
||||
$http.get("/settings.json").success(function(settings) {
|
||||
$scope.settings = settings;
|
||||
});
|
||||
$http.get("/themes.json").success(function(themes) {
|
||||
$scope.themes = themes;
|
||||
$scope.max_gain = 0;
|
||||
$scope.max_solved = 0;
|
||||
angular.forEach(themes, function(theme, key) {
|
||||
this[key].exercice_count = Object.keys(theme.exercices).length;
|
||||
this[key].exercice_coeff_max = 0;
|
||||
this[key].gain = 0;
|
||||
this[key].solved = 0;
|
||||
angular.forEach(theme.exercices, function(ex, k) {
|
||||
this.gain += ex.gain;
|
||||
this.solved += ex.solved;
|
||||
this.exercice_coeff_max = Math.max(this.exercice_coeff_max, ex.curcoeff);
|
||||
}, theme);
|
||||
$scope.max_gain += theme.gain;
|
||||
$scope.max_solved = Math.max($scope.max_solved, theme.solved);
|
||||
}, themes);
|
||||
actMenu();
|
||||
});
|
||||
|
@ -116,6 +125,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$http.get("/my.json").success(function(my) {
|
||||
$scope.my = my;
|
||||
angular.forEach($scope.my.exercices, function(exercice, eid) {
|
||||
exercice.solved = exercice.solved_rank > 0;
|
||||
if (exercice.video_uri) {
|
||||
exercice.video_uri = $sce.trustAsResourceUrl(exercice.video_uri);
|
||||
}
|
||||
|
|
|
@ -69,3 +69,15 @@ angular.module("FICApp")
|
|||
return (Math.round(res * 100) / 100) + " " + units[unit];
|
||||
}
|
||||
})
|
||||
|
||||
.filter("coeff", function() {
|
||||
return function(input) {
|
||||
if (input > 1) {
|
||||
return "+" + Math.floor((input - 1) * 100) + " %"
|
||||
} else if (input < 1) {
|
||||
return "-" + Math.floor((1 - input) * 100) + " %"
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<ul class="nav nav-tabs nav-justified">
|
||||
<li ng-repeat="(k,exercice) in themes[current_theme].exercices" ng-class="{active: k == current_exercice, disabled: !my.exercices[k]}"><a ng-show="(!my.exercices[k])">{{ exercice.title }}</a><a ng-href="/{{ current_theme }}/{{ k }}" ng-show="(my.exercices[k])">{{ exercice.title }} <span class="glyphicon glyphicon-ok" aria-hidden="true" ng-show="(my.team_id && my.exercices[k].solved)"></span></a></li>
|
||||
<li ng-repeat="(k,exercice) in themes[current_theme].exercices" ng-class="{active: k == current_exercice, disabled: !my.exercices[k]}"><a ng-show="(!my.exercices[k])">{{ exercice.title }}</a><a ng-href="/{{ current_theme }}/{{ k }}" ng-show="(my.exercices[k])">{{ exercice.title }} <span class="glyphicon glyphicon-gift" aria-hidden="true" ng-show="themes[current_theme].exercices[k].curcoeff > 1.0"></span> <span class="glyphicon glyphicon-ok" aria-hidden="true" ng-show="(my.team_id && my.exercices[k].solved)"></span></a></li>
|
||||
</ul>
|
||||
|
||||
<div class="alert alert-warning" style="margin-top:15px;" ng-show="!(my.exercices[current_exercice])">
|
||||
|
@ -8,7 +8,7 @@
|
|||
<div style="margin-top: 15px" class="well well-lg" ng-show="(my.exercices[current_exercice])">
|
||||
<p ng-bind-html="my.exercices[current_exercice].statement"></p>
|
||||
<ul>
|
||||
<li><strong>Gain :</strong> <ng-pluralize count="themes[current_theme].exercices[current_exercice].gain" when="{'one': '{} point', 'other': '{} points'}"></ng-pluralize> <em ng-show="themes[current_theme].happy">+10% happy hour</em> <em ng-show="themes[current_theme].exercices[current_exercice].solved < 1">+15% first blood</em></li>
|
||||
<li><strong>Gain :</strong> <ng-pluralize count="themes[current_theme].exercices[current_exercice].gain" when="{'one': '{} point', 'other': '{} points'}"></ng-pluralize> <em ng-show="themes[current_theme].exercices[current_exercice].curcoeff != 1.0">{{ themes[current_theme].exercices[current_exercice].curcoeff | coeff }} happy hour</em> <em ng-show="themes[current_theme].exercices[current_exercice].solved < 1">{{ 1 + settings.firstBlood | coeff }} first blood</em></li>
|
||||
<li><strong>Résolu par :</strong> <ng-pluralize count="themes[current_theme].exercices[current_exercice].solved" when="{'0': 'aucune équipe', 'one': '{} équipe', 'other': '{} équipes'}"></ng-pluralize>.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -46,8 +46,8 @@
|
|||
<div class="panel-heading">
|
||||
<div class="panel-title"><span class="glyphicon glyphicon-flag" aria-hidden="true"></span> Soumettre une solution</div>
|
||||
</div>
|
||||
<ul class="list-group" ng-show="(my.exercices[current_exercice].solved_number || my.exercices[current_exercice].submitted || sberr)">
|
||||
<li class="list-group-item text-warning" ng-show="my.exercices[current_exercice].solved_number"><ng-pluralize count="my.exercices[current_exercice].solved_number" when="{'one': '{} tentative effectuée', 'other': '{} tentatives effectuées'}"></ng-pluralize>. Dernière solution envoyée à {{ my.exercices[current_exercice].solved_time | date:"mediumTime" }}.</li>
|
||||
<ul class="list-group" ng-show="(my.exercices[current_exercice].tries || my.exercices[current_exercice].submitted || sberr)">
|
||||
<li class="list-group-item text-warning" ng-show="my.exercices[current_exercice].tries"><ng-pluralize count="my.exercices[current_exercice].tries" when="{'one': '{} tentative effectuée', 'other': '{} tentatives effectuées'}"></ng-pluralize>. Dernière solution envoyée à {{ my.exercices[current_exercice].solved_time | date:"mediumTime" }}.</li>
|
||||
<li class="list-group-item" ng-class="messageClass" ng-show="my.exercices[current_exercice].submitted || sberr"><strong ng-show="!sberr">Votre solution a bien été envoyée !</strong><strong ng-show="sberr">{{ sberr }}</strong> {{ message }}</li>
|
||||
</ul>
|
||||
<div class="panel-body" ng-show="!my.exercices[current_exercice].submitted || sberr">
|
||||
|
@ -69,7 +69,7 @@
|
|||
<div class="panel-title"><span class="glyphicon glyphicon-flag" aria-hidden="true"></span> Challenge réussi !</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
Vous êtes la {{ my.exercices[current_exercice].solved_number }}<sup><ng-pluralize count="my.exercices[current_exercice].solved_number" when="{'one': 're', 'other': 'e'}"></ng-pluralize></sup> équipe à avoir résolu ce challenge à {{ my.exercices[current_exercice].solved_time | date:"mediumTime" }}. Vous avez marqué <ng-pluralize count="themes[current_theme].exercices[current_exercice].gain" when="{'one': '{} point', 'other': '{} points'}"></ng-pluralize> !
|
||||
Vous êtes la {{ my.exercices[current_exercice].solved_rank }}<sup><ng-pluralize count="my.exercices[current_exercice].solved_rank" when="{'one': 're', 'other': 'e'}"></ng-pluralize></sup> équipe à avoir résolu ce challenge à {{ my.exercices[current_exercice].solved_time | date:"mediumTime" }}. Vous avez marqué <ng-pluralize count="my.exercices[current_exercice].gain" when="{'one': '{} point', 'other': '{} points'}"></ng-pluralize> !
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Reference in a new issue