/// <summary>
        /// Grades the question submission.
        /// </summary>
        private ScoredQuestionResult GradeSubmission(QuestionSubmission submission)
        {
            var multSubmission = submission as MultipleChoiceQuestionSubmission;

            if (multSubmission == null)
            {
                throw new ArgumentException("Invalid submission type", nameof(submission));
            }

            int numCorrectAnswers = Question.Choices.Count
                                    (
                choice => choice.Correct == (multSubmission.SelectedChoices?.Contains(choice.Value) ?? false)
                                    );

            var result = new MultipleChoiceQuestionResult
                         (
                numCorrectAnswers == Question.Choices.Count
                         );

            return(new ScoredQuestionResult
                   (
                       result,
                       Question.AllowPartialCredit
                                        ? (numCorrectAnswers * 1.0) / Question.Choices.Count
                                        : (numCorrectAnswers == Question.Choices.Count) ? 1.0 : 0.0
                   ));
        }
        public async Task GetSubmissionResultAsync_SubmissionFound_ReturnsCorrectResult()
        {
            var user = new User();
            var userQuestionSubmission = new UserQuestionSubmission()
            {
                DateSubmitted      = SubmissionDate,
                SubmissionContents = "Contents"
            };

            var store = GetUserQuestionDataStore
                        (
                assignmentQuestionId: 1,
                assignmentQuestionName: "Question 1",
                user: user,
                numAttempts: 1,
                numAttemptsRemaining: 1,
                generated: true,
                seed: 12345,
                questionPoints: 1.0,
                pastSubmissions: Collections.CreateList
                (
                    userQuestionSubmission
                )
                        );

            var status           = CreateUserQuestionStatus();
            var statusCalculator = GetMockQuestionStatusCalculator(store, status);
            var submission       = CreateQuestionSubmission(assignmentQuestionId: 1);
            var serializer       = GetMockJsonSerializer("Contents", submission);
            var resolvedQuestion = new MultipleChoiceQuestion();
            var resolverFactory  = GetMockQuestionResolverFactory
                                   (
                store,
                resolvedQuestion,
                submission: userQuestionSubmission
                                   );

            var questionResult = new MultipleChoiceQuestionResult(correct: true);
            var graderFactory  = GetMockQuestionGraderFactory
                                 (
                resolvedQuestion,
                submission,
                new ScoredQuestionResult(questionResult, score: 0.5)
                                 );

            var scoreCalculator = GetMockQuestionScoreCalculator
                                  (
                userQuestionSubmission,
                DueDate,
                questionPoints: 1.0,
                scoreWithoutLateness: 1.0,
                scoreWithLateness: 0.9
                                  );

            var questionSolver = GetQuestionSolver
                                 (
                questionResolverFactory: resolverFactory,
                questionGraderFactory: graderFactory,
                questionStatusCalculator: statusCalculator,
                questionScoreCalculator: scoreCalculator,
                jsonSerializer: serializer
                                 );

            var result = await questionSolver.GetSubmissionResultAsync
                         (
                store,
                assignmentQuestionId : 1,
                submissionDate : SubmissionDate,
                dueDate : DueDate
                         );

            Assert.Equal(1, result.QuestionSubmitted.AssignmentQuestionId);
            Assert.Equal("Question 1", result.QuestionSubmitted.Name);
            Assert.Equal(resolvedQuestion, result.QuestionSubmitted.Question);
            Assert.Equal(12345, result.QuestionSubmitted.Seed);
            Assert.Equal(user, result.QuestionSubmitted.User);
            Assert.Equal(submission, result.QuestionSubmitted.LastSubmission);
            Assert.False(result.QuestionSubmitted.Interactive);
            Assert.Equal(status, result.QuestionSubmitted.Status);
            Assert.Equal(1, result.QuestionSubmitted.PastSubmissions.Count);
            Assert.Equal(SubmissionDate, result.QuestionSubmitted.PastSubmissions[0]);
            Assert.Null(result.QuestionSubmitted.AssignmentProgress);
            Assert.Equal(questionResult, result.QuestionResult);
            Assert.Equal(1.0, result.QuestionPoints);
            Assert.Equal(SubmissionDate, result.SubmissionDate);
            Assert.Equal(1.0, result.ScoreWithoutLateness);
            Assert.Equal(0.9, result.ScoreWithLateness);
        }