Esempio n. 1
0
        public void CheckIfNewProblem(object sender, EventArgs e)
        {
            Boolean generateNewProblem = false;

            //Check if answer is correct
            if (MathProblems.Peek().IsSolutionCorrect(this.ProblemContentPage.Solution))
            {
                quiz.WasPreviousAnswerCorrect = true;
                quiz.NumberOfCorrectAnswers++;
            }
            else
            {
                quiz.WasPreviousAnswerCorrect = false;
            }
            //else
            //{
            //    if(ProblemGenerator.rng.Next(0,2) == 1)
            //    {
            //        generateNewProblem = true;
            //    }
            //}

            //Remove currently answered problem
            MathProblems.Dequeue();

            //if(generateNewProblem)
            //{
            //    var newProblemQueue = quiz.GenerateMathProblems(1);
            //    MathProblems.Enqueue(newProblemQueue.Dequeue());
            //    quiz.NumberOfGeneratedProblems++;
            //}
            UpdateProblemPageWithProblem();
        }
Esempio n. 2
0
        async private void UpdateProblemPageWithProblem()
        {
            if (MathProblems.Count != 0)
            {
                //Update labels or new problem
                CurrentProblemNumber++;

                //if (Navigation.ModalStack.Count > 0)
                //{
                //    await Navigation.PopModalAsync();
                //}
                this.ProblemContentPage.ProblemNumber = CurrentProblemNumber.ToString();
                this.ProblemContentPage.Problem       = MathProblems.Peek().Problem;
                this.ProblemContentPage.Hints         = MathProblems.Peek().Hints;
                string status = String.Empty;
                if (CurrentProblemNumber == 1)
                {
                    status = @"N/A";
                }
                else
                {
                    status = @"";
                }


                this.ProblemContentPage.UpdateProblemPage(status);

                if (Navigation.ModalStack.Count == 0)
                {
                    await Navigation.PushModalAsync(this.ProblemContentPage);
                }
                //  this.ProblemContentPage.SolutionTextField.Focus();
            }
            else
            {
                //Dismiss problem page and show the results page
                await Navigation.PopModalAsync();

                string pluralizeProblemString = String.Empty;
                if (quiz.NumberOfGeneratedProblems > 1)
                {
                    pluralizeProblemString =
                        Convert.ToString(quiz.NumberOfGeneratedProblems) +
                        " problems were generated during this quiz.";
                }
                else if (quiz.NumberOfGeneratedProblems == 1)
                {
                    pluralizeProblemString = "1 problem was generated for this quiz.";
                }
                else
                {
                    pluralizeProblemString = "No extra problems were generated for this quiz.";
                }
                this.ResultsContentPage.ResultsSummary =
                    $"You answered {quiz.NumberOfCorrectAnswers} out of {quiz.NumberOfProblems} problems correctly!";
                this.ResultsContentPage.NumberOfGeneratedProblems = pluralizeProblemString;

                var recommendation = quiz.GetRecommendation();
                this.ResultsContentPage.Recommendation = recommendation;
                this.ResultsContentPage.UpdatePage();

                //Clear this text so that when the modal view is switching
                //the user does not breifly see previous test score
                this.PreviousSessionLabel.Text = String.Empty;
                this.RecommendationLabel.Text  = String.Empty;

                await Navigation.PushModalAsync(this.ResultsContentPage);

                if (quiz.NumberOfCorrectAnswers == quiz.NumberOfProblems)
                {
                    this.PreviousSessionLabel.TextColor = Color.Blue;
                }
                else
                {
                    this.PreviousSessionLabel.TextColor = Color.Red;
                }
                this.PreviousSessionLabel.Text =
                    $"Last Session Results: {quiz.NumberOfCorrectAnswers} correct out of {quiz.NumberOfProblems}";
                this.RecommendationLabel.Text = recommendation;
            }
        }