diff --git a/CTF/CTF-Frontend/src/app/leaderboard/leaderboard.component.html b/CTF/CTF-Frontend/src/app/leaderboard/leaderboard.component.html
index 72fe8a2..f63078a 100644
--- a/CTF/CTF-Frontend/src/app/leaderboard/leaderboard.component.html
+++ b/CTF/CTF-Frontend/src/app/leaderboard/leaderboard.component.html
@@ -22,8 +22,8 @@
-
- {{ getRank() - 12 }} |
+
+ {{ getRank(index+1) }} |
{{ user.Name }} |
{{ user.Flags }} |
diff --git a/CTF/CTF-Frontend/src/app/leaderboard/leaderboard.component.ts b/CTF/CTF-Frontend/src/app/leaderboard/leaderboard.component.ts
index 0f730ab..99efab8 100644
--- a/CTF/CTF-Frontend/src/app/leaderboard/leaderboard.component.ts
+++ b/CTF/CTF-Frontend/src/app/leaderboard/leaderboard.component.ts
@@ -23,7 +23,6 @@ import { Submission } from '../models/submission.model';
})
export class LeaderboardComponent {
users: User[] = []; // array of all usrs
- rank: number = 0; // rank number for indexing table
contest: string | null = ""; // contest name
contestObj : Contest | null = null;
contestID : number | undefined = 0; // contest ID
@@ -35,7 +34,6 @@ export class LeaderboardComponent {
// on initialize
ngOnInit() {
- this.rank = 0;
this.PopulateTable();
this.contest = sessionStorage.getItem('ContestString');
}
@@ -85,19 +83,18 @@ export class LeaderboardComponent {
let user = this.users[i];
this.users[i].Flags = 0;
for (let j=0; j < this.subs.length; j++) {
- let sub = this.subs[i];
+ let sub = this.subs[j];
if (user.UserID == sub.UserID && sub.IsCorrect == true) {
this.users[i].Flags++;
}
}
}
- this.users = this.users.sort((a,b) => a.Flags + b.Flags); // sort the users
+ this.users = this.users.sort((a,b) => b.Flags - a.Flags); // sort the users
}
// increment rank and insert into table
- getRank(): number {
- this.rank++;
- return this.rank;
+ getRank(index: number): number {
+ return index++;
}
}