sync: randomize imports: themes order, MCQ and UCQ choices

This commit is contained in:
nemunaire 2018-12-02 05:05:59 +01:00
commit abd7fc6bef
3 changed files with 24 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package sync
import (
"fmt"
"math/rand"
"path"
"unicode"
@ -93,6 +94,13 @@ func SyncExerciceFlags(i Importer, exercice fic.Exercice) (errs []string) {
// Import choices
hasOne := false
if !flag.NoShuffle {
rand.Shuffle(len(flag.Choice), func(i, j int) {
flag.Choice[i], flag.Choice[j] = flag.Choice[j], flag.Choice[i]
})
}
for cid, choice := range flag.Choice {
if len(choice.Label) == 0 {
choice.Label = choice.Value
@ -121,6 +129,13 @@ func SyncExerciceFlags(i Importer, exercice fic.Exercice) (errs []string) {
} else {
hasOne := false
isJustified := false
if !quest.NoShuffle {
rand.Shuffle(len(quest.Choice), func(i, j int) {
quest.Choice[i], quest.Choice[j] = quest.Choice[j], quest.Choice[i]
})
}
for cid, choice := range quest.Choice {
var val bool
var justify string