From 1a0c59af3a6b53f1150a3f4c9fc0a7e0d28ff178 Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Thu, 29 Jun 2023 13:19:27 +0200 Subject: [PATCH] Now resets and kicks user back to chunk selection if the chunk has been learnt --- LearningChineseFixed/Pages/Learn.razor | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/LearningChineseFixed/Pages/Learn.razor b/LearningChineseFixed/Pages/Learn.razor index 9854df0..1b8e74f 100644 --- a/LearningChineseFixed/Pages/Learn.razor +++ b/LearningChineseFixed/Pages/Learn.razor @@ -125,7 +125,11 @@ void GenerateQuestion() { - if (DontSkipTheseCChar.Count < 5) throw new Exception("Finished this chunk of CChars"); + if (DontSkipTheseCChar.Count < 5) + { + FinishAndKickBackToLearn(); + return; + } int correctIndex = Random.Shared.Next(0, Answers.Length); @@ -142,6 +146,19 @@ } } + void FinishAndKickBackToLearn() + { + Snackbar.Add("Congrats, you have compleated this chunk!", Severity.Success, config => + { + config.RequireInteraction = true; + config.CloseAfterNavigation = false; + }); + Program.UpdateUiEvent -= OnUiUpdate; + Program.CCharsLeft = 0; + + navigator.NavigateTo(""); + } + async void Submit() { bool isCorrect = Answers.Any(x => x.isCorrect && x.isSelected);