示例#1
0
 public ReadQuestions(Questions selectedQuestion, QuizzingPageViewModel qVm)
 {
     sentences        = Regex.Split(selectedQuestion.Question, @"(?<=[\.!\?])\s+");
     positionAt       = 0;
     sentenceAt       = 0;
     qVm.QuestionText = "";
 }
示例#2
0
        void Next_Clicked(System.Object sender, System.EventArgs e)
        {
            QuizzingPageViewModel qVm = (QuizzingPageViewModel)this.BindingContext;

            qVm.NextQuestion();
            MainButton.IsEnabled = true;
        }
示例#3
0
        void Buzz_Clicked(System.Object sender, System.EventArgs e)
        {
            QuizzingPageViewModel qVm = (QuizzingPageViewModel)this.BindingContext;

            if (qVm.isStarted)
            {
                qVm.isStarted = false;
                qVm.IsReading = true;
                qVm.Read();
            }
            else
            {
                if (qVm.IsReading)
                {
                    qVm.IsReading = false;
                    AnswerEntry.Focus();
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(qVm.AnsweredText))
                    {
                        qVm.CheckAnswer();
                        MainButton.IsEnabled = false;
                    }
                    else
                    {
                        qVm.IsReading = true;
                        AnswerEntry.Unfocus();
                        qVm.Read();
                    }
                }
            }
        }
示例#4
0
        async void Report_Clicked(System.Object sender, System.EventArgs e)
        {
            QuizzingPageViewModel qVm = (QuizzingPageViewModel)this.BindingContext;

            string category = await DisplayActionSheet("What kind of problem is it: ", null, "Never mind", "Question", "Answer", "Alternate", "Other");

            if (!category.Equals("Never mind"))
            {
                Report report = new Report();
                report.userid     = Xamarin.Essentials.Preferences.Get("userid", 243);
                report.questionid = qVm.Question.ID;

                if (category.Equals("Question"))
                {
                    report.category = 0;
                }
                else if (category.Equals("Answer"))
                {
                    report.category = 1;
                }
                else if (category.Equals("Alternate"))
                {
                    report.category = 2;
                }
                else
                {
                    report.category = 3;
                }

                string problem = await DisplayPromptAsync("Problem: ", "Describe the problem in a few words");

                report.problem = problem;

                RestService restService = new RestService();
                var         conn        = Xamarin.Essentials.Connectivity.NetworkAccess;
                bool        result      = false;
                if (conn == Xamarin.Essentials.NetworkAccess.Internet)
                {
                    result = await restService.Report(report);
                }
                if (!result)
                {
                    await DisplayAlert("Error", "There was an error sending your report, please check your connection and try again later", "Okay");
                }
                else
                {
                    await DisplayAlert("Success", "Your report has been logged, we will look into it as soon as possible", "Okay");
                }
            }
        }
示例#5
0
        public async void ReadAQuestion(QuizzingPageViewModel qVm)
        {
            WordsOfQuestions = sentences[sentenceAt].Split(' ');

            qVm.CurrentClue = sentences[sentenceAt];

            for (int i = positionAt; i < WordsOfQuestions.Length; i++)
            {
                if (WordsOfQuestions[i].Length > 7)
                {
                    await Task.Delay(400);
                }
                else
                {
                    await Task.Delay(250);
                }
                qVm.QuestionText += WordsOfQuestions[i] + " ";
                positionAt       += 1;
                if (!qVm.IsReading)
                {
                    break;
                }
            }

            if (qVm.IsReading)
            {
                if (sentenceAt != sentences.Length - 1)
                {
                    sentenceAt += 1;
                    positionAt  = 0;

                    if (sentenceAt / sentences.Length <= 0.3)
                    {
                        qVm.k = 50;
                    }
                    else if (sentenceAt / sentences.Length <= 0.6)
                    {
                        qVm.k = 30;
                    }
                    else
                    {
                        qVm.k = 15;
                    }

                    await Task.Delay(1000);

                    qVm.QuestionText = "";
                    ReadAQuestion(qVm);
                }
                else
                {
                    await Task.Delay(7000);

                    if (!qVm.IsCompleted)
                    {
                        qVm.IsCompleted = true;
                        qVm.NextQuestion();
                    }
                }
            }
        }