public PostLearningAssessmentViewModel(PostLearningAssessment postLearningAssessment, int customisationId, int sectionId) { CourseTitle = postLearningAssessment.CourseTitle; CourseDescription = postLearningAssessment.CourseDescription; SectionName = postLearningAssessment.SectionName; PostLearningLocked = postLearningAssessment.PostLearningLocked; CustomisationId = customisationId; SectionId = sectionId; NextSectionId = postLearningAssessment.NextSectionId; if (postLearningAssessment.PostLearningAttempts == 0) { AssessmentStatus = "Not attempted"; } else { AssessmentStatus = GetPassStatus(postLearningAssessment); ScoreInformation = GetScoreInformation(postLearningAssessment); } AssessmentStatusStyling = GetPassStatusStyling(postLearningAssessment); StartButtonText = postLearningAssessment.PostLearningAttempts == 0 ? "Start assessment" : "Restart assessment"; StartButtonAdditionalStyling = postLearningAssessment.PostLearningAttempts == 0 ? "" : "nhsuk-button--secondary"; OnlyItemInOnlySection = !postLearningAssessment.OtherItemsInSectionExist && !postLearningAssessment.OtherSectionsExist; OnlyItemInThisSection = !postLearningAssessment.OtherItemsInSectionExist; ShowCompletionSummary = OnlyItemInOnlySection && postLearningAssessment.IncludeCertification; CompletionSummaryCardViewModel = new CompletionSummaryCardViewModel( customisationId, postLearningAssessment.Completed, postLearningAssessment.MaxPostLearningAssessmentAttempts, postLearningAssessment.IsAssessed, postLearningAssessment.PostLearningAssessmentPassThreshold, postLearningAssessment.DiagnosticAssessmentCompletionThreshold, postLearningAssessment.TutorialsCompletionThreshold ); ShowNextButton = postLearningAssessment.PostLearningAttempts > 0 && !OnlyItemInOnlySection; }
public void Get_post_learning_assessment_should_return_assessment_if_not_enrolled() { // Given const int customisationId = 6062; const int candidateId = 4236; const int sectionId = 103; // When var result = postLearningAssessmentService.GetPostLearningAssessment(customisationId, candidateId, sectionId); // Then var expectedPostLearningAssessmentService = new PostLearningAssessment( "Level 2 - Microsoft Word 2010", null, "All Modules and Assessments", "Working with documents", 0, 0, 0, false, false, true, null, 0, 85, 88, 90, 104, true, true, "", false ); result.Should().BeEquivalentTo(expectedPostLearningAssessmentService); }
private string GetPassStatus(PostLearningAssessment postLearningAssessment) { return(postLearningAssessment.PostLearningPassed ? "Passed" : "Failed"); }
private string GetPassStatusStyling(PostLearningAssessment postLearningAssessment) { return(postLearningAssessment.PostLearningAttempts > 0 && postLearningAssessment.PostLearningPassed ? "passed-text" : "not-passed-text"); }
private string GetScoreInformation(PostLearningAssessment postLearningAssessment) { return(postLearningAssessment.PostLearningAttempts == 1 ? $"{postLearningAssessment.PostLearningScore}% - 1 attempt" : $"{postLearningAssessment.PostLearningScore}% - {postLearningAssessment.PostLearningAttempts} attempts"); }