From 07ceb20d63bd512c9c648aacee924a528f6c4d9f Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Mon, 6 Mar 2023 22:29:35 +0100 Subject: [PATCH] Refactor work page --- ui/src/lib/components/WorkGrades.svelte | 153 ++++++++++++++++++++ ui/src/lib/components/WorkHeader.svelte | 39 ++++++ ui/src/routes/works/[wid]/+page.svelte | 177 ++---------------------- 3 files changed, 203 insertions(+), 166 deletions(-) create mode 100644 ui/src/lib/components/WorkGrades.svelte create mode 100644 ui/src/lib/components/WorkHeader.svelte diff --git a/ui/src/lib/components/WorkGrades.svelte b/ui/src/lib/components/WorkGrades.svelte new file mode 100644 index 0000000..f791ba1 --- /dev/null +++ b/ui/src/lib/components/WorkGrades.svelte @@ -0,0 +1,153 @@ + + +
+

+ Notes + + {#if stats.mean > 0}(moyenne : {Math.round(stats.mean*100)/100}, min : {stats.min}, max : {stats.max}){/if} + +

+
+ + + +
+
+
+ {#await gradesP} +
+
+ Chargement des notes … +
+ {:then grades} + + + + + + + + + + + {#if !grades} +
+ Aucune note n'a encore été envoyée pour ce travail. +
+ {:else} + {#each grades as grade, gid (grade.id)} + + + + + + + + {/each} + {/if} + +
LoginNoteCommentaireDate de la note
+ {grade.login} + {#if grade.comment}{grade.comment}{:else}-{/if}{grade.date} + + + + + + + {#if gradationStatus[grade.id]} + {#await gradationStatus[grade.id]} + + {:then status} + + {/await} + {/if} + +
+ {/await} +
diff --git a/ui/src/lib/components/WorkHeader.svelte b/ui/src/lib/components/WorkHeader.svelte new file mode 100644 index 0000000..4417f90 --- /dev/null +++ b/ui/src/lib/components/WorkHeader.svelte @@ -0,0 +1,39 @@ + + +
+
Date de début
+
+
Date de fin
+
+ {#if work.submission_url != "-"} +
Rendu ?
+
+ {#if work.submission_url} + + {:else} + {#await my_submission} +
+ {:then submission} + + + {:catch} + + Non + {/await} + {/if} +
+ {/if} +
diff --git a/ui/src/routes/works/[wid]/+page.svelte b/ui/src/routes/works/[wid]/+page.svelte index 67b99f5..e4c8bee 100644 --- a/ui/src/routes/works/[wid]/+page.svelte +++ b/ui/src/routes/works/[wid]/+page.svelte @@ -3,11 +3,12 @@ import { user } from '$lib/stores/user'; import DateFormat from '$lib/components/DateFormat.svelte'; - import ScoreBadge from '$lib/components/ScoreBadge.svelte'; import SubmissionStatus from '$lib/components/SubmissionStatus.svelte'; import SurveyBadge from '$lib/components/SurveyBadge.svelte'; import TraceStatus from '$lib/components/TraceStatus.svelte'; import WorkAdmin from '$lib/components/WorkAdmin.svelte'; + import WorkGrades from '$lib/components/WorkGrades.svelte'; + import WorkHeader from '$lib/components/WorkHeader.svelte'; import WorkRepository from '$lib/components/WorkRepository.svelte'; import { getScore } from '$lib/users'; @@ -15,41 +16,15 @@ let edit = false; let my_submission = null; let warn_already_used = false; + let showSteps = false; let w = null; - let gradesP = null; - let gradationStatus = {}; - let stats = {"mean": 0, "min": 999, "max": 0}; $: w = data.work; $: refresh_submission(data.work); - $: refresh_grades(data.work); function refresh_submission(w) { my_submission = w.getSubmission(); } - - function refresh_grades(w) { - gradesP = w.getGrades(); - gradesP.then((grades) => { - if (grades.length <= 0) return; - - let sum = 0; - for (const grade of grades) { - if (!gradationStatus[grade.id]) - gradationStatus[grade.id] = grade.gradationStatus(); - - sum += grade.score; - if (stats.min > grade.score && grade.comment != "- Non rendu -") stats.min = grade.score; - if (stats.max < grade.score) stats.max = grade.score; - } - stats.mean = sum / grades.length; - }); - } - - async function addMissingStudents(w) { - await w.addMissingGrades(); - refresh_grades(w); - } {#if $user && $user.is_admin} @@ -75,151 +50,21 @@ {/if}
-
-

- Notes - - {#if stats.mean > 0}(moyenne : {Math.round(stats.mean*100)/100}, min : {stats.min}, max : {stats.max}){/if} - -

-
- - -
-
-
- {#await gradesP} -
-
- Chargement des notes … -
- {:then grades} -

+ {#if showSteps} - - - - - - - - - - - {#if !grades} -
- Aucune note n'a encore été envoyée pour ce travail. -
- {:else} - {#each grades as grade, gid (grade.id)} - - - - - - - - {/each} - {/if} - -
LoginNoteCommentaireDate de la note
- {grade.login} - {#if grade.comment}{grade.comment}{:else}-{/if}{grade.date} - - - - - - - {#await gradationStatus[grade.id]} - - {:then status} - - {/await} - -
- {/await} -

+ {:else} + showSteps = true} + /> + {/if} {:else if (!$user || !$user.is_admin) && new Date(w.start_availability) > new Date()}
Ce travail n'est pas encore ouvert. Revenez plus tard !
{:else} -
-
Date de début
-
-
Date de fin
-
- {#if w.submission_url != "-"} -
Rendu ?
-
- {#if w.submission_url} - - {:else} - {#await my_submission} -
- {:then submission} - - - {:catch} - - Non - {/await} - {/if} -
- {/if} -
+ {#if w.description}
{@html w.description}