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();
        }
示例#10
0
        public void Post_learning_assessment_should_not_StartOrUpdate_course_sessions_if_unable_to_enrol()
        {
            // Given
            var defaultPostLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment();

            A.CallTo(() => postLearningAssessmentService.GetPostLearningAssessment(CustomisationId, CandidateId, SectionId))
            .Returns(defaultPostLearningAssessment);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId))
            .Returns(null);

            // When
            controller.PostLearning(CustomisationId, SectionId);

            // Then
            A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A <int> ._, A <int> ._, A <ISession> ._)).MustNotHaveHappened();
        }
        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_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_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);
        }
示例#15
0
        public void Post_learning_assessment_should_UpdateProgress_if_valid_post_learning_assessment()
        {
            // 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
            controller.PostLearning(CustomisationId, SectionId);

            // Then
            A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened();
        }
        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");
        }
示例#17
0
        public void Post_learning_assessment_should_404_if_failed_to_enrol()
        {
            // Given
            var defaultPostLearningAssessment = PostLearningAssessmentHelper.CreateDefaultPostLearningAssessment();

            A.CallTo(() => postLearningAssessmentService.GetPostLearningAssessment(CustomisationId, CandidateId, SectionId))
            .Returns(defaultPostLearningAssessment);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(null);

            // When
            var result = controller.PostLearning(CustomisationId, SectionId);

            // Then
            result.Should()
            .BeRedirectToActionResult()
            .WithControllerName("LearningSolutions")
            .WithActionName("StatusCode")
            .WithRouteValue("code", 404);
        }
示例#18
0
        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);
        }
示例#20
0
        public void Post_learning_assessment_should_StartOrUpdate_course_sessions_if_valid_post_learning_assessment()
        {
            // 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
            controller.PostLearning(CustomisationId, SectionId);

            // Then
            A.CallTo(() => sessionService.StartOrUpdateDelegateSession(CandidateId, CustomisationId, httpContextSession)).MustHaveHappenedOnceExactly();
            A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A <int> ._, A <int> ._, A <ISession> ._))
            .WhenArgumentsMatch((int candidateId, int customisationId, ISession session) =>
                                candidateId != CandidateId || customisationId != CustomisationId)
            .MustNotHaveHappened();
        }
        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);
        }