ui: Display grades works
This commit is contained in:
parent
f3aabf9b63
commit
4f87298f63
@ -88,6 +88,8 @@
|
|||||||
<div class="spinner-border spinner-border-sm" role="status"></div>
|
<div class="spinner-border spinner-border-sm" role="status"></div>
|
||||||
{:then score}
|
{:then score}
|
||||||
{score.score}
|
{score.score}
|
||||||
|
{:catch error}
|
||||||
|
<i class="bi text-warning bi-exclamation-triangle-fill" title={error}></i>
|
||||||
{/await}
|
{/await}
|
||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -61,7 +61,7 @@ export async function getUserNeedingHelp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getScore(survey) {
|
export async function getScore(survey) {
|
||||||
const res = await fetch(`api/surveys/${survey.id}/score`, {headers: {'Accept': 'application/json'}})
|
const res = await fetch(survey.kind === "w" ? `api/works/${survey.id}/score` : `api/surveys/${survey.id}/score`, {headers: {'Accept': 'application/json'}})
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
return await res.json();
|
return await res.json();
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,6 +87,18 @@ export class Work {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getGrades() {
|
||||||
|
const res = await fetch(`api/works/${this.id}/grades`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {'Accept': 'application/json'},
|
||||||
|
});
|
||||||
|
if (res.status == 200) {
|
||||||
|
return await res.json();
|
||||||
|
} else {
|
||||||
|
throw new Error((await res.json()).errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getWorks() {
|
export async function getWorks() {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import { user } from '../../../stores/user';
|
import { user } from '../../../stores/user';
|
||||||
import SurveyBadge from '../../../components/SurveyBadge.svelte';
|
import SurveyBadge from '../../../components/SurveyBadge.svelte';
|
||||||
import WorkAdmin from '../../../components/WorkAdmin.svelte';
|
import WorkAdmin from '../../../components/WorkAdmin.svelte';
|
||||||
|
import { getScore } from '../../../lib/users';
|
||||||
|
|
||||||
export let work = null;
|
export let work = null;
|
||||||
</script>
|
</script>
|
||||||
@ -30,5 +31,58 @@
|
|||||||
|
|
||||||
{#if $user && $user.is_admin}
|
{#if $user && $user.is_admin}
|
||||||
<WorkAdmin work={w} on:saved={() => edit = false} />
|
<WorkAdmin work={w} on:saved={() => edit = false} />
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<h3 class="mt-3">Notes</h3>
|
||||||
|
<div class="card mt-3 mb-5">
|
||||||
|
{#await w.getGrades()}
|
||||||
|
<div class="text-center">
|
||||||
|
<div class="spinner-border text-primary mx-3" role="status"></div>
|
||||||
|
<span>Chargement des notes …</span>
|
||||||
|
</div>
|
||||||
|
{:then grades}
|
||||||
|
<table class="table table-hover table-striped mb-0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Login</th>
|
||||||
|
<th>Note</th>
|
||||||
|
<th>Commentaire</th>
|
||||||
|
<th>Date de la note</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#if !grades}
|
||||||
|
<div class="text-center">
|
||||||
|
Aucune note n'a encore été envoyée pour ce travail.
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
{#each grades as grade, gid (grade.id)}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="users/{grade.id_user}">{grade.login}</a>
|
||||||
|
</td>
|
||||||
|
<td>{grade.score}</td>
|
||||||
|
<td>{#if grade.comment}{grade.comment}{:else}-{/if}</td>
|
||||||
|
<td>{grade.date}</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{/await}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
{#await getScore(w)}
|
||||||
|
<div class="spinner-border spinner-border-sm" role="status"></div>
|
||||||
|
{:then grade}
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<strong>Note finale :</strong> <span title="Établie le {grade.date}">{grade.score}</span> {#if grade.comment}– {grade.comment}{/if}
|
||||||
|
</div>
|
||||||
|
{:catch error}
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<i class="bi text-warning bi-exclamation-triangle-fill" title={error}></i>
|
||||||
|
<strong>{error.message}</strong>
|
||||||
|
</div>
|
||||||
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
{/await}
|
{/await}
|
||||||
|
@ -83,6 +83,8 @@
|
|||||||
<div class="spinner-border spinner-border-sm" role="status"></div>
|
<div class="spinner-border spinner-border-sm" role="status"></div>
|
||||||
{:then score}
|
{:then score}
|
||||||
{score.score}
|
{score.score}
|
||||||
|
{:catch error}
|
||||||
|
<i class="bi text-warning bi-exclamation-triangle-fill" title={error}></i>
|
||||||
{/await}
|
{/await}
|
||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
|
Reference in New Issue
Block a user