Justified MCQ are back!
This commit is contained in:
parent
a28f108b8a
commit
960122dfb6
5 changed files with 44 additions and 20 deletions
|
@ -211,6 +211,7 @@
|
|||
/>
|
||||
{:else}
|
||||
<FlagKey
|
||||
class="mb-3"
|
||||
exercice_id={exercice.id}
|
||||
{flag}
|
||||
bind:value={responses.flags[flag.id]}
|
||||
|
|
|
@ -9,8 +9,12 @@
|
|||
import { my } from '$lib/stores/my.js';
|
||||
import { settings } from '$lib/stores/settings.js';
|
||||
|
||||
export { className as class };
|
||||
let className = '';
|
||||
|
||||
export let exercice_id = 0;
|
||||
export let flag = { };
|
||||
export let no_label = false;
|
||||
export let value = "";
|
||||
let values = [""];
|
||||
|
||||
|
@ -99,13 +103,15 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<div class={className + " form-group"}>
|
||||
{#if flag.bonus_gain}
|
||||
<div class={'float-end badge bg-' + (flag.found?'success':'danger')} title={'Ce flag est optionnel, si vous le complétez il vous rapportera ' + flag.bonus_gain + ' points supplémentaires'}>
|
||||
optionnel | {#if flag.bonus_gain > 0}+{/if}{flag.bonus_gain} pts
|
||||
</div>
|
||||
{/if}
|
||||
<label for="sol_{flag.type}{flag.id}_0">{flag.label} :</label>
|
||||
{#if !no_label}
|
||||
<label for="sol_{flag.type}{flag.id}_0">{flag.label} :</label>
|
||||
{/if}
|
||||
{#if flag.found && flag.value}
|
||||
<span>{flag.value}</span>
|
||||
{/if}
|
||||
|
|
|
@ -23,19 +23,27 @@
|
|||
{#if !flag.found || flag.justify}
|
||||
{#each Object.keys(flag.choices) as cid, index}
|
||||
<div class="form-check ms-3">
|
||||
<input class="form-check-input" type="checkbox" id="mcq_{flag.id}_{cid}" bind:checked={values[Number(cid)]} disabled={flag.found}>
|
||||
<label class="form-check-label" for="mcq_{flag.id}_{cid}">
|
||||
{#if typeof flag.choices[cid] == "Object"}
|
||||
{flag.choices[cid].label}
|
||||
{:else}
|
||||
{flag.choices[cid]}
|
||||
{#if typeof flag.choices[cid] != "object"}
|
||||
<input class="form-check-input" type="checkbox" id="mcq_{flag.id}_{cid}" bind:checked={values[Number(cid)]} disabled={flag.found || flag.part_solved}>
|
||||
<label class="form-check-label" for="mcq_{flag.id}_{cid}">
|
||||
{flag.choices[cid]}{#if values[Number(cid)] && flag.justify} :{/if}
|
||||
</label>
|
||||
{#if values[Number(cid)] && flag.justify}
|
||||
<FlagKey
|
||||
class="mb-3"
|
||||
{exercice_id}
|
||||
flag={{id: cid, placeholder: "Flag correspondant"}}
|
||||
no_label={true}
|
||||
bind:value={justifications[cid]}
|
||||
/>
|
||||
{/if}
|
||||
</label>
|
||||
{#if values[Number(cid)] && flag.justify && (!flag.choices[cid].justification || !flag.choices[cid].justification.solved)}
|
||||
{:else}
|
||||
<input class="form-check-input" type="checkbox" id="mcq_{flag.id}_{cid}" checked disabled>
|
||||
<FlagKey
|
||||
class={flag.choices[cid].justification.found?"":"mb-3"}
|
||||
{exercice_id}
|
||||
flag={flag.choices[cid].justification}
|
||||
bind:values={justifications[flag.choices[cid].justification.id]}
|
||||
bind:value={justifications[cid]}
|
||||
/>
|
||||
{/if}
|
||||
{#if flag.choices[cid].justification && flag.choices[cid].justification.solved}
|
||||
|
|
Reference in a new issue