Fix questions order generator
This commit is contained in:
parent
bce666f7f3
commit
f5a12d2ea4
2 changed files with 12 additions and 10 deletions
|
@ -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++
|
||||
}
|
||||
|
||||
|
|
|
@ -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}}
|
||||
|
|
Loading…
Reference in a new issue