コード例 #1
0
        public IActionResult SetCurrentCourseCompleteByDate(int id, ReturnPageQuery returnPageQuery)
        {
            var currentCourses = courseDataService.GetCurrentCourses(User.GetCandidateIdKnownNotNull());
            var course         = currentCourses.FirstOrDefault(c => c.Id == id);

            if (course == null)
            {
                logger.LogWarning(
                    $"Attempt to set complete by date for course with id {id} which is not a current course for user with id {User.GetCandidateIdKnownNotNull()}"
                    );
                return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 404 }));
            }

            var courseModel = new CurrentCourseViewModel(course, returnPageQuery);

            if (courseModel.CompleteByDate != null && !courseModel.SelfEnrolled)
            {
                logger.LogWarning(
                    $"Attempt to set complete by date for course with id {id} for user with id ${User.GetCandidateIdKnownNotNull()} " +
                    "but the complete by date has already been set and the user has not self enrolled"
                    );
                return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 }));
            }

            var editCompleteByDateViewModel = new EditCompleteByDateViewModel(
                id,
                course.Name,
                LearningItemType.Course,
                courseModel.CompleteByDate,
                returnPageQuery,
                courseModel.ProgressId
                );

            return(View("Current/SetCompleteByDate", editCompleteByDateViewModel));
        }
コード例 #2
0
        public void Current_course_should_not_have_passed_sections_without_learning_assessment()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(isAssessed: false);

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);

            // Then
            currentCourseViewModel.HasPassedSections().Should().BeFalse();
        }
コード例 #3
0
        public void Current_course_should_be_overdue_when_complete_by_date_is_in_the_past()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(completeByDate: DateTime.Today - TimeSpan.FromDays(1));

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);

            // Then
            currentCourseViewModel.DateStyle().Should().Be("overdue");
        }
コード例 #4
0
        public void Current_course_should_have_diagnostic_score_with_diagnostic_score_value_and_diagnostic_assessment()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse();

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);


            // Then
            currentCourseViewModel.HasDiagnosticScore().Should().BeTrue();
        }
コード例 #5
0
        public void Current_course_should_not_have_diagnostic_score_without_diagnostic_score_value()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(diagnosticScore: null);

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);


            // Then
            currentCourseViewModel.HasDiagnosticScore().Should().BeFalse();
        }
コード例 #6
0
        public void Current_course_should_have_no_date_style_when_due_far_in_the_future()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(completeByDate: DateTime.Today + TimeSpan.FromDays(100));

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(currentCourse);



            // Then
            currentCourseViewModel.DateStyle().Should().Be("");
        }
コード例 #7
0
        public void Current_course_should_not_have_diagnostic_score_without_diagnostic_assessment()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse(hasDiagnostic: false);

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(
                currentCourse,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            currentCourseViewModel.HasDiagnosticScore().Should().BeFalse();
        }
コード例 #8
0
        public void Current_course_should_have_passed_sections_with_learning_assessment()
        {
            // Given
            var currentCourse = CurrentCourseHelper.CreateDefaultCurrentCourse();

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(
                currentCourse,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            currentCourseViewModel.HasPassedSections().Should().BeTrue();
        }
コード例 #9
0
        public void Current_course_should__be_due_soon_when_complete_by_date_is_in_the_future()
        {
            // Given
            var currentCourse =
                CurrentCourseHelper.CreateDefaultCurrentCourse(completeByDate: DateTime.Today + TimeSpan.FromDays(1));

            // When
            var currentCourseViewModel = new CurrentCourseViewModel(
                currentCourse,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            currentCourseViewModel.DateStyle().Should().Be("due-soon");
        }
コード例 #10
0
        public IActionResult RemoveCurrentCourseConfirmation(int id, ReturnPageQuery returnPageQuery)
        {
            var currentCourses = courseDataService.GetCurrentCourses(User.GetCandidateIdKnownNotNull());
            var course         = currentCourses.FirstOrDefault(c => c.Id == id);

            if (course == null)
            {
                logger.LogWarning(
                    $"Attempt to remove course with id {id} which is not a current course for user with id {User.GetCandidateIdKnownNotNull()}"
                    );
                return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 404 }));
            }

            var model = new CurrentCourseViewModel(course, returnPageQuery);

            return(View("Current/RemoveCurrentCourseConfirmation", model));
        }
コード例 #11
0
        public void Remove_confirmation_for_a_current_course_should_show_confirmation()
        {
            // Given
            const int customisationId = 2;
            var       currentCourse   = CurrentCourseHelper.CreateDefaultCurrentCourse(customisationId);
            var       currentCourses  = new[]
            {
                currentCourse,
            };

            A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses);

            // When
            var result = controller.RemoveCurrentCourseConfirmation(customisationId, ReturnPageQueryHelper.GetDefaultReturnPageQuery());

            // Then
            var expectedModel = new CurrentCourseViewModel(currentCourse, ReturnPageQueryHelper.GetDefaultReturnPageQuery());

            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }