Example #1
0
        public void Tutorial_should_have_showNextButton(
            string status,
            bool otherSectionsExist,
            bool otherItemsInSectionExist,
            bool expectedShowNextButton
            )
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                status: status,
                otherSectionsExist: otherSectionsExist,
                otherItemsInSectionExist: otherItemsInSectionExist
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.ShowNextButton.Should().Be(expectedShowNextButton);
        }
Example #2
0
        public async Task Tutorial_should_sign_in_with_longer_expiry_if_valid_tutorial_with_average_duration_of_45_minutes_or_over(int averageTutorialDuration)
        {
            // Given
            var utcNow = new DateTime(2022, 1, 1, 10, 0, 0);
            var defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId, averageTutorialDuration: averageTutorialDuration);

            A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId))
            .Returns(defaultTutorialInformation);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(1);
            A.CallTo(() => clockService.UtcNow).Returns(utcNow);

            // When
            await controller.Tutorial(CustomisationId, SectionId, TutorialId);

            // Then
            var expectedExpiryTime = new DateTime(2022, 1, 1, 18, 0, 0);

            A.CallTo(
                () => authenticationService.SignInAsync(
                    A <HttpContext> ._,
                    A <string> ._,
                    A <ClaimsPrincipal> ._,
                    A <AuthenticationProperties> .That.Matches(ap => ap.ExpiresUtc !.Value == expectedExpiryTime)
                    )
                ).MustHaveHappenedOnceExactly();
        }
Example #3
0
        public void Tutorial_parses_html_document_of_objectives()
        {
            // Given
            const string objectives =
                "<html> <head> <title>Tutorial Objective</title> </head>" +
                "<body> In this tutorial you will learn to: " +
                "<ul>" +
                "<li>open another window on to a workbook</li>" +
                "<li>arrange workbook windows</li>" +
                "<li>hide and show windows</li>" +
                "</ul>" +
                "</body> </html>";
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                objectives: objectives
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.Objectives.Should().Be(" In this tutorial you will learn to: " +
                                                     "<ul>" +
                                                     "<li>open another window on to a workbook</li>" +
                                                     "<li>arrange workbook windows</li>" +
                                                     "<li>hide and show windows</li>" +
                                                     "</ul>");
        }
        public void ContentViewer_should_render_view()
        {
            // Given
            var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent();
            const int progressId = 101;

            A.CallTo(() => tutorialContentDataService.GetTutorialContent(CustomisationId, SectionId, TutorialId))
                .Returns(expectedTutorialContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId))
                .Returns(progressId);

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

            // Then
            var expectedModel = new ContentViewerViewModel(
                config,
                expectedTutorialContent,
                CustomisationId,
                CentreId,
                SectionId,
                TutorialId,
                CandidateId,
                progressId
            );

            result.Should().BeViewResult()
                .Model.Should().BeEquivalentTo(expectedModel);
        }
Example #5
0
        public void Tutorial_should_have_timeSummary(
            int timeSpent,
            int averageTutorialDuration,
            bool showTime,
            bool showLearnStatus
            )
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                timeSpent: timeSpent,
                averageTutorialDuration: averageTutorialDuration,
                courseSettings: "{\"lm.st\":" + showTime.ToString().ToLower()
                + ", \"lm.sl\":" + showLearnStatus.ToString().ToLower() + "}"

                );
            var expectedTimeSummary = new TutorialTimeSummaryViewModel(
                timeSpent,
                averageTutorialDuration,
                showTime,
                showLearnStatus
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.TimeSummary.Should().BeEquivalentTo(expectedTimeSummary);
        }
Example #6
0
        public void Tutorial_should_have_nextLinkViewModel()
        {
            // Given
            const string postLearningAssessmentPath = "/assessment";
            const int    nextTutorialId             = 101;
            const int    nextSectionId = 100;
            var          expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                nextTutorialId: nextTutorialId,
                nextSectionId: nextSectionId,
                postLearningAssessmentPath: postLearningAssessmentPath
                );
            var expectedNextLinkViewModel = new TutorialNextLinkViewModel(
                CustomisationId,
                SectionId,
                postLearningAssessmentPath,
                nextTutorialId,
                nextSectionId
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.NextLinkViewModel.Should().BeEquivalentTo(expectedNextLinkViewModel);
        }
Example #7
0
        public void Tutorial_should_have_showCompletionSummary(
            bool otherSectionsExist,
            bool otherItemsInSectionExist,
            bool includeCertification,
            bool expectedShowCompletionSummary
            )
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                otherSectionsExist: otherSectionsExist,
                otherItemsInSectionExist: otherItemsInSectionExist,
                includeCertification: includeCertification
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.ShowCompletionSummary.Should().Be(expectedShowCompletionSummary);
        }
