New option to allow teams to self reset their progression
This commit is contained in:
parent
a0c34018cf
commit
d6ff46ca7f
9 changed files with 173 additions and 3 deletions
|
|
@ -10,6 +10,7 @@
|
|||
Col,
|
||||
Icon,
|
||||
Row,
|
||||
Spinner,
|
||||
} from 'sveltestrap';
|
||||
|
||||
import ExerciceDownloads from '$lib/components/ExerciceDownloads.svelte';
|
||||
|
|
@ -24,8 +25,29 @@
|
|||
import { current_theme } from '$lib/stores/themes';
|
||||
import { settings } from '$lib/stores/settings';
|
||||
|
||||
import { waitDiff, waitInProgress } from '$lib/wait.js';
|
||||
|
||||
let solved = {};
|
||||
let openResolution = false;
|
||||
|
||||
async function askProgressReset() {
|
||||
waitInProgress.set(true);
|
||||
const response = await fetch(
|
||||
"reset_progress",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {'Accept': 'application/json'},
|
||||
body: JSON.stringify({"eid": $current_exercice.id}),
|
||||
}
|
||||
);
|
||||
if (response.status < 300) {
|
||||
waitDiff(13, $my.exercices[$current_exercice.id]);
|
||||
} else {
|
||||
data = await response.json();
|
||||
waitInProgress.set(false);
|
||||
alert("Quelque chose s'est mal passé : " + data.errmsg);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if $current_exercice}
|
||||
|
|
@ -162,19 +184,29 @@
|
|||
</Row>
|
||||
</Col>
|
||||
{#if $my && $my.team_id}
|
||||
<Col xs="auto">
|
||||
<Col xs="auto" class="d-flex flex-column justify-content-between">
|
||||
{#if $settings.acceptNewIssue}
|
||||
<a href="issues/?eid={$current_exercice.id}" class="float-end btn btn-sm btn-warning">
|
||||
<a href="issues/?eid={$current_exercice.id}" class="btn btn-sm btn-warning">
|
||||
<Icon name="bug" />
|
||||
Rapporter une anomalie sur ce défi
|
||||
</a>
|
||||
{/if}
|
||||
{#if $settings.QAenabled}
|
||||
<a href="qa/exercices/{$current_exercice.id}" class="float-end btn btn-sm btn-info" target="_self">
|
||||
<a href="qa/exercices/{$current_exercice.id}" class="btn btn-sm btn-info" target="_self">
|
||||
<Icon name="bug" />
|
||||
Voir les éléments QA sur ce défi
|
||||
</a>
|
||||
{/if}
|
||||
{#if $settings.wip && $settings.canResetProgress}
|
||||
<Button size="sm" color="dark" on:click={askProgressReset} disabled={!$my.exercices[$current_exercice.id].solved_time || $waitInProgress}>
|
||||
{#if $waitInProgress}
|
||||
<Spinner size="sm" />
|
||||
{:else}
|
||||
<Icon name="skip-start-fill" />
|
||||
{/if}
|
||||
Effacer ma progression sur ce défi
|
||||
</Button>
|
||||
{/if}
|
||||
</Col>
|
||||
{/if}
|
||||
</Row>
|
||||
|
|
|
|||
Reference in a new issue