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); }
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); }
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); }
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); }
public IActionResult ContentViewer(int customisationId, int sectionId, int tutorialId) { var candidateId = User.GetCandidateIdKnownNotNull(); var centreId = User.GetCentreId(); var tutorialContent = tutorialContentDataService.GetTutorialContent(customisationId, sectionId, tutorialId); if (tutorialContent?.TutorialPath == null) { logger.LogError( "Redirecting to 404 as customisation/section/tutorial id was not found. " + $"Candidate id: {candidateId}, customisation id: {customisationId}, " + $"centre id: {centreId.ToString() ?? "null"}, section id: {sectionId} tutorial id: {tutorialId}"); return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 404 })); } 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 ContentViewerViewModel( config, tutorialContent, customisationId, centreId, sectionId, tutorialId, candidateId, progressId.Value ); return(View("Tutorial/ContentViewer", model)); }
public void Content_viewer_should_have_tutorialId() { // Given var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent(); // When var contentViewerViewModel = new ContentViewerViewModel( config, expectedTutorialContent, CustomisationId, CentreId, SectionId, TutorialId, CandidateId, ProgressId ); // Then contentViewerViewModel.TutorialId.Should().Be(TutorialId); }
public void Content_viewer_should_have_sectionName() { // Given const string sectionName = "Section Name"; var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent( sectionName: sectionName ); // When var contentViewerViewModel = new ContentViewerViewModel( config, expectedTutorialContent, CustomisationId, CentreId, SectionId, TutorialId, CandidateId, ProgressId ); // Then contentViewerViewModel.SectionName.Should().BeEquivalentTo(sectionName); }