Gradation: add route to add missing users
This commit is contained in:
parent
107b17c11f
commit
3397b9f123
4 changed files with 104 additions and 6 deletions
|
@ -109,6 +109,18 @@ export class Work {
|
|||
}
|
||||
}
|
||||
|
||||
async addMissingGrades() {
|
||||
const res = await fetch(`api/works/${this.id}/grades`, {
|
||||
method: 'PATCH',
|
||||
headers: {'Accept': 'application/json'},
|
||||
});
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).map((g) => new Grade(g));
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
async getSubmission(uid) {
|
||||
const res = await fetch(uid?`api/users/${uid}/works/${this.id}/submission`:`api/works/${this.id}/submission`, {
|
||||
headers: {'Accept': 'application/json'}
|
||||
|
|
|
@ -40,6 +40,11 @@
|
|||
stats.mean = sum / grades.length;
|
||||
});
|
||||
}
|
||||
|
||||
async function addMissingStudents(w) {
|
||||
await w.addMissingGrades();
|
||||
refresh_grades(w);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if $user && $user.is_admin}
|
||||
|
@ -72,12 +77,22 @@
|
|||
{#if stats.mean > 0}(moyenne : {Math.round(stats.mean*100)/100}, min : {stats.min}, max : {stats.max}){/if}
|
||||
</small>
|
||||
</h3>
|
||||
<button
|
||||
class="btn btn-light"
|
||||
on:click={() => refresh_grades(w)}
|
||||
>
|
||||
<i class="bi bi-arrow-clockwise"></i>
|
||||
</button>
|
||||
<div>
|
||||
<button
|
||||
class="btn btn-outline-info"
|
||||
title="Ajouter les étudiants manquant"
|
||||
on:click={() => addMissingStudents(w)}
|
||||
>
|
||||
<i class="bi bi-people"></i>
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-light"
|
||||
title="Rafraîchir l'affichage des notes"
|
||||
on:click={() => refresh_grades(w)}
|
||||
>
|
||||
<i class="bi bi-arrow-clockwise"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-3 mb-5">
|
||||
{#await gradesP}
|
||||
|
|
Reference in a new issue