Skip to content

Commit b0ff599

Browse files
committed
Merge branch 'leaderboard' of https://github.com/source-academy/frontend into leaderboard
2 parents dfbe92a + a44480e commit b0ff599

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/commons/sagas/RequestsSaga.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ export const dispatchContestXp = async (
13361336
};
13371337

13381338
/**
1339-
* GET /courses/{courseId}/admin/assessments/{assessmentId}/scoreLeaderboard
1339+
* GET /courses/{courseId}/assessments/{assessmentId}/scoreLeaderboard
13401340
*/
13411341
export const getScoreLeaderboard = async (
13421342
assessmentId: number,
@@ -1345,7 +1345,7 @@ export const getScoreLeaderboard = async (
13451345
): Promise<ContestEntry[] | null> => {
13461346
const params = new URLSearchParams({ visible_entries: `${visibleEntries}` });
13471347
const resp = await request(
1348-
`${courseId()}/admin/assessments/${assessmentId}/scoreLeaderboard?${params.toString()}`,
1348+
`${courseId()}/assessments/${assessmentId}/scoreLeaderboard?${params.toString()}`,
13491349
'GET',
13501350
{
13511351
...tokens
@@ -1368,7 +1368,7 @@ export const getScoreLeaderboard = async (
13681368
};
13691369

13701370
/**
1371-
* GET /courses/{courseId}/admin/assessments/{assessmentId}/popularVoteLeaderboard
1371+
* GET /courses/{courseId}/assessments/{assessmentId}/popularVoteLeaderboard
13721372
*/
13731373
export const getPopularVoteLeaderboard = async (
13741374
assessmentId: number,
@@ -1377,7 +1377,7 @@ export const getPopularVoteLeaderboard = async (
13771377
): Promise<ContestEntry[] | null> => {
13781378
const params = new URLSearchParams({ visible_entries: `${visibleEntries}` });
13791379
const resp = await request(
1380-
`${courseId()}/admin/assessments/${assessmentId}/popularVoteLeaderboard?${params.toString()}`,
1380+
`${courseId()}/assessments/${assessmentId}/popularVoteLeaderboard?${params.toString()}`,
13811381
'GET',
13821382
{
13831383
...tokens

src/pages/leaderboard/subcomponents/LeaderboardExportButton.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,20 @@ const LeaderboardExportButton: React.FC<Props> = ({ type, contest, contestID })
5353
}
5454
}, [data]);
5555

56+
const escapeCodeField = (value: any) => {
57+
const str = value?.toString() ?? '';
58+
const escaped = str.replace(/"/g, '""');
59+
return `"${escaped}"`;
60+
};
61+
5662
const role = useTypedSelector(store => store.session.role);
5763
const exportCSV = () => {
5864
const headers = [
5965
'Rank',
6066
'Name',
6167
'Username',
6268
type === 'overall' ? 'XP' : 'Score',
63-
type === 'overall' ? 'Achievements' : 'Submission Id'
69+
type === 'overall' ? 'Achievements' : 'Code'
6470
];
6571
const rows = data?.map(
6672
(player: {
@@ -83,7 +89,7 @@ const LeaderboardExportButton: React.FC<Props> = ({ type, contest, contestID })
8389
: (player as ContestLeaderboardRow).score,
8490
type === 'overall'
8591
? (player as LeaderboardRow).achievements
86-
: (player as ContestLeaderboardRow).submissionId
92+
: escapeCodeField((player as ContestLeaderboardRow).code)
8793
]
8894
);
8995

0 commit comments

Comments
 (0)