Skip to content

Commit 5fa3976

Browse files
committed
feat(page-profile): cheating banner
1 parent efb5ba9 commit 5fa3976

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/app/components/profile/page-profile/page-profile.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ <h3>{{'profile.trophies' | translate}}</h3>
7575

7676
<ng-container *ngIf="!user.$isOrg">
7777
<h3>{{'profile.stats.title' | translate}}</h3>
78+
<div *ngIf="user.cheat" class="alert alert-danger alert-cheat">{{'profile.stats.cheat' | translate}}</div>
7879
<div class="stats" *ngFor="let stats of (userProgress$ | async); let first = first">
7980
<h4 class="title">{{stats.title}}</h4>
8081
<h5 class="prediction" *ngIf="first && (prediction$ | async) as prediction">

src/app/components/profile/page-profile/page-profile.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,19 @@ export class PageProfileComponent implements OnInit {
179179
map(([year, waves]) => [year, ...waves])
180180
);
181181

182-
this.prediction$ = combineLatest([this.tasks.tasks$, this.tasksWithScore$, this.userProgress$, this.years.selectedFull$]).pipe(
183-
map(([tasks, scores, userProgress, year]) => {
182+
this.prediction$ = combineLatest([this.tasks.tasks$, this.tasksWithScore$, this.userProgress$, this.years.selectedFull$, this.user$]).pipe(
183+
map(([tasks, scores, userProgress, year, user]) => {
184184
if (userProgress.length === 0){
185185
return null;
186186
}
187187

188-
return PageProfileComponent.generatePrediction(tasks, scores, userProgress[0], Math.max((year?.sum_points || 0), (year?.point_pad || 0)));
188+
const prediction = PageProfileComponent.generatePrediction(tasks, scores, userProgress[0], Math.max((year?.sum_points || 0), (year?.point_pad || 0)));
189+
190+
if (prediction?.doable && user.cheat) {
191+
prediction.doable = false;
192+
}
193+
194+
return prediction;
189195
})
190196
);
191197

src/assets/i18n/cs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@
420420
"score": "Skóre",
421421
"solved-count": "Vyřešených úloh",
422422
"whole-year": "Celý ročník",
423+
"cheat": "Bylo u tebe detekováno podvádění nebo jiné chování v přímém rozporu s pravidly semináře",
423424
"prediction": {
424425
"normal": "Potřebuješ získat ještě {{percent}}% z celkového počtu bodů",
425426
"positive": {

0 commit comments

Comments
 (0)