ui: Working on works
This commit is contained in:
parent
b9acaa798b
commit
197c23736d
12 changed files with 475 additions and 10 deletions
|
|
@ -7,7 +7,9 @@
|
|||
import { getSurveys } from '../lib/surveys';
|
||||
import { getScore } from '../lib/users';
|
||||
|
||||
let req_surveys = getSurveys();
|
||||
export let allworks = false;
|
||||
|
||||
let req_surveys = getSurveys(allworks);
|
||||
export let direct = null;
|
||||
|
||||
req_surveys.then((surveys) => {
|
||||
|
|
@ -17,6 +19,18 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
function gotoSurvey(survey) {
|
||||
if (survey.kind === "w") {
|
||||
goto(`works/${survey.id}`);
|
||||
} else if (survey.direct != null) {
|
||||
goto(`surveys/${survey.id}/live`);
|
||||
} else if ($user.is_admin) {
|
||||
goto(`surveys/${survey.id}/responses`);
|
||||
} else {
|
||||
goto(`surveys/${survey.id}`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<table class="table table-striped table-hover mb-0">
|
||||
|
|
@ -38,7 +52,7 @@
|
|||
</tr>
|
||||
{:then surveys}
|
||||
<tbody style="cursor: pointer;">
|
||||
{#each surveys as survey, sid (survey.id)}
|
||||
{#each surveys as survey, sid (survey.kind + survey.id)}
|
||||
{#if (survey.shown || survey.direct != null || ($user && $user.is_admin)) && (!$user || (!$user.was_admin || $user.promo == survey.promo) || $user.is_admin)}
|
||||
{#if $user && $user.is_admin && (sid == 0 || surveys[sid-1].promo != survey.promo)}
|
||||
<tr class="bg-info text-light">
|
||||
|
|
@ -47,7 +61,7 @@
|
|||
</th>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr on:click={e => goto(survey.direct != null ?`surveys/${survey.id}/live`:$user.is_admin?`surveys/${survey.id}/responses`:`surveys/${survey.id}`)}>
|
||||
<tr on:click={e => gotoSurvey(survey)}>
|
||||
<td>
|
||||
{#if !survey.shown}<i class="bi bi-eye-slash-fill" title="Ce questionnaire n'est pas affiché aux étudiants"></i>{/if}
|
||||
{survey.title}
|
||||
|
|
@ -55,12 +69,12 @@
|
|||
<SurveyBadge {survey} class="float-end" />
|
||||
</td>
|
||||
{#if survey.startAvailability() > Date.now()}
|
||||
<td>
|
||||
<td title="Disponible à partir du {survey.start_availability}">
|
||||
<DateFormat date={survey.start_availability} dateStyle="medium" timeStyle="medium" />
|
||||
<i class="bi bi-arrow-bar-right"></i>
|
||||
</td>
|
||||
{:else}
|
||||
<td>
|
||||
<td title="Sera fermé le {survey.start_availability}">
|
||||
<i class="bi bi-arrow-bar-left"></i>
|
||||
<DateFormat date={survey.end_availability} dateStyle="medium" timeStyle="medium" />
|
||||
</td>
|
||||
|
|
|
|||
135
ui/src/components/WorkAdmin.svelte
Normal file
135
ui/src/components/WorkAdmin.svelte
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<script>
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import { ToastsStore } from '../stores/toasts';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
export let work = null;
|
||||
|
||||
function saveWork() {
|
||||
work.save().then((response) => {
|
||||
dispatch('saved', response);
|
||||
}, (error) => {
|
||||
ToastsStore.addErrorToast({
|
||||
msg: error.errmsg,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function deleteWork() {
|
||||
work.delete().then((response) => {
|
||||
goto(`works`);
|
||||
}, (error) => {
|
||||
ToastsStore.addErrorToast({
|
||||
msg: error.errmsg,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function duplicateWork() {
|
||||
work.duplicate().then((response) => {
|
||||
goto(`works/${response.id}`);
|
||||
}).catch((error) => {
|
||||
ToastsStore.addErrorToast({
|
||||
msg: error.errmsg,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<form on:submit|preventDefault={saveWork}>
|
||||
|
||||
{#if work.id}
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-sm-end">
|
||||
<label for="title" class="col-form-label col-form-label-sm">Identifiant du travail</label>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" class="form-control-plaintext form-control-sm" id="title" value={work.id}>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-sm-end">
|
||||
<label for="title" class="col-form-label col-form-label-sm">Titre du travail</label>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" class="form-control form-control-sm" id="title" bind:value={work.title}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-sm-end">
|
||||
<label for="promo" class="col-form-label col-form-label-sm">Promo</label>
|
||||
</div>
|
||||
<div class="col-sm-8 col-md-4 col-lg-2">
|
||||
<input type="number" step="1" min="0" max="2068" class="form-control form-control-sm" id="promo" bind:value={work.promo}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-sm-end">
|
||||
<label for="group" class="col-form-label col-form-label-sm">Restreindre au groupe</label>
|
||||
</div>
|
||||
<div class="col-sm-8 col-md-4 col-lg-2">
|
||||
<input class="form-control form-control-sm" id="group" bind:value={work.group}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-sm-end">
|
||||
<label for="submissionurl" class="col-form-label col-form-label-sm">URL validation la soumission</label>
|
||||
</div>
|
||||
<div class="col-sm-8 col-md-4 col-lg-2">
|
||||
<input class="form-control form-control-sm" id="submissionurl" bind:value={work.submission_url}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-sm-end">
|
||||
<label for="start_availability" class="col-form-label col-form-label-sm">Date de début</label>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" class="form-control form-control-sm" id="start_availability" bind:value={work.start_availability}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-sm-end">
|
||||
<label for="end_availability" class="col-form-label col-form-label-sm">Date de fin</label>
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<input type="text" class="form-control form-control-sm" id="end_availability" bind:value={work.end_availability}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row row-cols-3 mx-1 my-2">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="shown" bind:checked={work.shown}>
|
||||
<label class="form-check-label" for="shown">
|
||||
Afficher le travail
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="corrected" bind:checked={work.corrected}>
|
||||
<label class="form-check-label" for="corrected">
|
||||
Marqué comme corrigé
|
||||
</label>
|
||||
</div>
|
||||
</div | ||||