Add grade filter by category
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2023-03-08 17:13:55 +01:00
parent 9ad021fa65
commit 19a759536b
4 changed files with 29 additions and 2 deletions

View File

@ -1,8 +1,10 @@
<script> <script>
import { getCategories } from '$lib/categories';
import { getSurveys } from '$lib/surveys'; import { getSurveys } from '$lib/surveys';
import { getUsers, getGrades, getPromos } from '$lib/users'; import { getUsers, getGrades, getPromos } from '$lib/users';
export let promo = null; export let promo = null;
export let category = null;
</script> </script>
{#await getPromos() then promos} {#await getPromos() then promos}
@ -15,6 +17,18 @@
</select> </select>
</div> </div>
{/await} {/await}
{#await getCategories() then categories}
<div class="float-end me-2">
<select class="form-select" bind:value={category}>
<option value={null}>toutes</option>
{#each categories as categ (categ.id)}
{#if !promo || categ.promo == promo}
<option value={categ.id}>{categ.label}</option>
{/if}
{/each}
</select>
</div>
{/await}
<h2> <h2>
Étudiants {#if promo !== null}{promo}{/if} Étudiants {#if promo !== null}{promo}{/if}
<small class="text-muted">Notes</small> <small class="text-muted">Notes</small>
@ -39,7 +53,7 @@
<th>ID</th> <th>ID</th>
<th>Login</th> <th>Login</th>
{#each surveys as survey} {#each surveys as survey}
{#if survey.corrected && (!promo || survey.promo == promo)} {#if survey.corrected && (!promo || survey.promo == promo) && (!category || survey.id_category == category)}
<th> <th>
{#if survey.kind == "survey"} {#if survey.kind == "survey"}
<a href="surveys/{survey.id}" style="text-decoration: none">{survey.title}</a> <a href="surveys/{survey.id}" style="text-decoration: none">{survey.title}</a>
@ -68,7 +82,7 @@
<td><a href="users/{user.id}" style="text-decoration: none">{user.id}</a></td> <td><a href="users/{user.id}" style="text-decoration: none">{user.id}</a></td>
<td><a href="users/{user.login}" style="text-decoration: none">{user.login}</a></td> <td><a href="users/{user.login}" style="text-decoration: none">{user.login}</a></td>
{#each surveys as survey} {#each surveys as survey}
{#if survey.corrected && (!promo || survey.promo == promo)} {#if survey.corrected && (!promo || survey.promo == promo) && (!category || survey.id_category == category)}
<td> <td>
{grades[user.id] && grades[user.id][survey.kind + "." + survey.id]?grades[user.id][survey.kind + "." + survey.id]:""} {grades[user.id] && grades[user.id][survey.kind + "." + survey.id]?grades[user.id][survey.kind + "." + survey.id]:""}
</td> </td>

View File

@ -0,0 +1,6 @@
export async function load({ params }) {
return {
promo: parseInt(params.promo),
cid: parseInt(params.cid),
};
}

View File

@ -0,0 +1,7 @@
<script>
import StudentGrades from '$lib/components/StudentGrades.svelte';
export let data;
</script>
<StudentGrades promo={data.promo} category={data.cid} />