示例#1
0
        private CourseDelegate GetCourseDelegateWithAdminFields(DelegateCourseInfo delegateCourseInfo)
        {
            var coursePrompts = courseAdminFieldsService.GetCourseAdminFieldsWithAnswersForCourse(delegateCourseInfo);

            delegateCourseInfo.CourseAdminFields = coursePrompts;
            return(new CourseDelegate(delegateCourseInfo));
        }
        public void GetCourseAdminFieldsWithAnswersForCourse_Returns_Populated_List_of_CourseAdminFieldWithAnswer()
        {
            // Given
            const string answer1   = "ans1";
            const string answer2   = "ans2";
            var          expected1 = PromptsTestHelper.GetDefaultCourseAdminFieldWithAnswer(
                1,
                "System Access Granted",
                "Test",
                answer1
                );
            var expected2 = PromptsTestHelper.GetDefaultCourseAdminFieldWithAnswer(
                2,
                "Priority Access",
                answer: answer2
                );
            var expected = new List <CourseAdminFieldWithAnswer> {
                expected1, expected2
            };

            A.CallTo(() => courseAdminFieldsDataService.GetCourseAdminFields(100))
            .Returns(PromptsTestHelper.GetDefaultCourseAdminFieldsResult());
            var delegateCourseInfo = new DelegateCourseInfo {
                Answer1 = answer1, Answer2 = answer2, CustomisationId = 100
            };

            // When
            var result = courseAdminFieldsService.GetCourseAdminFieldsWithAnswersForCourse(delegateCourseInfo);

            // Then
            result.Should().BeEquivalentTo(expected);
        }
        public DetailedCourseProgress?GetDetailedCourseProgress(int progressId)
        {
            var progress = progressDataService.GetProgressByProgressId(progressId);

            var courseInfo = courseDataService.GetDelegateCourseInfoByProgressId(progressId);

            if (progress == null || courseInfo == null)
            {
                return(null);
            }

            var coursePrompts = courseAdminFieldsService.GetCourseAdminFieldsWithAnswersForCourse(
                courseInfo
                );

            courseInfo.CourseAdminFields = coursePrompts;

            var sections = progressDataService.GetSectionProgressDataForProgressEntry(progressId).ToList();

            foreach (var section in sections)
            {
                section.Tutorials =
                    progressDataService.GetTutorialProgressDataForSection(progressId, section.SectionId);
            }

            return(new DetailedCourseProgress(
                       progress,
                       sections,
                       courseInfo
                       ));
        }
        public void GetCoursesAndCourseDelegatesForCentre_populates_course_delegates_data()
        {
            // Given
            const int centreId           = 2;
            const int categoryId         = 1;
            const int customisationId    = 1;
            var       delegateCourseInfo = new DelegateCourseInfo();

            A.CallTo(() => courseDataService.GetCoursesAvailableToCentreByCategory(centreId, categoryId))
            .Returns(
                new List <CourseAssessmentDetails>
            {
                new CourseAssessmentDetails {
                    CustomisationId = customisationId
                }
            }
                );
            A.CallTo(() => courseDataService.GetDelegateCourseInfosForCourse(A <int> ._, A <int> ._))
            .Returns(new List <DelegateCourseInfo> {
                delegateCourseInfo
            });
            A.CallTo(() => courseAdminFieldsService.GetCourseAdminFieldsForCourse(A <int> ._))
            .Returns(
                new CourseAdminFields(
                    customisationId,
                    new List <CourseAdminField> {
                new CourseAdminField(1, "prompt", null)
            }
                    )
                );
            A.CallTo(() => courseAdminFieldsService.GetCourseAdminFieldsWithAnswersForCourse(delegateCourseInfo))
            .Returns(
                new List <CourseAdminFieldWithAnswer>
            {
                new CourseAdminFieldWithAnswer(1, "prompt", null, "answer")
            }
                );

            // When
            var result = courseDelegatesService.GetCoursesAndCourseDelegatesForCentre(
                centreId,
                categoryId,
                null
                );

            // Then
            using (new AssertionScope())
            {
                result.Courses.Should().HaveCount(1);
                result.Delegates.Should().HaveCount(1);
                result.Delegates.First().CourseAdminFields.Should().HaveCount(1);
                result.CustomisationId.Should().Be(customisationId);
                result.CourseAdminFields.Should().HaveCount(1);
            }
        }
