Now it doesn't show the same CChar pinyin in selection
This commit is contained in:
parent
dab3cb47b7
commit
2a49117995
|
@ -125,14 +125,20 @@
|
||||||
|
|
||||||
void GenerateQuestion()
|
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);
|
int correctIndex = Random.Shared.Next(0, Answers.Length);
|
||||||
|
|
||||||
for (int i = 0; i < Answers.Length; i++)
|
for (int i = 0; i < Answers.Length; i++)
|
||||||
{
|
{
|
||||||
bool isCorrect = i == correctIndex;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue