From 894e9c9b7c73a2afec045e43ab66b77b512c40af Mon Sep 17 00:00:00 2001 From: Mateusz Tylka Date: Wed, 10 May 2023 15:08:26 +0200 Subject: [PATCH 1/2] display submission description to Leaderboad --- .../specific_challenge/Leaderboard/Leaderboard.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/specific_challenge/Leaderboard/Leaderboard.js b/src/components/specific_challenge/Leaderboard/Leaderboard.js index 8a67b25..c0b6fd4 100644 --- a/src/components/specific_challenge/Leaderboard/Leaderboard.js +++ b/src/components/specific_challenge/Leaderboard/Leaderboard.js @@ -11,7 +11,6 @@ import { CALC_PAGES, EVALUATIONS_FORMAT, RENDER_WHEN, - } from '../../../utils/globals'; import Search from '../../generic/Search'; import Pager from '../../generic/Pager'; @@ -65,7 +64,7 @@ const Leaderboard = (props) => { }; const getLeaderboardHeader = () => { - let header = ['#', 'submitter']; + let header = ['#', 'submitter', 'description']; for (let metric of getPossibleMetrics()) { header.push(metric); } @@ -75,7 +74,7 @@ const Leaderboard = (props) => { }; const getLeaderboardHeaderMobile = () => { - let header = ['#', 'submitter', 'entries', 'when']; + let header = ['#', 'submitter', 'description', 'entries', 'when']; for (let metric of getPossibleMetrics()) { header.push(metric); } @@ -170,7 +169,7 @@ const Leaderboard = (props) => { tableType="leaderboard" gridTemplateColumns={ entries[0] - ? '1fr 3fr ' + + ? '1fr 2fr 3fr ' + '2fr '.repeat(entries[0].evaluations.length) + '1fr 2fr' : '' @@ -179,6 +178,7 @@ const Leaderboard = (props) => { staticColumnElements={[ { name: 'id', format: null, order: 1, align: 'left' }, { name: 'submitter', format: null, order: 2, align: 'left' }, + { name: 'description', format: null, order: 3, align: 'left' }, { name: 'times', format: null, order: 4, align: 'left' }, { name: 'when', format: RENDER_WHEN, order: 5, align: 'right' }, ]} @@ -224,7 +224,7 @@ const Leaderboard = (props) => { headerElements={getLeaderboardHeader()} gridTemplateColumns={ entries[0] - ? '1fr 3fr ' + + ? '1fr 2fr 3fr ' + '2fr '.repeat(entries[0].evaluations.length) + '1fr 2fr' : '' @@ -233,6 +233,7 @@ const Leaderboard = (props) => { staticColumnElements={[ { name: 'id', format: null, order: 1, align: 'left' }, { name: 'submitter', format: null, order: 2, align: 'left' }, + { name: 'description', format: null, order: 3, align: 'left' }, { name: 'times', format: null, order: 4, align: 'left' }, { name: 'when', format: RENDER_WHEN, order: 5, align: 'right' }, ]} @@ -255,7 +256,6 @@ const Leaderboard = (props) => { width="72px" borderRadius="64px" pages={CALC_PAGES(entries, 2)} - number={`${pageNr} / ${CALC_PAGES(entries, 2)}`} /> From bab709a7eb9ddaf695c82d682265e557e85d8d86 Mon Sep 17 00:00:00 2001 From: Mateusz Tylka Date: Wed, 10 May 2023 15:12:28 +0200 Subject: [PATCH 2/2] sorting by description in Leaderboard --- .../Leaderboard/Leaderboard.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/specific_challenge/Leaderboard/Leaderboard.js b/src/components/specific_challenge/Leaderboard/Leaderboard.js index c0b6fd4..8ffb2c6 100644 --- a/src/components/specific_challenge/Leaderboard/Leaderboard.js +++ b/src/components/specific_challenge/Leaderboard/Leaderboard.js @@ -22,6 +22,7 @@ const Leaderboard = (props) => { const [pageNr, setPageNr] = React.useState(1); const [loading, setLoading] = React.useState(true); const [submitterSorted, setSubmitterSorted] = React.useState(false); + const [descriptionSorted, setDescriptionSorted] = React.useState(false); const [entriesSorted, setEntriesSorted] = React.useState(false); const [whenSorted, setWhenSorted] = React.useState(false); const [scoresSorted, setScoresSorted] = React.useState([]); @@ -106,6 +107,27 @@ const Leaderboard = (props) => { setSubmitterSorted(true); } break; + case 'description': + if (descriptionSorted) { + newEntries = newEntries.sort((a, b) => + a.description.toLowerCase() < b.description.toLowerCase() + ? 1 + : b.description.toLowerCase() < a.description.toLowerCase() + ? -1 + : 0 + ); + setDescriptionSorted(false); + } else { + newEntries = newEntries.sort((a, b) => + a.description.toLowerCase() > b.description.toLowerCase() + ? 1 + : b.description.toLowerCase() > a.description.toLowerCase() + ? -1 + : 0 + ); + setDescriptionSorted(true); + } + break; case 'entries': if (entriesSorted) { newEntries = newEntries.sort((a, b) => b.times - a.times);