chore(deps): update module github.com/coreos/go-oidc to v3 - autoclosed #17
@ -38,15 +38,15 @@
|
|||||||
{edit}
|
{edit}
|
||||||
>
|
>
|
||||||
{#if $user && $user.is_admin}
|
{#if $user && $user.is_admin}
|
||||||
<button class="btn btn-sm btn-danger ms-1 float-end" on:click={() => dispatch('delete')}>
|
<button type="button" class="btn btn-sm btn-danger ms-1 float-end" on:click={() => dispatch('delete')}>
|
||||||
<i class="bi bi-trash-fill"></i>
|
<i class="bi bi-trash-fill"></i>
|
||||||
</button>
|
</button>
|
||||||
{#if edit}
|
{#if edit}
|
||||||
<button class="btn btn-sm btn-success ms-1 float-end" on:click={saveQuestion}>
|
<button type="button" class="btn btn-sm btn-success ms-1 float-end" on:click={saveQuestion}>
|
||||||
<i class="bi bi-check"></i>
|
<i class="bi bi-check"></i>
|
||||||
</button>
|
</button>
|
||||||
{:else}
|
{:else}
|
||||||
<button class="btn btn-sm btn-primary ms-1 float-end" on:click={editQuestion}>
|
<button type="button" class="btn btn-sm btn-primary ms-1 float-end" on:click={editQuestion}>
|
||||||
<i class="bi bi-pencil"></i>
|
<i class="bi bi-pencil"></i>
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
@ -75,23 +75,27 @@
|
|||||||
<input class="form-control" id="q{qid}placeholder" bind:value={question.placeholder}>
|
<input class="form-control" id="q{qid}placeholder" bind:value={question.placeholder}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else if question.kind}
|
||||||
{#await question.getProposals()}
|
{#if !question.id}
|
||||||
<div class="text-center">
|
Veuillez enregistrer la question pour pouvoir ajouter des propositions.
|
||||||
<div class="spinner-border text-primary mx-3" role="status"></div>
|
{:else}
|
||||||
<span>Chargement des choix …</span>
|
{#await question.getProposals()}
|
||||||
</div>
|
<div class="text-center">
|
||||||
{:then proposals}
|
<div class="spinner-border text-primary mx-3" role="status"></div>
|
||||||
<QuestionProposals
|
<span>Chargement des choix …</span>
|
||||||
edit
|
</div>
|
||||||
id_question={question.id}
|
{:then proposals}
|
||||||
kind={question.kind}
|
<QuestionProposals
|
||||||
{proposals}
|
edit
|
||||||
readonly
|
id_question={question.id}
|
||||||
bind:value={value}
|
kind={question.kind}
|
||||||
on:change={() => { dispatch("change"); }}
|
{proposals}
|
||||||
/>
|
readonly
|
||||||
{/await}
|
bind:value={value}
|
||||||
|
on:change={() => { dispatch("change"); }}
|
||||||
|
/>
|
||||||
|
{/await}
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{:else if question.kind == 'mcq' || question.kind == 'ucq'}
|
{:else if question.kind == 'mcq' || question.kind == 'ucq'}
|
||||||
{#await question.getProposals()}
|
{#await question.getProposals()}
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
name={prefixid + 'proposal' + proposal.id_question}
|
name={prefixid + 'proposal' + proposal.id_question}
|
||||||
id={prefixid + 'p' + proposal.id}
|
id={prefixid + 'p' + proposal.id}
|
||||||
bind:group={valueCheck}
|
bind:group={valueCheck}
|
||||||
value={proposal.id.toString()}
|
value={proposal.id?proposal.id.toString():''}
|
||||||
on:change={() => { value = valueCheck.join(','); dispatch("change"); }}
|
on:change={() => { value = valueCheck.join(','); dispatch("change"); }}
|
||||||
>
|
>
|
||||||
{:else}
|
{:else}
|
||||||
@ -49,7 +49,7 @@
|
|||||||
name={prefixid + 'proposal' + proposal.id_question}
|
name={prefixid + 'proposal' + proposal.id_question}
|
||||||
id={prefixid + 'p' + proposal.id}
|
id={prefixid + 'p' + proposal.id}
|
||||||
bind:group={value}
|
bind:group={value}
|
||||||
value={proposal.id.toString()}
|
value={proposal.id?proposal.id.toString():''}
|
||||||
on:change={() => { dispatch("change"); }}
|
on:change={() => { dispatch("change"); }}
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
@ -111,6 +111,7 @@
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-sm btn-link"
|
class="btn btn-sm btn-link"
|
||||||
|
disabled={proposals.length > 0 && !proposals[proposals.length-1].id}
|
||||||
on:click={addProposal}
|
on:click={addProposal}
|
||||||
>
|
>
|
||||||
ajouter
|
ajouter
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
function saveSurvey() {
|
function saveSurvey() {
|
||||||
survey.save().then((response) => {
|
survey.save().then((response) => {
|
||||||
dispatch('saved');
|
dispatch('saved', response);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
ToastsStore.addErrorToast({
|
ToastsStore.addErrorToast({
|
||||||
msg: error.errmsg,
|
msg: error.errmsg,
|
||||||
@ -42,11 +42,22 @@
|
|||||||
|
|
||||||
<form on:submit|preventDefault={saveSurvey}>
|
<form on:submit|preventDefault={saveSurvey}>
|
||||||
|
|
||||||
|
{#if survey.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 questionnaire</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="text" class="form-control-plaintext form-control-sm" id="title" value={survey.id}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-3 text-sm-end">
|
<div class="col-sm-3 text-sm-end">
|
||||||
<label for="title" class="col-form-label col-form-label-sm">Titre du questionnaire</label>
|
<label for="title" class="col-form-label col-form-label-sm">Titre du questionnaire</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-8">{survey.id}
|
<div class="col-sm-8">
|
||||||
<input type="text" class="form-control form-control-sm" id="title" bind:value={survey.title}>
|
<input type="text" class="form-control form-control-sm" id="title" bind:value={survey.title}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -69,22 +80,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
{#if survey.id}
|
||||||
<div class="col-sm-3 text-sm-end">
|
<div class="row">
|
||||||
<label for="direct" class="col-form-label col-form-label-sm">Question en direct</label>
|
<div class="col-sm-3 text-sm-end">
|
||||||
|
<label for="direct" class="col-form-label col-form-label-sm">Question en direct</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{#await getQuestions(survey.id) then questions}
|
||||||
|
<select id="direct" class="form-select form-select-sm" bind:value={survey.direct}>
|
||||||
|
<option value={null}>Pas de direct</option>
|
||||||
|
<option value={0}>Pause</option>
|
||||||
|
{#each questions as question (question.id)}
|
||||||
|
<option value={question.id}>{question.id} - {question.title}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
{/await}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-8">
|
{/if}
|
||||||
{#await getQuestions(survey.id) then questions}
|
|
||||||
<select id="direct" class="form-select form-select-sm" bind:value={survey.direct}>
|
|
||||||
<option value={null}>Pas de direct</option>
|
|
||||||
<option value={0}>Pause</option>
|
|
||||||
{#each questions as question (question.id)}
|
|
||||||
<option value={question.id}>{question.id} - {question.title}</option>
|
|
||||||
{/each}
|
|
||||||
</select>
|
|
||||||
{/await}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-3 text-sm-end">
|
<div class="col-sm-3 text-sm-end">
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
{#if survey.direct != null}<span class="badge bg-danger {className}">Direct</span>
|
{#if survey.direct != null}<span class="badge bg-danger {className}">Direct</span>
|
||||||
{:else if survey.startAvailability() > Date.now()}<span class="badge bg-info {className}">Prévu</span>
|
{:else if survey.startAvailability() > Date.now()}<span class="badge bg-info {className}">Prévu</span>
|
||||||
{:else if survey.endAvailability() > Date.now()}<span class="badge bg-warning {className}">En cours</span>
|
{:else if survey.endAvailability() > Date.now()}<span class="badge bg-warning {className}">En cours</span>
|
||||||
|
{:else if !survey.__start_availability}<span class="badge bg-dark {className}">Nouveau</span>
|
||||||
{:else if !survey.corrected}<span class="badge bg-primary text-light {className}">Terminé</span>
|
{:else if !survey.corrected}<span class="badge bg-primary text-light {className}">Terminé</span>
|
||||||
{:else}<span class="badge bg-success {className}">Corrigé</span>
|
{:else}<span class="badge bg-success {className}">Corrigé</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -68,7 +68,12 @@ export class Question {
|
|||||||
headers: {'Accept': 'application/json'},
|
headers: {'Accept': 'application/json'},
|
||||||
});
|
});
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
return (await res.json()).map((p) => new QuestionProposal(p))
|
const data = await res.json();
|
||||||
|
if (data === null) {
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
return (data).map((p) => new QuestionProposal(p))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error((await res.json()).errmsg);
|
throw new Error((await res.json()).errmsg);
|
||||||
}
|
}
|
||||||
@ -140,7 +145,12 @@ export async function getQuestion(qid) {
|
|||||||
export async function getQuestions(sid) {
|
export async function getQuestions(sid) {
|
||||||
const res = await fetch(`api/surveys/${sid}/questions`, {headers: {'Accept': 'application/json'}})
|
const res = await fetch(`api/surveys/${sid}/questions`, {headers: {'Accept': 'application/json'}})
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
return (await res.json()).map((e) => new Question(e))
|
const data = await res.json();
|
||||||
|
if (data === null) {
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
return (data).map((q) => new Question(q))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error((await res.json()).errmsg);
|
throw new Error((await res.json()).errmsg);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { getQuestions } from './questions';
|
import { getQuestions } from './questions';
|
||||||
|
|
||||||
|
export class Survey {
|
||||||
class Survey {
|
|
||||||
constructor(res) {
|
constructor(res) {
|
||||||
if (res) {
|
if (res) {
|
||||||
this.update(res);
|
this.update(res);
|
||||||
|
24
ui/src/routes/surveys/new.svelte
Normal file
24
ui/src/routes/surveys/new.svelte
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
|
import { user } from '../../stores/user';
|
||||||
|
import SurveyAdmin from '../../components/SurveyAdmin.svelte';
|
||||||
|
import SurveyBadge from '../../components/SurveyBadge.svelte';
|
||||||
|
import SurveyQuestions from '../../components/SurveyQuestions.svelte';
|
||||||
|
import { Survey } from '../../lib/surveys';
|
||||||
|
import { getQuestions } from '../../lib/questions';
|
||||||
|
|
||||||
|
let survey = new Survey();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<h2>
|
||||||
|
<a href="surveys/" class="text-muted" style="text-decoration: none"><</a>
|
||||||
|
Nouveau questionnaire
|
||||||
|
</h2>
|
||||||
|
<SurveyBadge class="ms-2" {survey} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if $user.is_admin}
|
||||||
|
<SurveyAdmin {survey} on:saved={(e) => { goto(`surveys/${e.detail.id}`)}} />
|
||||||
|
{/if}
|
Reference in New Issue
Block a user