lives: Can display results as charts on all screens
This commit is contained in:
parent
5b2fddddc1
commit
e61a8bd51d
3 changed files with 107 additions and 11 deletions
|
|
@ -47,6 +47,7 @@
|
|||
let responses = {};
|
||||
let corrected = false;
|
||||
let next_corrected = false;
|
||||
let with_stats = false;
|
||||
let timer = 20;
|
||||
let timer_end = null;
|
||||
let timer_remain = 0;
|
||||
|
|
@ -308,7 +309,6 @@
|
|||
Réponses
|
||||
</th>
|
||||
<th>
|
||||
Actions
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-primary"
|
||||
|
|
@ -330,11 +330,13 @@
|
|||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-info"
|
||||
on:click={() => { edit_question = new Question({ id_survey: survey.id }) } }
|
||||
title="Ajouter une question"
|
||||
class="btn btn-sm"
|
||||
class:btn-outline-success={!with_stats}
|
||||
class:btn-success={with_stats}
|
||||
on:click={() => { with_stats = !with_stats } }
|
||||
title="La prochaine correction sera affichée avec les statistiques"
|
||||
>
|
||||
<i class="bi bi-plus"></i>
|
||||
<i class="bi bi-bar-chart-fill"></i>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
|
|
@ -344,6 +346,14 @@
|
|||
>
|
||||
<i class="bi bi-bandaid-fill"></i>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-info mt-1"
|
||||
on:click={() => { edit_question = new Question({ id_survey: survey.id }) } }
|
||||
title="Ajouter une question"
|
||||
>
|
||||
<i class="bi bi-plus"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -374,7 +384,7 @@
|
|||
class:btn-primary={!next_corrected}
|
||||
class:btn-success={next_corrected}
|
||||
disabled={(question.id === current_question && next_corrected == corrected) || !ws_up}
|
||||
on:click={() => { ws.send('{"action":"new_question", "corrected": ' + next_corrected + ', "timer": 0, "question":' + question.id + '}')} }
|
||||
on:click={() => { ws.send('{"action":"new_question", "corrected": ' + next_corrected + (with_stats?', "stats": {}':'') + ', "timer": 0, "question":' + question.id + '}')} }
|
||||
>
|
||||
<i class="bi bi-play-fill"></i>
|
||||
</button>
|
||||
|
|
@ -382,7 +392,7 @@
|
|||
type="button"
|
||||
class="btn btn-sm btn-danger"
|
||||
disabled={question.id === current_question || !ws_up}
|
||||
on:click={() => { ws.send('{"action":"new_question", "corrected": ' + next_corrected + ', "timer": ' + timer * 1000 + ',"question":' + question.id + '}')} }
|
||||
on:click={() => { ws.send('{"action":"new_question", "corrected": ' + next_corrected + (with_stats?', "stats": {}':'') + ', "timer": ' + timer * 1000 + ',"question":' + question.id + '}')} }
|
||||
>
|
||||
<i class="bi bi-stopwatch-fill"></i>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
import { user } from '$lib/stores/user';
|
||||
import { ToastsStore } from '$lib/stores/toasts';
|
||||
import SurveyBadge from '$lib/components/SurveyBadge.svelte';
|
||||
import CorrectionPieChart from '$lib/components/CorrectionPieChart.svelte';
|
||||
import QuestionForm from '$lib/components/QuestionForm.svelte';
|
||||
import SurveyBadge from '$lib/components/SurveyBadge.svelte';
|
||||
import { getQuestion } from '$lib/questions';
|
||||
|
||||
export let data;
|
||||
|
|
@ -88,7 +89,12 @@
|
|||
if (data.action && data.action == "new_question") {
|
||||
show_question = data.question;
|
||||
survey.corrected = data.corrected;
|
||||
if (data.corrected) {
|
||||
if (data.stats) {
|
||||
stats = data.stats;
|
||||
} else {
|
||||
stats = null;
|
||||
}
|
||||
if(data.corrected) {
|
||||
corrections = data.corrections;
|
||||
} else {
|
||||
corrections = null;
|
||||
|
|
@ -168,6 +174,7 @@
|
|||
}
|
||||
|
||||
let corrections = null;
|
||||
let stats = null;
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
|
@ -207,6 +214,13 @@
|
|||
<span>Chargement d'une nouvelle question …</span>
|
||||
</div>
|
||||
{:then question}
|
||||
{#if stats != null}
|
||||
<CorrectionPieChart
|
||||
{question}
|
||||
proposals={true}
|
||||
data={stats}
|
||||
/>
|
||||
{/if}
|
||||
<QuestionForm
|
||||
{survey}
|
||||
{question}
|
||||
|
|
@ -221,7 +235,7 @@
|
|||
</div>
|
||||
{/if}
|
||||
</QuestionForm>
|
||||
{#if question.kind != 'mcq' && question.kind != 'ucq' && question.kind != 'none'}
|
||||
{#if !survey.corrected && question.kind != 'mcq' && question.kind != 'ucq' && question.kind != 'none'}
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
>
|
||||
|
|
|
|||
Reference in a new issue