settings: Challenge can never ends
This commit is contained in:
parent
d4f69059bf
commit
aad95f1e53
@ -115,11 +115,13 @@ const indextpl = `<!DOCTYPE html>
|
||||
<span>{{"{{ startIn }}"}}</span>"
|
||||
<span class="point">|</span>
|
||||
</span>
|
||||
<span id="hours">{{"{{ time.hours | time }}"}}</span>
|
||||
<span class="point">:</span>
|
||||
<span id="min">{{"{{ time.minutes | time }}"}}</span>
|
||||
<span class="point">:</span>
|
||||
<span id="sec">{{"{{ time.seconds | time }}"}}</span>
|
||||
<span ng-show="settings && settings.end > 0">
|
||||
<span id="hours">{{"{{ time.hours | time }}"}}</span>
|
||||
<span class="point">:</span>
|
||||
<span id="min">{{"{{ time.minutes | time }}"}}</span>
|
||||
<span class="point">:</span>
|
||||
<span id="sec">{{"{{ time.seconds | time }}"}}</span>
|
||||
</span>
|
||||
</span>
|
||||
</nav>
|
||||
|
||||
|
@ -545,7 +545,8 @@ angular.module("FICApp")
|
||||
response.enableExerciceDepend = response.unlockedChallengeDepth >= 0;
|
||||
response.disabledsubmitbutton = response.disablesubmitbutton && response.disablesubmitbutton.length > 0;
|
||||
$rootScope.settings.start = new Date(response.start);
|
||||
$rootScope.settings.end = new Date(response.end);
|
||||
if (response.end) $rootScope.settings.end = new Date(response.end);
|
||||
else $rootScope.settings.end = null;
|
||||
$rootScope.settings.generation = new Date(response.generation);
|
||||
$rootScope.settings.activateTime = new Date(response.activateTime);
|
||||
})
|
||||
@ -581,8 +582,10 @@ angular.module("FICApp")
|
||||
}
|
||||
$scope.saveSettings = function(msg) {
|
||||
if (msg === undefined) { msg = 'New settings saved!'; }
|
||||
var nStart = this.config.start;
|
||||
var nEnd = this.config.end;
|
||||
if (this.config.end == "") this.config.end = null;
|
||||
|
||||
var nStart = this.config.start;
|
||||
var nEnd = this.config.end;
|
||||
var nGen = this.config.generation;
|
||||
var state = this.config.enableExerciceDepend;
|
||||
this.config.unlockedChallengeDepth = (this.config.enableExerciceDepend?this.config.unlockedChallengeDepth:-1)
|
||||
@ -602,7 +605,11 @@ angular.module("FICApp")
|
||||
response.enableExerciceDepend = response.unlockedChallengeDepth >= 0;
|
||||
response.disabledsubmitbutton = response.disablesubmitbutton && response.disablesubmitbutton.length > 0;
|
||||
$rootScope.settings.start = new Date(nStart);
|
||||
$rootScope.settings.end = new Date(nEnd);
|
||||
if (nEnd) {
|
||||
$rootScope.settings.end = new Date(nEnd);
|
||||
} else {
|
||||
$rootScope.settings.end = null;
|
||||
}
|
||||
$rootScope.settings.generation = new Date(nGen);
|
||||
}, function(response) {
|
||||
$scope.addToast('danger', 'An error occurs when saving settings:', response.data.errmsg);
|
||||
|
@ -263,7 +263,7 @@ angular.module("FICApp")
|
||||
}
|
||||
|
||||
function updTime() {
|
||||
if (time && $rootScope.settings) {
|
||||
if (time && $rootScope.settings && $rootScope.settings.end) {
|
||||
var srv_cur = new Date(Date.now() + (time.cu - time.he));
|
||||
|
||||
// Refresh on start/activate time reached
|
||||
|
@ -510,7 +510,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-controller="CountdownController" style="position: fixed; bottom: {{ display.hideCarousel?'0':'109px' }}; right: 0; width: 33vw; overflow: hidden; padding-top: 25px;" ng-if="!display.hideCountdown" ng-cloak>
|
||||
<div ng-controller="CountdownController" style="position: fixed; bottom: {{ display.hideCarousel?'0':'109px' }}; right: 0; width: 33vw; overflow: hidden; padding-top: 25px;" ng-if="!display.hideCountdown && time.end" ng-cloak>
|
||||
<div class="bg-light text-center text-dark" ng-if="time.hours === 0 || time.hours" style="margin-top: -5px; width: inherit; {{ display.customCountdown?'':'box-shadow: white 0px -10px 15px 0px;' }}">
|
||||
<div class="clock" ng-class="{expired: time.expired, end: time.end}" style="font-size: 50px">
|
||||
<span id="hours">{{ time.hours | time }}</span>
|
||||
@ -594,7 +594,7 @@
|
||||
<td>{{ settings.start | date:"HH' h 'mm" }}</td>
|
||||
<td>Début du challenge</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr ng-if="settings.end">
|
||||
<td>{{ settings.end | date:"HH' h 'mm" }}</td>
|
||||
<td>Fin du challenge</td>
|
||||
</tr>
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func WantChoicesHandler(w http.ResponseWriter, r *http.Request, team string, sURL []string) {
|
||||
if time.Now().After(challengeEnd) {
|
||||
if challengeEnd != nil && time.Now().After(*challengeEnd) {
|
||||
http.Error(w, "{\"errmsg\":\"Le challenge est terminé, trop tard !\"}", http.StatusGone)
|
||||
return
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func HintHandler(w http.ResponseWriter, r *http.Request, team string, sURL []string) {
|
||||
if time.Now().After(challengeEnd) {
|
||||
if challengeEnd != nil && time.Now().After(*challengeEnd) {
|
||||
http.Error(w, "{\"errmsg\":\"Le challenge est terminé, trop tard pour un indice !\"}", http.StatusGone)
|
||||
return
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ const resolutiontpl = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Challenge Forensic - Résolution</title>
|
||||
<title>Résolution</title>
|
||||
</head>
|
||||
<body style="margin: 0">
|
||||
<video src="{{.}}" controls width="100%" height="100%"></video>
|
||||
|
@ -12,7 +12,7 @@ var startedFile = "started"
|
||||
|
||||
var touchTimer *time.Timer = nil
|
||||
var challengeStart time.Time
|
||||
var challengeEnd time.Time
|
||||
var challengeEnd *time.Time
|
||||
|
||||
func touchStartedFile() {
|
||||
if fd, err := os.Create(startedFile); err == nil {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func SubmissionHandler(w http.ResponseWriter, r *http.Request, team string, sURL []string) {
|
||||
if time.Now().After(challengeEnd) {
|
||||
if challengeEnd != nil && time.Now().After(*challengeEnd) {
|
||||
http.Error(w, "{\"errmsg\":\"Vous ne pouvez plus soumettre, le challenge est terminé.\"}", http.StatusGone)
|
||||
return
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { settings, time } from '$lib/stores/settings.js';
|
||||
</script>
|
||||
|
||||
{#if $settings}
|
||||
{#if $settings && $settings.end}
|
||||
{#if $settings.end - $settings.start > 0}
|
||||
<div
|
||||
class="clock display-2 text-end text-md-center"
|
||||
@ -69,7 +69,7 @@
|
||||
{:else}
|
||||
<div class="d-flex h-100 justify-content-center align-items-center">
|
||||
<h1 class="display-3 m-0">
|
||||
Challenge forensic
|
||||
{$challengeInfo.title}
|
||||
</h1>
|
||||
</div>
|
||||
{/if}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package fic
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"srs.epita.fr/fic-server/settings"
|
||||
@ -36,6 +37,10 @@ func GenZQDSSessionFile(c *settings.ChallengeInfo, s *settings.Settings) (*Sessi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if s.End == nil {
|
||||
return nil, fmt.Errorf("Please define an end date")
|
||||
}
|
||||
|
||||
var challenges []*ChallengeZQDS
|
||||
|
||||
for _, th := range themes {
|
||||
@ -75,7 +80,7 @@ func GenZQDSSessionFile(c *settings.ChallengeInfo, s *settings.Settings) (*Sessi
|
||||
Rules: c.Rules,
|
||||
YourMission: c.YourMission,
|
||||
Start: s.Start,
|
||||
End: s.End,
|
||||
End: *s.End,
|
||||
Challenges: challenges,
|
||||
}, nil
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ type Settings struct {
|
||||
|
||||
// Start is the departure time (expected or effective).
|
||||
Start time.Time `json:"start"`
|
||||
// End is the expected end time.
|
||||
End time.Time `json:"end"`
|
||||
// End is the expected end time (if empty their is no end-date).
|
||||
End *time.Time `json:"end,omitempty"`
|
||||
// Generation is a value used to regenerate static files.
|
||||
Generation time.Time `json:"generation"`
|
||||
// ActivateTime is the time when the current file should be proceed.
|
||||
|
Loading…
x
Reference in New Issue
Block a user