public void Post_learning_assessment_should_have_section_id() { // Given const int sectionId = 22; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment(); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, sectionId); // Then postLearningAssessmentViewModel.SectionId.Should().Be(sectionId); }
public void Post_learning_assessment_can_have_no_next_section() { // Given var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( nextSectionId: null ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.NextSectionId.Should().BeNull(); }
public void Post_learning_assessment_start_button_should_say_start_if_it_has_not_been_attempted() { // Given var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( attemptsPl: 0 ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.StartButtonText.Should().Be("Start assessment"); }
public void Post_learning_assessment_start_button_should_have_no_extra_colour_if_it_has_not_been_attempted() { // Given var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( attemptsPl: 0 ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.StartButtonAdditionalStyling.Should().Be(""); }
public void Post_learning_assessment_assessment_status_with_no_attempts_should_be_not_attempted() { // Given const int postLearningAttempts = 0; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( attemptsPl: postLearningAttempts ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.AssessmentStatus.Should().Be("Not attempted"); }
public void Post_learning_assessment_should_have_section_name() { // Given const string sectionName = "Section name"; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( sectionName: sectionName ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.SectionName.Should().Be(sectionName); }
public void Post_learning_assessment_assessment_status_with_no_attempts_should_have_no_score_information() { // Given const int postLearningAttempts = 0; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( attemptsPl: postLearningAttempts ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.ScoreInformation.Should().BeNull(); }
public void Post_learning_assessment_start_button_should_be_grey_if_it_has_been_attempted(int postLearningPasses) { // Given var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( attemptsPl: 1, plPasses: postLearningPasses ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.StartButtonAdditionalStyling.Should().Be("nhsuk-button--secondary"); }
public void Post_learning_assessment_can_be_not_locked() { // Given const bool postLearningLocked = false; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( plLocked: postLearningLocked ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.PostLearningLocked.Should().BeFalse(); }
public void Post_learning_assessment_assessment_status_with_multiple_attempts_should_have_score_information() { // Given const int postLearningAttempts = 5; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( attemptsPl: postLearningAttempts, bestScore: 10 ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.ScoreInformation.Should().Be("10% - 5 attempts"); }
public void Post_learning_assessment_should_have_onlyItemInThisSection( bool otherItemsInSectionExist, bool expectedOnlyItemInThisSection ) { // Given var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( otherItemsInSectionExist: otherItemsInSectionExist ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.OnlyItemInThisSection.Should().Be(expectedOnlyItemInThisSection); }
public void Post_learning_assessment_should_have_title() { // Given const string applicationName = "Application name"; const string customisationName = "Customisation name"; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( applicationName: applicationName, customisationName: customisationName ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.CourseTitle.Should().Be($"{applicationName} - {customisationName}"); }
public void Post_learning_assessment_assessment_status_with_attempts_but_no_passes_should_have_not_passed_styling() { // Given const int postLearningAttempts = 5; const int postLearningPasses = 0; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( attemptsPl: postLearningAttempts, plPasses: postLearningPasses ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.AssessmentStatusStyling.Should().Be("not-passed-text"); }
public void Post_learning_assessment_assessment_status_with_attempts_can_be_passed() { // Given const int postLearningAttempts = 4; const int postLearningPasses = 2; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( attemptsPl: postLearningAttempts, plPasses: postLearningPasses ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.AssessmentStatus.Should().Be("Passed"); }
public void Post_learning_assessment_should_render_view() { // Given const int progressId = 299; var defaultPostLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment(); A.CallTo(() => postLearningAssessmentService.GetPostLearningAssessment(CustomisationId, CandidateId, SectionId)) .Returns(defaultPostLearningAssessment); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)). Returns(progressId); // When var result = controller.PostLearning(CustomisationId, SectionId); // Then var expectedModel = new PostLearningAssessmentViewModel(defaultPostLearningAssessment, CustomisationId, SectionId); result.Should().BeViewResult() .Model.Should().BeEquivalentTo(expectedModel); }
public void Post_learning_assessment_should_have_showCompletionSummary( bool otherSectionsExist, bool otherItemsInSectionExist, bool includeCertification, bool expectedShowCompletionSummary ) { // Given var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( otherSectionsExist: otherSectionsExist, otherItemsInSectionExist: otherItemsInSectionExist, includeCertification: includeCertification ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.ShowCompletionSummary.Should().Be(expectedShowCompletionSummary); }
public void Post_learning_assessment_should_have_showNextButton( bool otherSectionsExist, bool otherItemsInSectionExist, int attemptsPl, bool expectedShowNextButton ) { // Given var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( otherSectionsExist: otherSectionsExist, otherItemsInSectionExist: otherItemsInSectionExist, attemptsPl: attemptsPl ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, CustomisationId, SectionId); // Then postLearningAssessmentViewModel.ShowNextButton.Should().Be(expectedShowNextButton); }
public void Post_learning_assessment_should_have_completion_summary_card_view_model( int customisationId, string?completed, int maxPostLearningAssessmentAttempts, bool isAssessed, int postLearningAssessmentPassThreshold, int diagnosticAssessmentCompletionThreshold, int tutorialsCompletionThreshold ) { // Given var completedDateTime = completed != null?DateTime.Parse(completed) : (DateTime?)null; var postLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment( completed: completedDateTime, maxPostLearningAssessmentAttempts: maxPostLearningAssessmentAttempts, isAssessed: isAssessed, postLearningAssessmentPassThreshold: postLearningAssessmentPassThreshold, diagnosticAssessmentCompletionThreshold: diagnosticAssessmentCompletionThreshold, tutorialsCompletionThreshold: tutorialsCompletionThreshold ); var expectedCompletionSummaryViewModel = new CompletionSummaryCardViewModel( customisationId, completedDateTime, maxPostLearningAssessmentAttempts, isAssessed, postLearningAssessmentPassThreshold, diagnosticAssessmentCompletionThreshold, tutorialsCompletionThreshold ); // When var postLearningAssessmentViewModel = new PostLearningAssessmentViewModel(postLearningAssessment, customisationId, SectionId); // Then postLearningAssessmentViewModel.CompletionSummaryCardViewModel .Should().BeEquivalentTo(expectedCompletionSummaryViewModel); }
public IActionResult PostLearning(int customisationId, int sectionId) { var candidateId = User.GetCandidateIdKnownNotNull(); var centreId = User.GetCentreId(); var postLearningAssessment = postLearningAssessmentService.GetPostLearningAssessment(customisationId, candidateId, sectionId); if (postLearningAssessment == null) { logger.LogError( "Redirecting to 404 as section/centre id was not found. " + $"Candidate id: {candidateId}, customisation id: {customisationId}, " + $"centre id: {centreId.ToString() ?? "null"}, section id: {sectionId}"); return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 404 })); } if (!String.IsNullOrEmpty(postLearningAssessment.Password) && !postLearningAssessment.PasswordSubmitted) { return(RedirectToAction("CoursePassword", "LearningMenu", new { customisationId })); } var progressId = courseContentService.GetOrCreateProgressId(candidateId, customisationId, centreId); if (progressId == null) { logger.LogError( "Redirecting to 404 as no progress id was returned. " + $"Candidate id: {candidateId}, customisation id: {customisationId}, centre id: {centreId}"); return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 404 })); } sessionService.StartOrUpdateDelegateSession(candidateId, customisationId, HttpContext.Session); courseContentService.UpdateProgress(progressId.Value); var model = new PostLearningAssessmentViewModel(postLearningAssessment, customisationId, sectionId); return(View("PostLearning/PostLearning", model)); }