コード例 #1
0
        public void Tutorial_separator_displays_in_correct_situations(
            bool showTutorials,
            bool showPostLearningAssessment,
            bool showConsolidationExercise,
            bool separatorExpected
            )
        {
            // Given
            var consolidationPath = showConsolidationExercise
                ? "https://www.dls.nhs.uk/tracking/MOST/Word07Core/cons/WC07-Exercise_1.zip"
                : null;
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                isAssessed: showPostLearningAssessment,
                consolidationPath: consolidationPath
                );

            if (showTutorials)
            {
                var tutorials = new[]
                {
                    SectionTutorialHelper.CreateDefaultSectionTutorial(),
                    SectionTutorialHelper.CreateDefaultSectionTutorial()
                };
                sectionContent.Tutorials.AddRange(tutorials);
            }

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.DisplayTutorialSeparator.Should().Be(separatorExpected);
        }
コード例 #2
0
        public void Section_should_return_section_page_if_more_than_one_tutorial_in_section()
        {
            // Given
            const int customisationId = 123;
            const int sectionId       = 456;
            const int tutorialId      = 789;
            var       tutorial1       = SectionContentHelper.CreateDefaultSectionTutorial(id: tutorialId + 1);
            var       tutorial2       = SectionContentHelper.CreateDefaultSectionTutorial(id: tutorialId + 2);
            var       tutorial3       = SectionContentHelper.CreateDefaultSectionTutorial(id: tutorialId + 3);

            var expectedSectionContent = SectionContentHelper.CreateDefaultSectionContent(
                diagAssessPath: null,
                plAssessPath: null,
                consolidationPath: null,
                otherSectionsExist: true
                );

            expectedSectionContent.Tutorials.AddRange(new[] { tutorial1, tutorial2, tutorial3 });

            A.CallTo(() => sectionContentDataService.GetSectionContent(customisationId, CandidateId, sectionId))
            .Returns(expectedSectionContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, customisationId, CentreId)).Returns(10);

            var expectedModel = new SectionContentViewModel(config, expectedSectionContent, customisationId, sectionId);

            // When
            var result = controller.Section(customisationId, sectionId);

            // Then
            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
コード例 #3
0
        public void Section_should_return_section_page_if_there_is_diagnostic_assessment_and_consolidation()
        {
            // Given
            const int customisationId        = 123;
            const int sectionId              = 456;
            var       expectedSectionContent = SectionContentHelper.CreateDefaultSectionContent(
                diagAssessPath: "some/diagnostic/path.html",
                diagStatus: true,
                plAssessPath: null,
                consolidationPath: "some/consolidation/path.pdf",
                otherSectionsExist: true
                );

            // expectedSectionContent.Tutorials; viewable tutorials, is empty

            A.CallTo(() => sectionContentDataService.GetSectionContent(customisationId, CandidateId, sectionId))
            .Returns(expectedSectionContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, customisationId, CentreId)).Returns(10);

            var expectedModel = new SectionContentViewModel(config, expectedSectionContent, customisationId, sectionId);

            // When
            var result = controller.Section(customisationId, sectionId);

            // Then
            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
コード例 #4
0
        public void Section_should_redirect_to_tutorial_page_if_one_tutorial_and_is_assessed_but_has_no_path()
        {
            // Given
            const int customisationId        = 123;
            const int sectionId              = 456;
            const int tutorialId             = 789;
            var       tutorial               = SectionContentHelper.CreateDefaultSectionTutorial(id: tutorialId);
            var       expectedSectionContent = SectionContentHelper.CreateDefaultSectionContent(
                diagAssessPath: null,
                plAssessPath: null,
                isAssessed: true,
                consolidationPath: null,
                otherSectionsExist: true
                );

            expectedSectionContent.Tutorials.Add(tutorial);

            A.CallTo(() => sectionContentDataService.GetSectionContent(customisationId, CandidateId, sectionId))
            .Returns(expectedSectionContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, customisationId, CentreId)).Returns(10);

            // When
            var result = controller.Section(customisationId, sectionId);

            // Then
            result.Should()
            .BeRedirectToActionResult()
            .WithControllerName("LearningMenu")
            .WithActionName("Tutorial")
            .WithRouteValue("customisationId", customisationId)
            .WithRouteValue("sectionId", sectionId)
            .WithRouteValue("tutorialId", tutorialId);
        }
コード例 #5
0
        public void Section_should_return_section_page_if_there_is_post_learning_assessment_and_tutorial()
        {
            // Given
            const int customisationId        = 123;
            const int sectionId              = 456;
            const int tutorialId             = 789;
            var       tutorial               = SectionContentHelper.CreateDefaultSectionTutorial(id: tutorialId);
            var       expectedSectionContent = SectionContentHelper.CreateDefaultSectionContent(
                diagAssessPath: null,
                plAssessPath: "some/post-learning/path.html",
                isAssessed: true,
                consolidationPath: null,
                otherSectionsExist: true
                );

            expectedSectionContent.Tutorials.Add(tutorial);

            A.CallTo(() => sectionContentDataService.GetSectionContent(customisationId, CandidateId, sectionId))
            .Returns(expectedSectionContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, customisationId, CentreId)).Returns(10);

            var expectedModel = new SectionContentViewModel(config, expectedSectionContent, customisationId, sectionId);

            // When
            var result = controller.Section(customisationId, sectionId);

            // Then
            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
コード例 #6
0
        public void Section_should_redirect_to_diagnostic_assessment_if_is_assessed_but_there_is_no_post_learning_path()
        {
            // Given
            const int customisationId        = 123;
            const int sectionId              = 456;
            var       expectedSectionContent = SectionContentHelper.CreateDefaultSectionContent(
                diagAssessPath: "some/diagnostic/path.html",
                diagStatus: true,
                plAssessPath: null,
                isAssessed: true,
                consolidationPath: null,
                otherSectionsExist: true
                );

            // expectedSectionContent.Tutorials; viewable tutorials, is empty

            A.CallTo(() => sectionContentDataService.GetSectionContent(customisationId, CandidateId, sectionId))
            .Returns(expectedSectionContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, customisationId, CentreId)).Returns(10);

            // When
            var result = controller.Section(customisationId, sectionId);

            // Then
            result.Should()
            .BeRedirectToActionResult()
            .WithControllerName("LearningMenu")
            .WithActionName("Diagnostic")
            .WithRouteValue("customisationId", customisationId)
            .WithRouteValue("sectionId", sectionId);
        }
コード例 #7
0
        public void Section_content_post_learning_passed_should_be_false_if_pl_passes_is_zero()
        {
            // When
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(plPasses: 0);

            // Then
            sectionContent.PostLearningPassed.Should().BeFalse();
        }
コード例 #8
0
        public void Section_content_post_learning_passed_should_be_true_if_pl_passes_is_more_than_one()
        {
            // When
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(plPasses: 3);

            // Then
            sectionContent.PostLearningPassed.Should().BeTrue();
        }
コード例 #9
0
        public void Section_content_should_have_customisation_id()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent();

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.CustomisationId.Should().Be(CustomisationId);
        }
コード例 #10
0
        public void Diagnostic_assessment_should_not_be_shown_if_diag_status_is_false()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(diagStatus: false);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.ShowDiagnostic.Should().BeFalse();
        }
コード例 #11
0
        public void Post_learning_status_should_have_passed_styling_if_pl_attempts_is_more_than_zero_and_pl_passes_is_more_than_zero()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(attemptsPl: 3, plPasses: 1);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.PostLearningStatusStyling.Should().Be("passed-text");
        }
コード例 #12
0
        public void Post_learning_should_not_be_shown_if_is_assessed_is_false()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(isAssessed: false);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.ShowPostLearning.Should().BeFalse();
        }
コード例 #13
0
        public void Post_learning_should_not_be_shown_if_no_post_learning_path()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(plAssessPath: null);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.ShowPostLearning.Should().BeFalse();
        }
コード例 #14
0
        public void Post_learning_status_should_be_not_attempted_if_pl_attempts_is_zero()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(attemptsPl: 0);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.PostLearningStatus.Should().Be("Not Attempted");
        }
コード例 #15
0
        public void Diagnostic_assessment_completion_status_is_not_attempted_if_diag_attempts_is_zero()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(diagAttempts: 0);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.DiagnosticCompletionStatus.Should().Be("Not Attempted");
        }
コード例 #16
0
        public void Diagnostic_assessment_should_be_shown_if_diag_status_is_true_and_diag_assessment_path_exists()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                diagAssessPath: "https://www.dls.nhs.uk/CMS/CMSContent/Course308/Diagnostic/02-DIAG-Entering-data/itspplayer.html",
                diagStatus: true);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.ShowDiagnostic.Should().BeTrue();
        }
コード例 #17
0
        public void Post_learning_should_be_shown_if_there_is_post_learning_path_and_is_assessed_is_true()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                plAssessPath: "https://www.dls.nhs.uk/CMS/CMSContent/Course308/PLAssess/02-PLA-Entering-data/itspplayer.html",
                isAssessed: true);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.ShowPostLearning.Should().BeTrue();
        }
コード例 #18
0
        public void Section_content_should_have_default_consolidationExerciseLabel_when_courseSetting_is_empty()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                courseSettings: null
                );

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.ConsolidationExerciseLabel.Should().Be("Consolidation Exercise");
        }
コード例 #19
0
        public void Should_have_null_next_section_id_if_there_is_no_next_section()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                nextSectionId: null
                );

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.NextSectionId.Should().BeNull();
        }