Example #8
0
        public void Content_viewer_should_parse_html_source()
        {
            // Given
            const int customisationId = 24861;
            var       expectedHtmlUrl = "https://www.dls.nhs.uk/CMS/CMSContent/Course508/Section1904/Tutorials/Intro to Social Media/itspplayer.html"
                                        + "?CentreID=101&CustomisationID=24861&TutorialID=4&CandidateID=254480&Version=2&ProgressID=276837&type=learn"
                                        + $"&TrackURL={BaseUrl}/tracking/tracker";

            // Given
            var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent(
                currentVersion: 2,
                tutorialPath: "https://www.dls.nhs.uk/CMS/CMSContent/Course508/Section1904/Tutorials/Intro to Social Media/itspplayer.html"
                );

            // When
            var contentViewerViewModel = new ContentViewerViewModel(
                config,
                expectedTutorialContent,
                customisationId,
                CentreId,
                SectionId,
                TutorialId,
                CandidateId,
                ProgressId
                );

            // Then
            contentViewerViewModel.ContentSource.Should().Be(expectedHtmlUrl);
        }
Example #9
0
        public void Content_viewer_should_parse_scorm_source()
        {
            // Given
            var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent(
                currentVersion: 1,
                tutorialPath: "https://www.dls.nhs.uk/cms/CMSContent/Course589/Section2295/Tutorials/2 Patient Reg PDS/imsmanifest.xml"
                );

            var expectedScormUrl = $"{BaseUrl}/scoplayer/sco?CentreID=101&CustomisationID=37545&TutorialID=4&CandidateID=254480&Version=1"
                                   + "&tutpath=https://www.dls.nhs.uk/cms/CMSContent/Course589/Section2295/Tutorials/2 Patient Reg PDS/imsmanifest.xml";

            // When
            var contentViewerViewModel = new ContentViewerViewModel(
                config,
                expectedTutorialContent,
                CustomisationId,
                CentreId,
                SectionId,
                TutorialId,
                CandidateId,
                ProgressId
                );

            // Then
            contentViewerViewModel.ContentSource.Should().Be(expectedScormUrl);
        }
Example #10
0
        public void Content_viewer_should_have_courseTitle()
        {
            // Given
            const string applicationName         = "Application Name";
            const string customisationName       = "Customisation Name";
            var          expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent(
                applicationName: applicationName,
                customisationName: customisationName
                );

            // When
            var contentViewerViewModel = new ContentViewerViewModel(
                config,
                expectedTutorialContent,
                CustomisationId,
                CentreId,
                SectionId,
                TutorialId,
                CandidateId,
                ProgressId
                );

            // Then
            var courseTitle = $"{applicationName} - {customisationName}";

            contentViewerViewModel.CourseTitle.Should().BeEquivalentTo(courseTitle);
        }
Example #11
0
        public async Task Tutorial_should_not_UpdateProgress_if_unable_to_enrol()
        {
            // Given
            var defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId);

            A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId))
            .Returns(defaultTutorialInformation);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(null);

            // When
            await controller.Tutorial(CustomisationId, SectionId, TutorialId);

            // Then
            A.CallTo(() => courseContentService.UpdateProgress(A <int> ._)).MustNotHaveHappened();
        }
Example #12
0
        public void Tutorial_should_not_StartOrUpdate_course_sessions_if_unable_to_enrol()
        {
            // Given
            var defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId);

            A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId))
            .Returns(defaultTutorialInformation);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(null);

            // When
            controller.Tutorial(CustomisationId, SectionId, TutorialId);

            // Then
            A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A <int> ._, A <int> ._, A <ISession> ._)).MustNotHaveHappened();
        }
Example #13
0
        public void Tutorial_should_have_tutorialId()
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId);

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.TutorialId.Should().Be(TutorialId);
        }
        public void ContentViewer_should_not_UpdateProgress_if_unable_to_enrol()
        {
            // Given
            var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent();

            A.CallTo(() => tutorialContentDataService.GetTutorialContent(CustomisationId, SectionId, TutorialId))
                .Returns(expectedTutorialContent);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId))
                .Returns(null);

            // When
            controller.ContentViewer(CustomisationId, SectionId, TutorialId);

            // Then
            A.CallTo(() => courseContentService.UpdateProgress(A<int>._)).MustNotHaveHappened();
        }
