backend: Display a message when the exercice is disabled
This commit is contained in:
parent
089e604679
commit
d8462cf58e
30
backend/locked.go
Normal file
30
backend/locked.go
Normal file
@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
var TeamLockedExercices = map[int64]map[string]bool{}
|
||||
|
||||
func treatLocked(pathname string, team *fic.Team) {
|
||||
fd, err := os.Open(pathname)
|
||||
if err != nil {
|
||||
log.Printf("[ERR] Unable to open %q: %s", pathname, err)
|
||||
return
|
||||
}
|
||||
|
||||
var locked map[string]bool
|
||||
|
||||
jdec := json.NewDecoder(fd)
|
||||
if err := jdec.Decode(&locked); err != nil {
|
||||
log.Printf("[ERR] Unable to parse JSON %q: %s", pathname, err)
|
||||
return
|
||||
}
|
||||
|
||||
TeamLockedExercices[team.Id] = locked
|
||||
log.Printf("Team %q (tid=%d) has locked %d exercices", team.Name, team.Id, len(locked))
|
||||
}
|
@ -25,6 +25,7 @@
|
||||
|
||||
export let exercice = { };
|
||||
export let flags = [];
|
||||
export let readonly = false;
|
||||
|
||||
function waitDiff(i) {
|
||||
my.refresh((my) => {
|
||||
@ -224,7 +225,7 @@
|
||||
type="submit"
|
||||
color="danger"
|
||||
id="submission-{exercice.id}"
|
||||
disabled={submitInProgress || $settings.disablesubmitbutton}
|
||||
disabled={submitInProgress || $settings.disablesubmitbutton || readonly}
|
||||
>
|
||||
{#if submitInProgress}
|
||||
<Spinner size="sm" class="me-2" />
|
||||
@ -233,6 +234,8 @@
|
||||
</Button>
|
||||
{#if $settings.disablesubmitbutton}
|
||||
<span class="text-muted">{$settings.disablesubmitbutton}</span>
|
||||
{:else if readonly}
|
||||
<span class="text-muted">Ce défi est désactivé</span>
|
||||
{/if}
|
||||
</div>
|
||||
</form>
|
||||
|
@ -218,6 +218,7 @@
|
||||
exercice={$my.exercices[$current_exercice.id]}
|
||||
bind:forcesolved={solved[$current_exercice.id]}
|
||||
flags={$my.exercices[$current_exercice.id].flags}
|
||||
readonly={$current_exercice.disabled}
|
||||
/>
|
||||
{/if}
|
||||
{/if}
|
||||
|
@ -66,6 +66,7 @@ type myTeamMCQJustifiedChoice struct {
|
||||
}
|
||||
type myTeamExercice struct {
|
||||
ThemeId int64 `json:"theme_id"`
|
||||
Disabled bool `json:"disabled,omitempty"`
|
||||
WIP bool `json:"wip,omitempty"`
|
||||
Statement string `json:"statement"`
|
||||
Overview string `json:"overview,omitempty"`
|
||||
@ -123,6 +124,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
||||
for _, e := range exos {
|
||||
if t == nil || (!e.Disabled && t.HasAccess(e)) {
|
||||
exercice := myTeamExercice{}
|
||||
exercice.Disabled = e.Disabled
|
||||
exercice.WIP = e.WIP
|
||||
exercice.ThemeId = e.IdTheme
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user