コード例 #20
0
        public void Section_content_should_not_have_otherSectionsExist_when_no_other_sections_exist()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                otherSectionsExist: false
                );

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.OtherSectionsExist.Should().BeFalse();
        }
コード例 #21
0
        public void Section_content_should_not_show_completion_summary_when_other_sections_exist()
        {
            // Given
            var sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                otherSectionsExist: true,
                includeCertification: true
                );

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.ShowCompletionSummary.Should().BeFalse();
        }
コード例 #22
0
        public void Section_content_should_have_consolidationExerciseLabel_from_courseSetting()
        {
            // Given
            const string consolidationText = "Different consolidation description";
            var          sectionContent    = SectionContentHelper.CreateDefaultSectionContent(
                courseSettings: "{\"lm.ce\":\"" + consolidationText + "\"}"
                );

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.ConsolidationExerciseLabel.Should().Be(consolidationText);
        }
コード例 #23
0
        public void Section_content_should_have_section_name()
        {
            // Given
            const string sectionName    = "Section name";
            var          sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                sectionName: sectionName
                );

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.SectionName.Should().Be(sectionName);
        }
コード例 #24
0
        public void Section_content_view_model_should_properly_convert_consolidation_path()
        {
            // Given
            const string consolidationPath = "consolidation/path";
            var          sectionContent    = SectionContentHelper.CreateDefaultSectionContent(
                consolidationPath: consolidationPath
                );
            var expectedConsolidationPath = $"{BaseUrl}/tracking/dlconsolidation?client={consolidationPath}";

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.ConsolidationExercisePath.Should().Be(expectedConsolidationPath);
        }
コード例 #25
0
        public void Section_content_should_have_title()
        {
            // Given
            const string applicationName   = "Application name";
            const string customisationName = "Customisation name";
            var          sectionContent    = SectionContentHelper.CreateDefaultSectionContent(
                applicationName: applicationName,
                customisationName: customisationName
                );

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.CourseTitle.Should().Be($"{applicationName} - {customisationName}");
        }
コード例 #26
0
        public void Section_should_not_StartOrUpdate_course_sessions_if_unable_to_enrol()
        {
            // Given
            var defaultSectionContent = SectionContentHelper.CreateDefaultSectionContent();

            A.CallTo(() => sectionContentDataService.GetSectionContent(CustomisationId, CandidateId, SectionId))
            .Returns(defaultSectionContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId))
            .Returns(null);

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

            // Then
            A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A <int> ._, A <int> ._, A <ISession> ._)).MustNotHaveHappened();
        }
コード例 #27
0
        public void Section_should_UpdateProgress_if_valid_section()
        {
            // Given
            const int progressId            = 299;
            var       defaultSectionContent = SectionContentHelper.CreateDefaultSectionContent();

            A.CallTo(() => sectionContentDataService.GetSectionContent(CustomisationId, CandidateId, SectionId))
            .Returns(defaultSectionContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId))
            .Returns(progressId);

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

            // Then
            A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened();
        }
コード例 #28
0
        public void Diagnostic_assessment_completion_status_does_not_use_plural_if_attempts_is_one()
        {
            // Given
            const int diagAttempts   = 1;
            const int secScore       = 10;
            const int secOutOf       = 15;
            var       sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                diagAttempts: diagAttempts,
                secScore: secScore,
                secOutOf: secOutOf);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.DiagnosticCompletionStatus.Should().Be($"{secScore}/{secOutOf} - {diagAttempts} attempt");
        }
コード例 #29
0
        public void Diagnostic_assessment_completion_status_shows_score_and_attempts_if_diag_attempts_is_more_than_0()
        {
            // Given
            const int diagAttempts   = 4;
            const int secScore       = 10;
            const int secOutOf       = 15;
            var       sectionContent = SectionContentHelper.CreateDefaultSectionContent(
                diagAttempts: diagAttempts,
                secScore: secScore,
                secOutOf: secOutOf);

            // When
            var sectionContentViewModel = new SectionContentViewModel(config, sectionContent, CustomisationId, SectionId);

            // Then
            sectionContentViewModel.DiagnosticCompletionStatus.Should().Be($"{secScore}/{secOutOf} - {diagAttempts} attempts");
        }
コード例 #30
0
        public void Section_should_404_if_failed_to_enrol()
        {
            // Given
            var defaultSectionContent = SectionContentHelper.CreateDefaultSectionContent();

            A.CallTo(() => sectionContentDataService.GetSectionContent(CustomisationId, CandidateId, SectionId))
            .Returns(defaultSectionContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(null);

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

            // Then
            result.Should()
            .BeRedirectToActionResult()
            .WithControllerName("LearningSolutions")
            .WithActionName("StatusCode")
            .WithRouteValue("code", 404);
        }