dashboard: Fix last challenge due to hashtable change

This commit is contained in:
nemunaire 2023-04-05 17:10:53 +02:00
parent cc0e26ef1f
commit 0d596ccb8c
2 changed files with 17 additions and 12 deletions

View File

@ -379,14 +379,14 @@
<div class="card niceborder bg-dark" ng-if="s.type == 'exercice' && !s.params.hide">
<div class="card-img-top theme-card" style="background-image: url('{{themes[my.exercices[s.params.exercice].theme_id].image}}')"></div>
<div class="card-body text-light">
<h3 style="font-size: 1.0rem; text-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">Défi <em>{{ themes[my.exercices[s.params.exercice].theme_id].exercices[s.params.exercice].title }}</em> du thème <em>{{ themes[my.exercices[s.params.exercice].theme_id].name }}</em></h3>
<h3 style="font-size: 1.0rem; text-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">Défi <em>{{ exercices[s.params.exercice].title }}</em> du thème <em>{{ themes[my.exercices[s.params.exercice].theme_id].name }}</em></h3>
<p ng-bind-html="my.exercices[s.params.exercice].overview"></p>
<ul class="list-inline text-muted mr-2 ml-2 mb-1" style="font-size: 0.9rem">
<li><ng-pluralize count="themes[my.exercices[s.params.exercice].theme_id].exercices[s.params.exercice].gain" when="{'0': 'aucun point', 'one': '{} point', 'other': '{} points'}"></ng-pluralize></li>
<li><ng-pluralize count="exercices[s.params.exercice].gain" when="{'0': 'aucun point', 'one': '{} point', 'other': '{} points'}"></ng-pluralize></li>
<li ng-if="my.exercices[s.params.exercice].files"><ng-pluralize count="my.exercices[s.params.exercice].files.length" when="{'0': 'Aucun fichier', 'one': '{} fichier', 'other': '{} fichiers'}"></ng-pluralize></li>
<li ng-if="my.exercices[s.params.exercice].hints.length"><ng-pluralize count="my.exercices[s.params.exercice].hints.length" when="{'0': 'Aucun indice disponible', 'one': '{} indice disponible', 'other': '{} indices disponibles'}"></ng-pluralize></li>
<li>Tenté par <ng-pluralize count="themes[my.exercices[s.params.exercice].theme_id].exercices[s.params.exercice].tried" when="{'0': 'aucune équipe', 'one': '{} équipe', 'other': '{} équipes'}"></ng-pluralize></li>
<li ng-if="my.exercices[s.params.exercice].tries">Résolu par <ng-pluralize count="themes[my.exercices[s.params.exercice].theme_id].exercices[s.params.exercice].solved" when="{'0': 'aucune équipe', 'one': '{} équipe', 'other': '{} équipes'}"></ng-pluralize></li>
<li>Tenté par <ng-pluralize count="exercices[s.params.exercice].tried" when="{'0': 'aucune équipe', 'one': '{} équipe', 'other': '{} équipes'}"></ng-pluralize></li>
<li ng-if="my.exercices[s.params.exercice].tries">Résolu par <ng-pluralize count="exercices[s.params.exercice].solved" when="{'0': 'aucune équipe', 'one': '{} équipe', 'other': '{} équipes'}"></ng-pluralize></li>
</ul>
</div>
</div>
@ -399,14 +399,14 @@
</div>
<div class="card-img-top theme-card" style="background-image: url('{{themes[my.exercices[lastExercice].theme_id].image}}')"></div>
<div class="card-body text-light">
<h3 style="font-size: 1.0rem; text-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap"><em>{{ themes[my.exercices[lastExercice].theme_id].exercices[lastExercice].title }}</em> du thème <em>{{ themes[my.exercices[lastExercice].theme_id].name }}</em></h3>
<h3 style="font-size: 1.0rem; text-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap"><em>{{ exercices[lastExercice].title }}</em> du thème <em>{{ themes[my.exercices[lastExercice].theme_id].name }}</em></h3>
<p ng-bind-html="my.exercices[lastExercice].overview"></p>
<ul class="list-inline text-muted mr-2 ml-2 mb-1" style="font-size: 0.9rem">
<li><ng-pluralize count="themes[my.exercices[lastExercice].theme_id].exercices[lastExercice].gain" when="{'0': 'aucun point', 'one': '{} point', 'other': '{} points'}"></ng-pluralize></li>
<li><ng-pluralize count="exercices[lastExercice].gain" when="{'0': 'aucun point', 'one': '{} point', 'other': '{} points'}"></ng-pluralize></li>
<li ng-if="my.exercices[lastExercice].files"><ng-pluralize count="my.exercices[lastExercice].files.length" when="{'0': 'Aucun fichier', 'one': '{} fichier', 'other': '{} fichiers'}"></ng-pluralize></li>
<li ng-if="my.exercices[lastExercice].hints.length"><ng-pluralize count="my.exercices[lastExercice].hints.length" when="{'0': 'Aucun indice disponible', 'one': '{} indice disponible', 'other': '{} indices disponibles'}"></ng-pluralize></li>
<li>Tenté par <ng-pluralize count="themes[my.exercices[lastExercice].theme_id].exercices[lastExercice].tried" when="{'0': 'aucune équipe', 'one': '{} équipe', 'other': '{} équipes'}"></ng-pluralize></li>
<li ng-if="my.exercices[lastExercice].tries">Résolu par <ng-pluralize count="themes[my.exercices[lastExercice].theme_id].exercices[lastExercice].solved" when="{'0': 'aucune équipe', 'one': '{} équipe', 'other': '{} équipes'}"></ng-pluralize></li>
<li>Tenté par <ng-pluralize count="exercices[lastExercice].tried" when="{'0': 'aucune équipe', 'one': '{} équipe', 'other': '{} équipes'}"></ng-pluralize></li>
<li ng-if="my.exercices[lastExercice].tries">Résolu par <ng-pluralize count="exercices[lastExercice].solved" when="{'0': 'aucune équipe', 'one': '{} équipe', 'other': '{} équipes'}"></ng-pluralize></li>
</ul>
</div>
</div>

View File

@ -26,11 +26,13 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
var res = event.txt.match(/<strong>(\d+)<sup>e<\/sup><\/strong> défi ([^&]+)/);
if (res) {
for (var tid in $scope.themes) {
if ($scope.themes[tid].name == res[2]) {
lastExercice = Object.keys($scope.themes[tid].exercices)[parseInt(res[1])-1];
if ($scope.themes[tid].name == res[2]) {
for (var eid in $scope.themes[tid].exercices) {
lastExercice = $scope.themes[tid].exercices[parseInt(res[1])-1].id;
break;
}
}
}
}
}
}
event.time = Date.parse(event.time);
@ -132,7 +134,8 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
return;
$scope.lastthemeetag = response.headers()["last-modified"];
var themes = response.data;
var themes = response.data;
var exercices = {};
$scope.themes = themes;
$scope.max_gain = 0;
angular.forEach(themes, function(theme, key) {
@ -142,10 +145,12 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
this[key].exercice_count = 0;
this[key].gain = 0;
angular.forEach(theme.exercices, function(ex, k) {
exercices[ex.id] = ex;
this.gain += ex.gain;
}, theme);
$scope.max_gain += theme.gain;
}, themes);
$scope.exercices = exercices;
});
$http.get("./teams.json").then(function(response) {
if ($scope.lastteametag != undefined && $scope.lastteametag == response.headers()["last-modified"])