コード例 #1
0
 public EditAdminFieldViewModel(CourseAdminField courseAdminField)
 {
     PromptNumber  = courseAdminField.PromptNumber;
     Prompt        = courseAdminField.PromptText;
     OptionsString = NewlineSeparatedStringListHelper.JoinNewlineSeparatedList(courseAdminField.Options);
     IncludeAnswersTableCaption = true;
 }
コード例 #2
0
        public void CourseAdminField_constructor_populates_options_with_single_entry()
        {
            // When
            var result = new CourseAdminField(1, "Test", "Option");

            // Then
            using (new AssertionScope())
            {
                result.Options.Should().NotBeNull();
                result.Options.Count.Should().Be(1);
            }
        }
        EditDelegateCourseAdminField_GET_returns_not_found_if_no_course_admin_field_corresponds_to_prompt_number()
        {
            // Given
            const int    validPromptNumber   = 1;
            const int    invalidPromptNumber = 2;
            const string promptText          = "Prompt text";
            const string options             = "Answer";

            var courseAdminFieldWithAnswer = new CourseAdminFieldWithAnswer(
                validPromptNumber,
                promptText,
                options,
                options
                );
            var delegateCourseInfo = new DelegateCourseInfo
            {
                CourseAdminFields = new List <CourseAdminFieldWithAnswer> {
                    courseAdminFieldWithAnswer
                }
            };
            var delegateCourseDetails = new DetailedCourseProgress(
                new Progress(),
                new List <DetailedSectionProgress>(),
                delegateCourseInfo
                );

            var courseAdminField           = new CourseAdminField(validPromptNumber, promptText, options);
            var courseAdminFieldsForCourse = new CourseAdminFields(
                CustomisationId,
                new List <CourseAdminField> {
                courseAdminField
            }
                );

            A.CallTo(() => progressService.GetDetailedCourseProgress(ProgressId))
            .Returns(delegateCourseDetails);
            A.CallTo(() => courseAdminFieldsService.GetCourseAdminFieldsForCourse(CustomisationId))
            .Returns(courseAdminFieldsForCourse);

            // When
            var result = delegateProgressController.EditDelegateCourseAdminField(
                invalidPromptNumber,
                ProgressId,
                DelegateAccessRoute.CourseDelegates
                );

            // Then
            result.Should().BeNotFoundResult();
        }
コード例 #4
0
        public void CourseAdminField_constructor_populates_options_with_extra_newline_separated_entries()
        {
            // Given
            var options = "Option1\r\nOption2\r\n\r\nOption3\r\n\r\n\r\n\r\nOption4";

            // When
            var result = new CourseAdminField(1, "Test", options);

            // Then
            using (new AssertionScope())
            {
                result.Options.Should().NotBeNull();
                result.Options.Count.Should().Be(4);
            }
        }
コード例 #5
0
        private static IEnumerable <ResponseCount> GetResponseCountsForPrompt(
            CourseAdminField courseAdminField,
            IReadOnlyCollection <DelegateCourseAdminFieldAnswers> allAnswers
            )
        {
            const string blank    = "blank";
            const string notBlank = "not blank";

            var responseCounts = new List <ResponseCount>();

            if (courseAdminField.Options.Any())
            {
                responseCounts.AddRange(
                    courseAdminField.Options.Select(
                        x => new ResponseCount(
                            x,
                            allAnswers.Count(a => a.AdminFieldAnswers[courseAdminField.PromptNumber - 1] == x)
                            )
                        )
                    );
            }
            else
            {
                responseCounts.Add(
                    new ResponseCount(
                        notBlank,
                        allAnswers.Count(
                            a => !string.IsNullOrEmpty(a.AdminFieldAnswers[courseAdminField.PromptNumber - 1])
                            )
                        )
                    );
            }

            responseCounts.Add(
                new ResponseCount(
                    blank,
                    allAnswers.Count(
                        a => string.IsNullOrEmpty(a.AdminFieldAnswers[courseAdminField.PromptNumber - 1])
                        )
                    )
                );

            return(responseCounts);
        }