Fix countdown and reset response StartTime when len(SingleResponses) is zero
This commit is contained in:
parent
52b572dc25
commit
eaa9c405aa
4 changed files with 28 additions and 7 deletions
10
dist/main.bundle.js
vendored
10
dist/main.bundle.js
vendored
File diff suppressed because one or more lines are too long
|
@ -240,7 +240,7 @@ func (model *Response) Update(db *Database, args map[string]string, w http.Respo
|
|||
}
|
||||
|
||||
// Check if the contest is still active
|
||||
if !response.(*Response).IsActive() {
|
||||
if isParticipant(r) && !response.(*Response).IsActive() {
|
||||
return nil, errors.OutOfTime
|
||||
}
|
||||
|
||||
|
@ -251,6 +251,14 @@ func (model *Response) Update(db *Database, args map[string]string, w http.Respo
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// If there aren't single responses then participant
|
||||
// response Starttime is resetted.
|
||||
if isAdministrator(r) {
|
||||
if len(response.(*Response).SingleResponses) == 0 {
|
||||
response.(*Response).StartTime = time.Time{}
|
||||
}
|
||||
}
|
||||
|
||||
WriteUpdater(r, response.(*Response))
|
||||
|
||||
_, err = SaveResponse(db, response)
|
||||
|
|
|
@ -10,7 +10,13 @@ $(function () {
|
|||
} else {
|
||||
timeleft = 0;
|
||||
}
|
||||
$("#timeleft").html(timeleft)
|
||||
|
||||
$("#timeleft").html(timeleft);
|
||||
|
||||
var minutes = Math.floor(timeleft/60);
|
||||
var seconds = timeleft % 60;
|
||||
|
||||
$("#timeleft_view").html(minutes+":"+seconds.toString().padStart(2, "0"));
|
||||
}, 1000);
|
||||
|
||||
$("#reloadCaptcha").on("click",function(eventObject) {
|
||||
|
|
|
@ -71,7 +71,8 @@
|
|||
<dt>Gara</dt><dd>{{.Data.Contest}}</dd>
|
||||
<dt>Partecipante</dt><dd>{{.Data.Participant}}</dd>
|
||||
{{- if $isParticipant -}}
|
||||
<dt>Tempo rimanente</dt>{{if .Data.TimeLeft}}<dd><span id="timeleft">{{.Data.TimeLeft.Seconds|toInt}}</span> secondi rimanenti</dd>{{else}}<dd>La gara è sempre attiva</dd>{{end}}
|
||||
<span id="timeleft" style="display: none">{{.Data.TimeLeft.Seconds|toInt}}</span>
|
||||
<dt>Tempo rimanente</dt>{{if .Data.TimeLeft}}<dd><span id="timeleft_view"></span> minuti rimanenti</dd>{{else}}<dd>La gara è sempre attiva</dd>{{end}}
|
||||
{{- end -}}
|
||||
</dl>
|
||||
<button type="submit" class="btn btn-primary" form="{{$form}}">Salva</button>
|
||||
|
|
Loading…
Reference in a new issue