Skip to content

Commit e6f590f

Browse files
committed
Temporary removal of Achievements column in leaderboard and added default sample profile pictures
1 parent 9138c53 commit e6f590f

File tree

9 files changed

+35
-3
lines changed

9 files changed

+35
-3
lines changed

public/assets/Sample Profile 1.jpg

6.84 KB
Loading

public/assets/Sample Profile 2.jpg

8.79 KB
Loading

public/assets/Sample Profile 3.jpg

10.8 KB
Loading

public/assets/Sample Profile 4.jpg

75.7 KB
Loading

public/assets/Sample Profile 5.jpg

17.9 KB
Loading

public/assets/Sample Profile 6.jpg

6.9 KB
Loading

public/assets/Sample Profile 7.jpg

14 KB
Loading

src/pages/leaderboard/subcomponents/ContestLeaderboard.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ const ContestLeaderboard: React.FC<Props> = ({ type, contestID }) => {
7070
const top3 = rankedLeaderboard.filter(row => row.rank <= 3);
7171
const rest = rankedLeaderboard.slice(top3.length, Number(visibleEntries));
7272

73+
// Set sample profile pictures (Seeded random)
74+
function convertToRandomNumber(id: string): number {
75+
const str = id.slice(1);
76+
let hash = 0;
77+
for (let i = 0; i < str.length; i++) {
78+
const char = str.charCodeAt(i);
79+
hash = (hash << 5) - hash + char;
80+
}
81+
return (Math.abs(hash) % 7) + 1;
82+
}
83+
84+
rankedLeaderboard.map((row: ContestLeaderboardRow) => {
85+
row.avatar = `/assets/Sample Profile ${convertToRandomNumber(row.username)}.jpg`;
86+
})
87+
7388
// const workspaceLocation = 'assessment';
7489
const navigate = useNavigate();
7590
const handleLinkClick = (code: string, votingId: number) => {

src/pages/leaderboard/subcomponents/OverallLeaderboard.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ import {
1313
LeaderboardRow
1414
} from 'src/features/leaderboard/LeaderboardTypes';
1515

16-
import default_avatar from '../../../assets/default-avatar.jpg';
1716
import leaderboard_background from '../../../assets/leaderboard_background.jpg';
1817
import LeaderboardDropdown from './LeaderboardDropdown';
1918
import LeaderboardExportButton from './LeaderboardExportButton';
2019
import LeaderboardPodium from './LeaderboardPodium';
2120

21+
import default_avatar from 'src/assets/default-avatar.jpg'
22+
2223
const OverallLeaderboard: React.FC = () => {
2324
// Retrieve XP Data from store
2425
const rankedLeaderboard: LeaderboardRow[] = useTypedSelector(store => store.leaderboard.userXp);
@@ -49,6 +50,21 @@ const OverallLeaderboard: React.FC = () => {
4950
const visibleEntries = useTypedSelector(store => store.session.topLeaderboardDisplay);
5051
const topX = rankedLeaderboard.slice(0, Number(visibleEntries));
5152

53+
// Set sample profile pictures (Seeded random)
54+
function convertToRandomNumber(id: string): number {
55+
const str = id.slice(1);
56+
let hash = 0;
57+
for (let i = 0; i < str.length; i++) {
58+
const char = str.charCodeAt(i);
59+
hash = (hash << 5) - hash + char;
60+
}
61+
return (Math.abs(hash) % 7) + 1;
62+
}
63+
64+
rankedLeaderboard.map((row: LeaderboardRow) => {
65+
row.avatar = `/assets/Sample Profile ${convertToRandomNumber(row.username)}.jpg`;
66+
})
67+
5268
// Define column definitions for ag-Grid
5369
const columnDefs: ColDef<LeaderboardRow>[] = useMemo(
5470
() => [
@@ -57,7 +73,7 @@ const OverallLeaderboard: React.FC = () => {
5773
suppressMovable: true,
5874
headerName: 'Rank',
5975
width: 84,
60-
sortable: true,
76+
sortable: true,
6177
cellRenderer: (params: any) => {
6278
const rank = params.value;
6379
const medal = rank === 1 ? '🥇' : rank === 2 ? '🥈' : rank === 3 ? '🥉' : '';
@@ -81,14 +97,15 @@ const OverallLeaderboard: React.FC = () => {
8197
)
8298
},
8399
{ field: 'name', suppressMovable: true, headerName: 'Name', width: 520, sortable: true },
84-
{ field: 'xp', suppressMovable: true, headerName: 'XP', width: 154, sortable: true },
100+
{ field: 'xp', suppressMovable: true, headerName: 'XP', width: 414/*154*/, sortable: true }/*,
85101
{
86102
field: 'achievements',
87103
suppressMovable: true,
88104
sortable: false,
89105
headerName: 'Achievements',
90106
width: 260
91107
}
108+
*/
92109
],
93110
[]
94111
);

0 commit comments

Comments
 (0)