Fix questions order generator

This commit is contained in:
Andrea Fazzi 2019-12-18 10:46:39 +01:00
parent bce666f7f3
commit f5a12d2ea4
2 changed files with 12 additions and 10 deletions

View file

@ -193,13 +193,13 @@ func (c *Contest) generateQuestionsOrder() (string, error) {
rand.Seed(time.Now().UnixNano())
for count < len(questions) {
number := rand.Intn(len(questions))
log.Println(count, number)
if generated[number] {
position := rand.Intn(len(questions))
if generated[position] {
continue
}
generated[number] = true
order = append(order, strconv.Itoa(number))
generated[position] = true
order = append(order, strconv.Itoa(int(questions[position].ID)))
count++
}

View file

@ -1,9 +1,11 @@
{{ define "content" }}
<div class="container">
{{$admin := (.Claims|isAdmin)}}
{{$update := .Options.Get "update"}}
{{if $admin}}
{{$isAdmin := .Claims|isAdmin}}
{{$isParticipant := .Claims|isParticipant}}
{{$update := .Options.Get "update"}}
<div class="container">
{{if $isAdmin}}
{{if $update}}
@ -37,7 +39,7 @@
</div>
{{end}}
{{if $admin}}
{{if $isAdmin}}
{{$options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Response" } `}}
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}