diff --git a/atsebayt/src/components/StudentGrades.svelte b/atsebayt/src/components/StudentGrades.svelte index 44d9e46..d9668b1 100644 --- a/atsebayt/src/components/StudentGrades.svelte +++ b/atsebayt/src/components/StudentGrades.svelte @@ -1,25 +1,77 @@ +{#await getPromos() then promos} +
+ +
+{/await}

- Étudiants {#if promo}{promo}{/if} + Étudiants {#if promo !== null}{promo}{/if} Notes

- - - - - - - - - - - - - - - -
IDLogin{ survey.title }
{ user.id }{ user.login }{ grades[user.id][survey.id] }
+{#await getSurveys()} +
+
+ Chargement des questionnaires corrigés… +
+{:then surveys} + {#await getGrades()} +
+
+ Chargement des notes… +
+ {:then grades} +
+ + + + + + {#each surveys as survey (survey.id)} + {#if survey.corrected && (promo === null || survey.promo == promo)} + + {/if} + {/each} + + + + {#await getUsers()} + + + + {:then users} + {#each users as user (user.id)} + {#if promo === null || user.promo === promo} + + + + {#each surveys as survey (survey.id)} + {#if survey.corrected && (promo === null || survey.promo == promo)} + + {/if} + {/each} + + {/if} + {/each} + {/await} + +
IDLogin{survey.title}
+
+
+ Chargement des étudiants… +
+
{user.id}{user.login}{grades[user.id][survey.id]?grades[user.id][survey.id]:"N/A"}
+
+ {/await} +{/await} diff --git a/atsebayt/src/lib/users.js b/atsebayt/src/lib/users.js index a6e00d8..51847e2 100644 --- a/atsebayt/src/lib/users.js +++ b/atsebayt/src/lib/users.js @@ -25,6 +25,14 @@ export async function getUser(uid) { } } +export async function getGrades(uid, survey) { + const res = await fetch(`api/grades`, {headers: {'Accept': 'application/json'}}) + if (res.status == 200) { + return await res.json(); + } else { + throw new Error((await res.json()).errmsg); + } +} export async function getUserGrade(uid, survey) { const res = await fetch(`api/users/${uid}/surveys/${survey.id}/grades`, {headers: {'Accept': 'application/json'}}) if (res.status == 200) {