Exemplo n.º 1
0
 /// <summary>
 /// evaluate textual or single choice answer
 /// </summary>
 /// <param name="answer">answer to evaluate</param>
 /// <returns>calculated number of points for the answer</returns>
 private int EvaluateTextualOrSingleChoiceAnswer(TestSubmissionAnswer answer)
 {
     if (answer.Text == answer.Question.CorrectAnswer)
     {
         return(answer.Question.Points);
     }
     else
     {
         return(0);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// evaluate answer with multiple answer choices
        /// </summary>
        /// <param name="answer">answer to evaluate</param>
        /// <returns>calculated number of points for the answer</returns>
        private int EvaluateMultipleChoiceAnswer(TestSubmissionAnswer answer)
        {
            var correctAnswers     = QuestionWithChoicesTools.GetCorrectAnswersLetters(answer.Question);
            var submittedAnswers   = QuestionWithChoicesTools.GetSubmittedAnswersLetters(answer);
            var allPossibleAnswers = QuestionWithChoicesTools.GetAnswerChoicesLetters(answer.Question);

            int correct = 0;

            foreach (var possibleAnswer in allPossibleAnswers)
            {
                if (IsAnswerLetterCorrect(possibleAnswer, correctAnswers, submittedAnswers))
                {
                    correct++;
                }
            }

            double correctRatio = (double)correct / allPossibleAnswers.Length;

            return((int)Math.Round(correctRatio * answer.Question.Points));
        }
 /// <inheritdoc/>
 public void UpdateAnswerProperties(TestSubmissionAnswer answerToEvaluate, int updatedPoints, string updatedComment)
 {
     answerToEvaluate.Points  = updatedPoints;
     answerToEvaluate.Comment = updatedComment;
 }
 /// <summary>
 /// get letters of all submitted answer choices in the <paramref name="answer"/>
 /// </summary>
 /// <param name="answer">given answer</param>
 /// <returns></returns>
 public static string[] GetSubmittedAnswersLetters(TestSubmissionAnswer answer)
 {
     return(answer.Text.Split(answerLetterDelimiter, StringSplitOptions.RemoveEmptyEntries).TrimAll());
 }
Exemplo n.º 5
0
 public QuestionWithChoicesToolsTests()
 {
     exampleQuestion = new TestQuestion(1, string.Empty, $"A{ald} B", 1, QuestionType.MultipleChoice);
     exampleAnswer   = new TestSubmissionAnswer(exampleQuestion, $"A{ald}C");
 }