admin: Display student needing help on home page
This commit is contained in:
parent
1ce1f90e66
commit
5b1be21728
3 changed files with 54 additions and 0 deletions
|
|
@ -51,6 +51,15 @@ export async function getUserScore(uid, survey) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getUserNeedingHelp() {
|
||||
const res = await fetch(`api/help`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getScore(survey) {
|
||||
const res = await fetch(`api/surveys/${survey.id}/score`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { user } from '../stores/user';
|
||||
import { getUser, getUserNeedingHelp } from '../lib/users';
|
||||
import SurveyList from '../components/SurveyList.svelte';
|
||||
import ValidateSubmissions from '../components/ValidateSubmissions.svelte';
|
||||
|
||||
|
|
@ -37,6 +38,26 @@
|
|||
|
||||
<ValidateSubmissions />
|
||||
|
||||
{#if $user.is_admin}
|
||||
<p class="lead">Demande d'aide :</p>
|
||||
{#await getUserNeedingHelp()}
|
||||
<span class="spinner-border spinner-border" role="status" aria-hidden="true"></span>
|
||||
{:then nhs}
|
||||
<ul style="columns: 2">
|
||||
{#each nhs as user (user.id)}
|
||||
<li>
|
||||
{#await getUser(user.id_user)}
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
{:then u}
|
||||
<a href="users/{u.id}">{u.login}</a>
|
||||
{/await}
|
||||
({user.date})
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/await}
|
||||
{/if}
|
||||
|
||||
<p class="lead">Voici la liste des questionnaires :</p>
|
||||
{:else}
|
||||
<p class="card-text lead">
|
||||
|
|
|
|||
Reference in a new issue