コード例 #1
0
        private string GetText(Vocable vocable, Language language)
        {
            var text = vocable.Words
                       .Where(x => x.Language == language)
                       .Select(x => x.Text)
                       .Shuffle(_shuffleAlgorithm)
                       .First();

            return(text);
        }
コード例 #2
0
        private Question CreateQuestion(Vocable vocable)
        {
            var text          = GetTextToTranslate(vocable);
            var correctAnswer = GetTranslation(vocable);
            var falseAnswers  = GetIncorrectTranslations(vocable);

            var question = new Question(_shuffleAlgorithm, text, correctAnswer, falseAnswers);

            return(question);
        }
コード例 #3
0
        private IEnumerable <string> GetIncorrectTranslations(Vocable vocableToTranslate)
        {
            var falseTranslationsCandidates = _vocabulary.Vocables
                                              .Where(x => x != vocableToTranslate)
                                              .Shuffle(_shuffleAlgorithm)
                                              .Take(3)
                                              .Select(x => GetText(x, TranslateToLanguage))
                                              .ToList();

            return(falseTranslationsCandidates);
        }
コード例 #4
0
 private string GetTranslation(Vocable vocable)
 {
     return(GetText(vocable, TranslateToLanguage));
 }
コード例 #5
0
 private string GetTextToTranslate(Vocable vocable)
 {
     return(GetText(vocable, TranslateFromLanguage));
 }