示例#5
0
        public void GetDetailedCourseProgress_returns_progress_composed_from_data_if_progress_found()
        {
            // Given
            var testCourseProgress = new Progress
            {
                ProgressId  = 1, CustomisationId = 4, CandidateId = 5, DiagnosticScore = 42, Completed = null,
                RemovedDate = null,
            };
            var testSectionProgress = new List <DetailedSectionProgress>
            {
                new DetailedSectionProgress {
                    SectionId = 2, SectionName = "Section2"
                },
                new DetailedSectionProgress {
                    SectionId = 3, SectionName = "Section3"
                },
            };
            var testTutorialProgress1 = new List <DetailedTutorialProgress>
            {
                new DetailedTutorialProgress
                {
                    TutorialName  = "Tut1", TutorialStatus = "Passed", AvgTime = 2, TimeTaken = 9, DiagnosticScore = 7,
                    PossibleScore = 8,
                },
                new DetailedTutorialProgress
                {
                    TutorialName    = "Tut2", TutorialStatus = "Not Passed", AvgTime = 3, TimeTaken = 8,
                    DiagnosticScore = 5, PossibleScore = 5,
                },
            };
            var testTutorialProgress2 = new List <DetailedTutorialProgress>
            {
                new DetailedTutorialProgress
                {
                    TutorialName    = "Tut3", TutorialStatus = "Not Passed", AvgTime = 4, TimeTaken = 7,
                    DiagnosticScore = 0, PossibleScore = 1,
                },
                new DetailedTutorialProgress
                {
                    TutorialName  = "Tut4", TutorialStatus = "Passed", AvgTime = 5, TimeTaken = 6, DiagnosticScore = 0,
                    PossibleScore = 5,
                },
            };
            var adminField = PromptsTestHelper.GetDefaultCourseAdminFieldWithAnswer(
                2,
                "Priority Access",
                answer: "answer2"
                );
            var testCourseAdminFields = new List <CourseAdminFieldWithAnswer> {
                adminField
            };
            var testCourseInfo = new DelegateCourseInfo
            {
                DelegateLastName  = "lastName",
                DelegateEmail     = "email",
                DelegateId        = 99,
                CandidateNumber   = "five",
                LastUpdated       = DateTime.UnixEpoch,
                Enrolled          = DateTime.MinValue,
                Completed         = DateTime.Today,
                CompleteBy        = DateTime.Now,
                CustomisationId   = 10,
                IsAssessed        = true,
                CourseAdminFields = testCourseAdminFields
            };

            A.CallTo(() => progressDataService.GetProgressByProgressId(1)).Returns(testCourseProgress);
            A.CallTo(() => progressDataService.GetSectionProgressDataForProgressEntry(1)).Returns(testSectionProgress);
            A.CallTo(() => progressDataService.GetTutorialProgressDataForSection(1, 2)).Returns(testTutorialProgress1);
            A.CallTo(() => progressDataService.GetTutorialProgressDataForSection(1, 3)).Returns(testTutorialProgress2);
            A.CallTo(() => courseDataService.GetDelegateCourseInfoByProgressId(1)).Returns(testCourseInfo);
            A.CallTo(
                () => courseAdminFieldsService.GetCourseAdminFieldsWithAnswersForCourse(
                    testCourseInfo
                    )
                ).Returns(testCourseAdminFields);

            var testSectionProgressWithTutorials = new List <DetailedSectionProgress>
            {
                new DetailedSectionProgress
                {
                    SectionId = 2, SectionName = "Section2", Tutorials = testTutorialProgress1
                },
                new DetailedSectionProgress
                {
                    SectionId = 3, SectionName = "Section3", Tutorials = testTutorialProgress2
                },
            };
            var expectedResult = new DetailedCourseProgress(
                testCourseProgress,
                testSectionProgressWithTutorials,
                testCourseInfo
                );

            // When
            var result = progressService.GetDetailedCourseProgress(1);

            // Then
            result.Should().BeEquivalentTo(expectedResult);
        }