Skip to content

Commit 1428ebd

Browse files
committed
feat: shuffle questions
1 parent a97b5fe commit 1428ebd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

internal/csv/handler.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ func LoadQuestionsFromCSV(filename string, mode models.QuizMode) ([]models.Quest
147147
}
148148
}
149149

150+
if len(questions) > 1 {
151+
r := rand.New(rand.NewSource(time.Now().UnixNano()))
152+
r.Shuffle(len(questions), func(i, j int) {
153+
questions[i], questions[j] = questions[j], questions[i]
154+
})
155+
}
156+
150157
return questions, nil
151158
}
152159

0 commit comments

Comments
 (0)