frontend: Mark bad submissions as invalid
This commit is contained in:
parent
bf2be00f15
commit
f841d9c11c
3 changed files with 25 additions and 5 deletions
|
@ -28,11 +28,13 @@
|
||||||
export let readonly = false;
|
export let readonly = false;
|
||||||
|
|
||||||
export let forcesolved = false;
|
export let forcesolved = false;
|
||||||
|
let last_submission = { };
|
||||||
let responses = { };
|
let responses = { };
|
||||||
async function submitFlags() {
|
async function submitFlags() {
|
||||||
waitInProgress.set(true);
|
waitInProgress.set(true);
|
||||||
sberr = "";
|
sberr = "";
|
||||||
message = "";
|
message = "";
|
||||||
|
last_submission = JSON.parse(JSON.stringify(responses));
|
||||||
|
|
||||||
if ($my && $my.team_id === 0) {
|
if ($my && $my.team_id === 0) {
|
||||||
let allGoodResponse = true;
|
let allGoodResponse = true;
|
||||||
|
@ -119,6 +121,11 @@
|
||||||
mcqs: { },
|
mcqs: { },
|
||||||
justifications: { },
|
justifications: { },
|
||||||
};
|
};
|
||||||
|
last_submission = {
|
||||||
|
flags: { },
|
||||||
|
mcqs: { },
|
||||||
|
justifications: { },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let last_exercice = null;
|
let last_exercice = null;
|
||||||
|
@ -152,10 +159,12 @@
|
||||||
{#if exercice.tries || exercice.solved_time || exercice.submitted || sberr || $timeouted}
|
{#if exercice.tries || exercice.solved_time || exercice.submitted || sberr || $timeouted}
|
||||||
<ListGroup class="border-dark">
|
<ListGroup class="border-dark">
|
||||||
{#if exercice.solved_time || exercice.tries}
|
{#if exercice.solved_time || exercice.tries}
|
||||||
<ListGroupItem class="text-warning rounded-0">
|
<div class="d-flex align-items-center">
|
||||||
{#if exercice.tries > 0}{exercice.tries} {exercice.tries==1?"tentative effectuée":"tentatives effectuées"}.{/if}
|
<ListGroupItem class="rounded-0 {$waitInProgress?'text-secondary':'text-warning'}">
|
||||||
Dernière solution envoyée à <DateFormat date={exercice.solved_time} />.
|
{#if exercice.tries > 0}{exercice.tries} {exercice.tries==1?"tentative effectuée":"tentatives effectuées"}.{/if}
|
||||||
</ListGroupItem>
|
Dernière solution envoyée le <span class:placeholder={$waitInProgress} class:placeholder-glow={$waitInProgress}><DateFormat date={exercice.solved_time} /></span>.
|
||||||
|
</ListGroupItem>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if exercice.solve_dist}
|
{#if exercice.solve_dist}
|
||||||
<ListGroupItem class="rounded-0">
|
<ListGroupItem class="rounded-0">
|
||||||
|
@ -191,6 +200,7 @@
|
||||||
<FlagMCQ
|
<FlagMCQ
|
||||||
exercice_id={exercice.id}
|
exercice_id={exercice.id}
|
||||||
{flag}
|
{flag}
|
||||||
|
previous_values={$waitInProgress ? { justifications: { }, mcqs: { } } : last_submission}
|
||||||
bind:values={responses.mcqs}
|
bind:values={responses.mcqs}
|
||||||
bind:justifications={responses.justifications}
|
bind:justifications={responses.justifications}
|
||||||
/>
|
/>
|
||||||
|
@ -199,6 +209,7 @@
|
||||||
class="mb-3"
|
class="mb-3"
|
||||||
exercice_id={exercice.id}
|
exercice_id={exercice.id}
|
||||||
{flag}
|
{flag}
|
||||||
|
previous_value={$waitInProgress ? "" : last_submission.flags[flag.id]}
|
||||||
bind:value={responses.flags[flag.id]}
|
bind:value={responses.flags[flag.id]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
export let exercice_id = 0;
|
export let exercice_id = 0;
|
||||||
export let flag = { };
|
export let flag = { };
|
||||||
export let no_label = false;
|
export let no_label = false;
|
||||||
|
export let previous_value = "";
|
||||||
export let value = "";
|
export let value = "";
|
||||||
let values = [""];
|
let values = [""];
|
||||||
|
|
||||||
|
@ -141,6 +142,7 @@
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
class="form-control flag"
|
class="form-control flag"
|
||||||
|
class:is-invalid={previous_value && previous_value == value}
|
||||||
id="sol_{flag.type}{flag.id}_{index}"
|
id="sol_{flag.type}{flag.id}_{index}"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
bind:value={values[index]}
|
bind:value={values[index]}
|
||||||
|
@ -154,6 +156,7 @@
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="form-control flag"
|
class="form-control flag"
|
||||||
|
class:is-invalid={previous_value && previous_value == value}
|
||||||
id="sol_{flag.type}{flag.id}_{index}"
|
id="sol_{flag.type}{flag.id}_{index}"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
bind:value={values[index]}
|
bind:value={values[index]}
|
||||||
|
@ -164,6 +167,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
<textarea
|
<textarea
|
||||||
class="form-control flag"
|
class="form-control flag"
|
||||||
|
class:is-invalid={previous_value && previous_value == value}
|
||||||
id="sol_{flag.type}{flag.id}_{index}"
|
id="sol_{flag.type}{flag.id}_{index}"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
bind:value={values[index]}
|
bind:value={values[index]}
|
||||||
|
@ -208,6 +212,7 @@
|
||||||
value={l}
|
value={l}
|
||||||
bind:group={values[index]}
|
bind:group={values[index]}
|
||||||
class="form-check-input"
|
class="form-check-input"
|
||||||
|
class:is-invalid={previous_value && previous_value == value}
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
class="form-check-label"
|
class="form-check-label"
|
||||||
|
@ -220,6 +225,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
<select
|
<select
|
||||||
class="form-select"
|
class="form-select"
|
||||||
|
class:is-invalid={previous_value && previous_value == value}
|
||||||
id="sol_{flag.type}{flag.id}_{index}"
|
id="sol_{flag.type}{flag.id}_{index}"
|
||||||
bind:value={values[index]}
|
bind:value={values[index]}
|
||||||
>
|
>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
export let exercice_id = 0;
|
export let exercice_id = 0;
|
||||||
export let flag = { };
|
export let flag = { };
|
||||||
|
export let previous_values = { justifications: { }, mcqs: { } };
|
||||||
export let values = { };
|
export let values = { };
|
||||||
export let justifications = { };
|
export let justifications = { };
|
||||||
</script>
|
</script>
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
{#each Object.keys(flag.choices) as cid, index}
|
{#each Object.keys(flag.choices) as cid, index}
|
||||||
<div class="form-check ms-3">
|
<div class="form-check ms-3">
|
||||||
{#if typeof flag.choices[cid] != "object"}
|
{#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}>
|
<input class="form-check-input" class:is-invalid={previous_values.mcqs && Object.keys(flag.choices).reduce((acc, cur) => acc + (previous_values.mcqs[Number(cur)] !== undefined ? 1 : 0), 0) > 0 && Object.keys(flag.choices).reduce((acc, cur) => acc && previous_values.mcqs[Number(cur)] == values[Number(cur)], true)} 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}">
|
<label class="form-check-label" for="mcq_{flag.id}_{cid}">
|
||||||
{flag.choices[cid]}{#if values[Number(cid)] && flag.justify} :{/if}
|
{flag.choices[cid]}{#if values[Number(cid)] && flag.justify} :{/if}
|
||||||
</label>
|
</label>
|
||||||
|
@ -34,6 +35,7 @@
|
||||||
{exercice_id}
|
{exercice_id}
|
||||||
flag={{id: cid, placeholder: "Flag correspondant"}}
|
flag={{id: cid, placeholder: "Flag correspondant"}}
|
||||||
no_label={true}
|
no_label={true}
|
||||||
|
previous_value={previous_values.justifications && previous_values.justifications[cid]}
|
||||||
bind:value={justifications[cid]}
|
bind:value={justifications[cid]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -43,6 +45,7 @@
|
||||||
class={flag.choices[cid].justification.found?"":"mb-3"}
|
class={flag.choices[cid].justification.found?"":"mb-3"}
|
||||||
{exercice_id}
|
{exercice_id}
|
||||||
flag={flag.choices[cid].justification}
|
flag={flag.choices[cid].justification}
|
||||||
|
previous_value={previous_values.justifications[cid]}
|
||||||
bind:value={justifications[cid]}
|
bind:value={justifications[cid]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Reference in a new issue