Esempio n. 1
0
        void CompleteWordsDictionary()
        {
            IsDictionaryCompleted = true;

            if (PopUp.CurrentWordsDictionary.Count == 0)
            {
                for (int i = 0; i < BlockVolume; i++)
                {
                    PopUp.CurrentWordsDictionary.Add(PopUp.WordsDictionary.ElementAt(i).Key, PopUp.WordsDictionary.ElementAt(i).Value);
                }
            }
            else if (PopUp.CurrentWordsDictionary.Count != 0)
            {
                int currentWordsDictionaryCount = PopUp.CurrentWordsDictionary.Count();
                Model.ReSortCurrentWordsDictionary();
                for (int i = currentWordsDictionaryCount; i < BlockVolume; i++)
                {
                    if (!PopUp.CurrentWordsDictionary.Keys.Contains(PopUp.WordsDictionary.ElementAt(i).Key))
                    {
                        PopUp.CurrentWordsDictionary.Add(PopUp.WordsDictionary.ElementAt(i).Key, PopUp.WordsDictionary.ElementAt(i).Value);
                    }
                }
            }
            AnswerList.Clear();
        }
Esempio n. 2
0
        public void LoadExamPaper(BaobaoBook book)
        {
            ExamPaper paper = null;

            AnswerList.Clear();
            QuestionList.Clear();
            if (book != null)
            {
                if (!_books.ContainsKey(book) || _books[book] == null)
                {
                    string examPaper = book.Name;
                    paper = FileSettingsHelper <ExamPaper> .LoadSetting(Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DataPath, examPaper));

                    _books[book] = paper;
                }
                else
                {
                    paper = _books[book];
                }
            }
            if (paper != null)
            {
                foreach (var question in paper.Questions)
                {
                    QuestionList.Add(question);
                }

                if (QuestionList.Count > 0)
                {
                    _currentQuestionIndex = -1;
                    CurrentQuestionIndex  = 0;
                }
            }
        }
Esempio n. 3
0
 private void ClearTest()
 {
     TaskList.Items.Clear();
     AnswerList.Clear();
     editor.Html      = "";
     currentAnswerNum = 0;
     currentTask      = null;
     currentTaskNum   = 0;
     currentText      = null;
     currentUnit      = null;
 }
Esempio n. 4
0
        public void LoadQuestions()
        {
            var currentQuestion = CurrentQuestion;

            if (currentQuestion != null)
            {
                AnswerList.Clear();
                foreach (var answer in currentQuestion.Answers)
                {
                    AnswerList.Add(answer);
                }
            }
        }
