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