From 32b5095e876d77b3cf6ad08ccb848ca860818870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vikt=C3=B3ria=20Brezinov=C3=A1?= Date: Sat, 9 Dec 2023 00:42:22 +0100 Subject: [PATCH 1/4] add series results generation --- .../SemesterAdministration.tsx | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/components/SemesterAdministration/SemesterAdministration.tsx b/src/components/SemesterAdministration/SemesterAdministration.tsx index 312ac5d3..76f20fe8 100644 --- a/src/components/SemesterAdministration/SemesterAdministration.tsx +++ b/src/components/SemesterAdministration/SemesterAdministration.tsx @@ -63,6 +63,27 @@ export const SemesterAdministration: FC = () => { ) } + const getSeriesResults = async (seriesId: number) => { + const {data} = await axios.get(`/api/competition/series/${seriesId}/results`) + setTextareaContent( + data + .map((result: Result) => { + let rank = '' + if (result.rank_changed) { + if (result.rank_start === result.rank_end) { + rank = `${result.rank_start}.` + } else { + rank = `${result.rank_start}.-${result.rank_end}.` + } + } + const name = `${result.registration.profile.first_name} ${result.registration.profile.last_name}` + const points = result.solutions[0].map((problem) => problem.points).join('&') + return `${rank}&${name}&${result.registration.school.abbreviation}&${result.registration.grade}&${points}&${result.total}\\\\` + }) + .join('\n'), + ) + } + const getPostalCards = async (offline_only: boolean) => { const {data} = await axios.get( `/api/competition/semester/${semesterId}/${offline_only ? 'offline-schools' : 'schools'}`, @@ -110,7 +131,14 @@ export const SemesterAdministration: FC = () => { ))}

Generovanie dát

- + {[...semester.series_set].reverse().map((series) => ( +
+ +
+ ))} + +
+
Zoznam riešiteľov From b7534250f8221872c867823e4c6fddf2a8eecd63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vikt=C3=B3ria=20Brezinov=C3=A1?= Date: Sat, 9 Dec 2023 00:44:22 +0100 Subject: [PATCH 2/4] change justification to left --- .../SemesterAdministration/SemesterAdministration.module.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SemesterAdministration/SemesterAdministration.module.scss b/src/components/SemesterAdministration/SemesterAdministration.module.scss index 66f7f244..0ce1106f 100644 --- a/src/components/SemesterAdministration/SemesterAdministration.module.scss +++ b/src/components/SemesterAdministration/SemesterAdministration.module.scss @@ -1,6 +1,6 @@ .actions { margin-top: .5rem; display: flex; - justify-content: flex-end; + justify-content: flex-start; column-gap: 20px; } \ No newline at end of file From 0fa731803287156dbd4087e56224490b80a9e012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vikt=C3=B3ria=20Brezinov=C3=A1?= Date: Sat, 9 Dec 2023 00:44:57 +0100 Subject: [PATCH 3/4] change id of seriesWithPoblems to required --- src/types/api/generated/competition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/api/generated/competition.ts b/src/types/api/generated/competition.ts index 62c5f460..e1ec32ba 100644 --- a/src/types/api/generated/competition.ts +++ b/src/types/api/generated/competition.ts @@ -121,7 +121,7 @@ export interface Series { } export interface SeriesWithProblems { - id?: number + id: number can_participate?: any is_registered?: any problems: Problem[] From 7db62ff2eec8f05e4fb3dd09b92f64ee3ebfe0b9 Mon Sep 17 00:00:00 2001 From: matushl Date: Sat, 9 Dec 2023 13:03:42 +0100 Subject: [PATCH 4/4] Unite two functions into one --- .../SemesterAdministration.tsx | 41 +++++++------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/src/components/SemesterAdministration/SemesterAdministration.tsx b/src/components/SemesterAdministration/SemesterAdministration.tsx index 76f20fe8..b9617436 100644 --- a/src/components/SemesterAdministration/SemesterAdministration.tsx +++ b/src/components/SemesterAdministration/SemesterAdministration.tsx @@ -41,30 +41,11 @@ export const SemesterAdministration: FC = () => { const [textareaContent, setTextareaContent] = useState('') - const getSemesterResults = async () => { - const {data} = await axios.get(`/api/competition/semester/${semesterId}/results`) - setTextareaContent( - data - .map((result: Result) => { - let rank = '' - if (result.rank_changed) { - if (result.rank_start === result.rank_end) { - rank = `${result.rank_start}.` - } else { - rank = `${result.rank_start}.-${result.rank_end}.` - } - } - const name = `${result.registration.profile.first_name} ${result.registration.profile.last_name}` - const subtotal = result.subtotal[0] - const points = result.solutions[1].map((problem) => problem.points).join('&') - return `${rank}&${name}&${result.registration.school.abbreviation}&${result.registration.grade}&${subtotal}&${points}&${result.total}\\\\` - }) - .join('\n'), + const getResults = async (seriesId: number | null) => { + const isSemester = seriesId === null + const {data} = await axios.get( + isSemester ? `/api/competition/semester/${semesterId}/results` : `/api/competition/series/${seriesId}/results`, ) - } - - const getSeriesResults = async (seriesId: number) => { - const {data} = await axios.get(`/api/competition/series/${seriesId}/results`) setTextareaContent( data .map((result: Result) => { @@ -77,8 +58,14 @@ export const SemesterAdministration: FC = () => { } } const name = `${result.registration.profile.first_name} ${result.registration.profile.last_name}` - const points = result.solutions[0].map((problem) => problem.points).join('&') - return `${rank}&${name}&${result.registration.school.abbreviation}&${result.registration.grade}&${points}&${result.total}\\\\` + if (isSemester) { + const subtotal = result.subtotal[0] + const points = result.solutions[1].map((problem) => problem.points).join('&') + return `${rank}&${name}&${result.registration.school.abbreviation}&${result.registration.grade}&${subtotal}&${points}&${result.total}\\\\` + } else { + const points = result.solutions[0].map((problem) => problem.points).join('&') + return `${rank}&${name}&${result.registration.school.abbreviation}&${result.registration.grade}&${points}&${result.total}\\\\` + } }) .join('\n'), ) @@ -133,10 +120,10 @@ export const SemesterAdministration: FC = () => {
{[...semester.series_set].reverse().map((series) => (
- +
))} - +