Example #1
0
 private bool AudioCanBePlayedBeforeAnswer(AnswerTypeEnum answerType)
 {
     if (Mode == ModeEnum.Spelling ||
         (AppSettings.Learning.PlayPronuncation.BeforeAnswer && answerType == AnswerTypeEnum.Translations))
     {
         return(true);
     }
     return(false);
 }
Example #2
0
 private bool AudioCanBePlayedAfterAnswer(AnswerTypeEnum answerType)
 {
     if (Mode != ModeEnum.Spelling &&
         AppSettings.Learning.PlayPronuncation.AfterAnswer &&
         answerType == AnswerTypeEnum.Words)
     {
         return(true);
     }
     return(false);
 }
Example #3
0
 public QuestionInfo(
     Entry entry,
     QuestionTypeEnum questionType,
     AnswerTypeEnum answerType,
     List <string>?possibleAnswers)
 {
     Entry           = entry;
     QuestionType    = questionType;
     AnswerType      = answerType;
     PossibleAnswers = possibleAnswers;
 }
Example #4
0
        public void CompareQuestionInfo_EqualObjects_ReturnsTrue(
            Entry entry,
            QuestionTypeEnum questionType,
            AnswerTypeEnum modeType,
            List <string>?possibleAnswers1,
            List <string>?possibleAnswers2)
        {
            // Arrange
            var questionInfo1 = new QuestionInfo(entry, questionType, modeType, possibleAnswers1);
            var questionInfo2 = new QuestionInfo(entry, questionType, modeType, possibleAnswers2);

            // Act
            bool result = questionInfo1.Equals(questionInfo2);

            // Assert
            Assert.True(result);
        }
        public string GetDetail(CSVExportData.VoterAnswersRow detail, AnswerTypeEnum answerType)
        {
            switch (ddlAnswer.SelectedValue)
            {
                case "Answer": return answerType == AnswerTypeEnum.SelectionTextType ?
                    (detail.IsAnswerAnswerTextNull() ? string.Empty : detail.AnswerAnswerText) :
                   (detail.IsAnswerTextNull() ? string.Empty : detail.AnswerText);

                case "AnswerDisplayOrderNumber":
                    if (isTextAnswer(detail.AnswerTypeId))
                        return detail.IsAnswerTextNull() ? string.Empty : detail.AnswerText;
                    else
                        return answerType == AnswerTypeEnum.SelectionOtherType ?
                            (detail.IsAnswerTextNull() ? string.Empty : detail.AnswerText) :
                            detail.AnswerDisplayOrder.ToString();

                case "AnswerID":
                    if (isTextAnswer(detail.IsAnswerTypeIdNull()?0:detail.AnswerTypeId))
                        return detail.IsAnswerTextNull() ? string.Empty : detail.AnswerText;
                    else
                        return answerType == AnswerTypeEnum.SelectionTextType ?
                            (detail.IsAnswerIdAliasNull() ?
                            (detail.IsAnswerAnswerTextNull() ? string.Empty : detail.AnswerAnswerText) : detail.AnswerIdAlias) :
                            (detail.IsAnswerAnswerTextNull() ? string.Empty : detail.AnswerAnswerText);

                case "AnswerAlias":
                    if (isTextAnswer(detail.AnswerTypeId))
                        return detail.IsAnswerTextNull() ? string.Empty : detail.AnswerText;
                    else
                        return answerType == AnswerTypeEnum.SelectionTextType ?
                            (detail.IsAnswerAliasNull() ? (detail.IsAnswerAnswerTextNull() ? string.Empty : detail.AnswerAnswerText)
                            : detail.AnswerAlias) :
                        (detail.IsAnswerAnswerTextNull() ? string.Empty : detail.AnswerAnswerText);

                case "AnswerIdAlias":
                    if (isTextAnswer(detail.AnswerTypeId))
                        return detail.IsAnswerTextNull() ? string.Empty : detail.AnswerText;
                    else
                        return answerType == AnswerTypeEnum.SelectionTextType ?
                                                (detail.IsAnswerIdAliasNull() ? detail.AnswerAnswerText : detail.AnswerIdAlias) + " " +
                                                (detail.IsAnswerAliasNull() ? string.Empty : detail.AnswerAlias) :
                      (detail.IsAnswerAnswerTextNull() ? string.Empty : detail.AnswerAnswerText);

                default: return "Invalid DDl Value";
            }
        }
Example #6
0
 private void PlayPronunciationAudio(List <string> words, WhenEnum whenWasInvoked, AnswerTypeEnum answerType)
 {
     if (whenWasInvoked == WhenEnum.BeforeAnswer && !AudioCanBePlayedBeforeAnswer(answerType))
     {
         return;
     }
     if (whenWasInvoked == WhenEnum.AfterAnswer && !AudioCanBePlayedAfterAnswer(answerType))
     {
         return;
     }
     if (AppSettings.PronunciationApi == null)
     {
         return;
     }
     _ = PronunciationService.PlayAsync(words.ToList())
         .ContinueWith(
         x => PronunciationLogger.LogError(
             x.Exception, "An unexpected error occured in pronunciation service."
             ),
         TaskContinuationOptions.OnlyOnFaulted
         );
 }