Esempio n. 5
0
        void TranslationClickCommand_Execute(object parameter)
        {
            TranslationClickCanExecute = false;

            List <object> objUserAnswer = parameter as List <object>;
            List <string> userAnswer    = objUserAnswer.Select(s => (string)s).ToList();

            int correctAnswerNumber = 0;

            if (Model.IsTestOpenFirstly)
            {
                foreach (Dictionary <string, bool> listItem in VariantsList)
                {
                    foreach (KeyValuePair <string, bool> translation in listItem)
                    {
                        if (translation.Value == true)
                        {
                            if (" " + userAnswer[0] == translation.Key)
                            {
                                AnswerList.Add(new Dictionary <string, bool> {
                                    { Term + " " + "-" + translation.Key, true }
                                });
                                CorrectAnswersCounter++;
                            }
                            else
                            {
                                AnswerList.Add(new Dictionary <string, bool> {
                                    { Term + " " + "-" + translation.Key, false }
                                });
                                IncorrectAnswersCounter++;
                                if (Model.IsTestOpenFirstly)
                                {
                                    PopUp.CurrentWordsDictionary.Add(Term + " " + "-" + translation.Key, 5);
                                }
                            }
                            goto FillColor;
                        }
                        correctAnswerNumber++;
                    }
                }
            }
            else
            {
                foreach (Dictionary <string, bool> listItem in VariantsList)
                {
                    foreach (KeyValuePair <string, bool> translation in listItem)
                    {
                        if (translation.Value == true)
                        {
                            if (" " + userAnswer[0] == translation.Key)
                            {
                                AnswerList.Add(new Dictionary <string, bool> {
                                    { Term + " " + "-" + translation.Key, true }
                                });
                                CorrectAnswersCounter++;
                            }
                            else
                            {
                                AnswerList.Add(new Dictionary <string, bool> {
                                    { Term + " " + "-" + translation.Key, false }
                                });
                                IncorrectAnswersCounter++;
                            }
                            goto FillColor;
                        }
                        correctAnswerNumber++;
                    }
                }
            }


FillColor:
            switch (userAnswer[1])
            {
            case "TranslationOne":
                TranslationOneColor = Color.FromArgb(255, 128, 0, 0);
                break;

            case "TranslationTwo":
                TranslationTwoColor = Color.FromArgb(255, 128, 0, 0);
                break;

            case "TranslationThree":
                TranslationThreeColor = Color.FromArgb(255, 128, 0, 0);
                break;

            case "TranslationFour":
                TranslationFourColor = Color.FromArgb(255, 128, 0, 0);
                break;
            }
            switch (correctAnswerNumber)
            {
            case 0:
                TranslationOneColor = Color.FromArgb(255, 0, 128, 0);
                break;

            case 1:
                TranslationTwoColor = Color.FromArgb(255, 0, 128, 0);
                break;

            case 2:
                TranslationThreeColor = Color.FromArgb(255, 0, 128, 0);
                break;

            case 3:
                TranslationFourColor = Color.FromArgb(255, 0, 128, 0);
                break;
            }

            if (Model.IsTestOpenFirstly)
            {
                if (IncorrectAnswersCounter < 10)
                {
                    if (InitialFillTestIndex < PopUp.WordsDictionary.Count)
                    {
                        Task.Run(() =>
                        {
                            Thread.Sleep(500);
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                InitialFillTest();
                            });
                        });
                    }
                    else
                    {
                        //StaticConfigProvider.IsTestOpenFirstly = false;
                        CompleteWordsDictionary();
                        Model.IsTestOpenFirstly         = false;
                        IsCountersVisible               = false;
                        StaticConfigProvider.StartTimer = true;
                        Model.FillCurrentTermTranslationLists(PopUp.CurrentWordsDictionary);

                        openWindowService.HideTestWindow();

                        Task.Run(() =>
                        {
                            Thread.Sleep(2000);
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                FillTest();
                            });
                        });
                    }
                }
                else
                {
                    //StaticConfigProvider.IsTestOpenFirstly = false;
                    Model.IsTestOpenFirstly         = false;
                    IsCountersVisible               = false;
                    StaticConfigProvider.StartTimer = true;
                    Model.FillCurrentTermTranslationLists(PopUp.CurrentWordsDictionary);
                    WordsDictionaryChangePriority(AnswerList);
                    AnswerList.Clear();

                    openWindowService.HideTestWindow();

                    Task.Run(() =>
                    {
                        Thread.Sleep(2000);
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            FillTest();
                        });
                    });
                }
            }
            else
            {
                TestAppearCounter++;

                if (TestAppearCounter < BlockVolume)
                {
                    Task.Run(() =>
                    {
                        Thread.Sleep(500);
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            FillTest();
                        });
                    });
                }
                else
                {
                    CurrentWordsDictionaryChangePriority(AnswerList);

                    if (NextWordCounter != 0)
                    {
                        IsCountersVisible = true;
                        AnswerList.Clear();
                        Task.Run(() =>
                        {
                            Thread.Sleep(500);
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                FillTestNext();
                            });
                        });
                    }
                    else
                    {
                        openWindowService.HideTestWindow();
                        StaticConfigProvider.StartTimer = true;

                        IsCountersVisible = false;
                        IsNextWord        = false;

                        AnswerList.Clear();
                        TestAppearCounter = 0;
                        FillTestIndex     = 0;

                        // Delay and next appearing filling
                        Task.Run(() =>
                        {
                            Thread.Sleep(2000);
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                FillTest();
                            });
                        });
                        // Delay and next appearing filling
                    }
                }
            }
        }