Example #15
0
        public async Task Tutorial_should_UpdateProgress_if_valid_tutorial()
        {
            // Given
            const int progressId = 3;
            var       defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId);

            A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId))
            .Returns(defaultTutorialInformation);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(progressId);

            // When
            await controller.Tutorial(CustomisationId, SectionId, TutorialId);

            // Then
            A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened();
        }
        public void TutorialVideo_should_have_sectionId()
        {
            // Given
            var expectedTutorialVideo = TutorialContentHelper.CreateDefaultTutorialVideo();

            // When
            var tutorialVideoViewModel = new TutorialVideoViewModel(
                config,
                expectedTutorialVideo,
                CustomisationId,
                SectionId,
                TutorialId
                );

            // Then
            tutorialVideoViewModel.SectionId.Should().Be(SectionId);
        }
Example #17
0
        public void Tutorial_handles_null_objectives()
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                objectives: null
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.Objectives.Should().BeNull();
        }
Example #18
0
        public void Tutorial_should_have_default_showLearnStatus_when_courseSetting_is_empty()
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                courseSettings: null
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.ShowLearnStatus.Should().BeTrue();
        }
Example #19
0
        public void Tutorial_start_button_should_say_start_tutorial_if_tutorial_status_is_not_complete(string status)
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                status: status
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.TutorialStartButtonText.Should().Be("Start tutorial");
        }
Example #20
0
        public void Tutorial_start_button_should_be_grey_if_tutorial_status_is_complete()
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                status: "Complete"
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.TutorialStartButtonAdditionalStyling.Should().Be("nhsuk-button--secondary");
        }
Example #21
0
        public void Tutorial_should_have_showLearnStatus_from_courseSetting()
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                courseSettings: "{\"lm.sl\":false}"
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.ShowLearnStatus.Should().BeFalse();
        }
Example #22
0
        public void Tutorial_should_have_default_supportingMaterialsLabel_when_courseSetting_is_empty()
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                courseSettings: null
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.SupportingMaterialsLabel.Should().Be("Download supporting materials");
        }
Example #23
0
        public async Task Tutorial_should_render_view()
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId);

            A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId))
            .Returns(expectedTutorialInformation);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(3);

            // When
            var result = await controller.Tutorial(CustomisationId, SectionId, TutorialId);

            // Then
            var expectedModel = new TutorialViewModel(config, expectedTutorialInformation, CustomisationId, SectionId);

            result.Should().BeViewResult()
            .Model.Should().BeEquivalentTo(expectedModel);
        }
Example #24
0
        public void Tutorial_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 expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                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 tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                customisationId,
                SectionId
                );

            // Then
            tutorialViewModel.CompletionSummaryCardViewModel
            .Should().BeEquivalentTo(expectedCompletionSummaryViewModel);
        }
Example #25
0
        public async Task Tutorial_should_StartOrUpdate_course_sessions_if_valid_tutorial()
        {
            // Given
            var defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId);

            A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId))
            .Returns(defaultTutorialInformation);
            A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(1);

            // When
            await controller.Tutorial(CustomisationId, SectionId, TutorialId);

            // 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();
        }
Example #26
0
        public void Tutorial_should_not_decide_to_show_progress_when_canShowDiagnosticStatus_is_false()
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                canShowDiagnosticStatus: false,
                attemptCount: 1
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.CanShowProgress.Should().BeFalse();
        }
Example #27
0
        public void Tutorial_should_have_sectionName()
        {
            // Given
            const string sectionName = "Section Name";
            var          expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                sectionName: sectionName
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.SectionName.Should().Be(sectionName);
        }
Example #28
0
        public void Tutorial_should_not_recommend_a_tutorial_when_score_is_max()
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                currentScore: 10,
                possibleScore: 10
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.TutorialRecommendation.Should().Be("optional");
        }
Example #29
0
        public void Tutorial_parses_supporting_materials_path(string?supportingMaterialPath)
        {
            // Given
            var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                supportingMaterialPath: supportingMaterialPath
                );
            var expectedParsedPath = ContentUrlHelper.GetNullableContentPath(config, supportingMaterialPath);

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.SupportingMaterialPath.Should().Be(expectedParsedPath);
        }
Example #30
0
        public void Tutorial_should_have_status()
        {
            // Given
            const string status = "Not started";
            var          expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(
                status: status
                );

            // When
            var tutorialViewModel = new TutorialViewModel(
                config,
                expectedTutorialInformation,
                CustomisationId,
                SectionId
                );

            // Then
            tutorialViewModel.Status.Should().Be(status);
        }