diff --git a/LearningChineseFixed/Pages/Learn.razor b/LearningChineseFixed/Pages/Learn.razor index 1b9584d..9854df0 100644 --- a/LearningChineseFixed/Pages/Learn.razor +++ b/LearningChineseFixed/Pages/Learn.razor @@ -125,14 +125,20 @@ void GenerateQuestion() { - if (DontSkipTheseCChar.Count < 3) throw new Exception("Finished this chunk of CChars"); + if (DontSkipTheseCChar.Count < 5) throw new Exception("Finished this chunk of CChars"); int correctIndex = Random.Shared.Next(0, Answers.Length); for (int i = 0; i < Answers.Length; i++) { bool isCorrect = i == correctIndex; - Answers[i] = new Answer(DontSkipTheseCChar[Random.Shared.Next(0, DontSkipTheseCChar.Count)], isCorrect); + CChar randomCChar; + + repickRandomCChar: + randomCChar = DontSkipTheseCChar[Random.Shared.Next(0, DontSkipTheseCChar.Count)]; + if (Answers.Any(x =>x != null && x.cchar == randomCChar)) goto repickRandomCChar; + + Answers[i] = new Answer(randomCChar, isCorrect); } }