コード例 #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public AssignmentResultViewModel(
            StudentAssignmentResult result,
            Func<int, string> getQuestionUrl,
            ITimeZoneProvider timeZoneProvider)
        {
            AssignmentName = result.AssignmentName;
            DueDate = result.AssignmentDueDate.FormatLongDateTime(timeZoneProvider);
            Score = $"{result.Score} / {result.QuestionResults.Sum(qr => qr.QuestionPoints)}";
            Status = GetColoredText
            (
                result.Status.GetColor(),
                result.Status.GetText(),
                result.Status.GetBold(),
                preventWrapping: true
            );

            QuestionResults = result.QuestionResults
                .Select
                (
                    qr => new StudentQuestionResultViewModel
                    (
                        qr,
                        getQuestionUrl
                    )
                ).ToList();
        }
コード例 #2
0
 /// <summary>
 /// Verifies student assignment results.
 /// </summary>
 private void VerifyStudentAssignmentResult(
     StudentAssignmentResult expected,
     StudentAssignmentResult actual)
 {
     Assert.Equal(expected.AssignmentName, actual.AssignmentName);
     Assert.Equal(expected.AssignmentDueDate, actual.AssignmentDueDate);
     Assert.Equal(expected.Score, actual.Score);
     Assert.Equal(expected.Status.Completion, actual.Status.Completion);
     Assert.Equal(expected.Status.Late, actual.Status.Late);
     Assert.Equal(expected.QuestionResults.Count, actual.QuestionResults.Count);
     for (int index = 0; index < expected.QuestionResults.Count; index++)
     {
         VerifyStudentQuestionResult
         (
             expected.QuestionResults[index],
             actual.QuestionResults[index]
         );
     }
 }