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)); }
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(); }
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"); }
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(); }
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(); }
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(""); }
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(); }
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(); }
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"); }
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)); }
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); }