コード例 #1
0
        public void TestToAccessibilityResourceNotModified()
        {
            ImmutableArray <AccessibilityFamilyResource> resource = ImmutableArray.Create <AccessibilityFamilyResource>();
            AccessibilityFamilyResource familyResource            = new AccessibilityFamilyResource(
                resourceCode: "ACC1",
                selections: ImmutableArray <AccessibilityFamilySelection> .Empty,
                disabled: false,
                defaultSelection: null);

            resource.Add(familyResource);

            AccessibilityFamily noPartialResources = new AccessibilityFamily(
                subjects: new ImmutableArray <string>(),
                grades: GradeLevels.NA,
                resources: resource);
            AccessibilityResource        inputResource  = Resources[1];
            List <AccessibilityResource> inputResources = new List <AccessibilityResource>
            {
                inputResource
            };

            var resultResources = AccessibilityResourceTranslation.MergeGlobalResources(noPartialResources, inputResources);

            Assert.Equal(inputResources.Count, resultResources.Resources.Count());

            AccessibilityResource outputResource = resultResources.Resources[0];

            Assert.Equal(inputResource.CurrentSelectionCode, outputResource.CurrentSelectionCode);
            Assert.Equal(inputResource.Description, outputResource.Description);
            Assert.Equal(inputResource.Disabled, outputResource.Disabled);
            Assert.Equal(inputResource.DefaultSelection, outputResource.DefaultSelection);
            Assert.Equal(inputResource.Order, outputResource.Order);
            Assert.Equal(inputResource.Selections.Count(), outputResource.Selections.Length);
        }
コード例 #2
0
        /// <summary>
        /// Disables accessibility resources for special cases:
        ///     - ASL is disabled by itemMetadata flag
        ///     - Calculator is disabled if metadata flag or resource is disabled
        ///     - GlobalNotes is only enabled for performance task items
        ///     - EnglishDictionary and Thesaurus are only enabled for WER items
        /// </summary>
        public static AccessibilityResource ApplyFlags(
            this AccessibilityResource resource,
            ItemDigest itemDigest,
            string interactionType,
            bool isPerformanceTask,
            List <string> dictionarySupportedItemTypes,
            IEnumerable <string> supportedBraille,
            Claim claim,
            bool aslSupported)
        {
            if (itemDigest == null || resource.Disabled)
            {
                return(resource);
            }

            bool isUnsupportedAsl                 = !aslSupported && resource.ResourceCode == "AmericanSignLanguage";
            bool isUnsupportedCalculator          = (!itemDigest.AllowCalculator || resource.Disabled) && resource.ResourceCode == "Calculator";
            bool isUnsupportedGlobalNotes         = !isPerformanceTask && resource.ResourceCode == "GlobalNotes";
            bool isUnsupportedDictionaryThesaurus = !dictionarySupportedItemTypes.Any(s => s == interactionType) &&
                                                    (resource.ResourceCode == "EnglishDictionary" || resource.ResourceCode == "Thesaurus");
            bool isUnsupportedClosedCaptioning = !(claim?.ClaimNumber == "3" && itemDigest.SubjectCode == "ELA") && resource.ResourceCode == "ClosedCaptioning";

            if (isUnsupportedAsl || isUnsupportedCalculator || isUnsupportedGlobalNotes || isUnsupportedDictionaryThesaurus || isUnsupportedClosedCaptioning)
            {
                var newResource = resource.ToDisabled();
                return(newResource);
            }
            else if (resource.ResourceCode == "BrailleType")
            {
                return(resource.DisableUnsupportedBraille(supportedBraille));
            }

            return(resource);
        }
コード例 #3
0
        public static ImmutableArray <AccessibilityResource> ToGlobalAccessibilityResources(
            this IEnumerable <XElement> singleSelectResources)
        {
            var accessibilityResources = singleSelectResources
                                         .Select(xs => AccessibilityResource.Create(xs))
                                         .Where(a => a.Selections.Any())
                                         .OrderBy(a => a.Order)
                                         .ToImmutableArray();

            return(accessibilityResources);
        }
コード例 #4
0
        private static AccessibilityResource ApplyCookie(this AccessibilityResource resource, Dictionary <string, string> cookie)
        {
            string newSelectedCode;

            if (cookie.TryGetValue(resource.ResourceCode, out newSelectedCode))
            {
                return(resource.ApplySelectedCode(newSelectedCode));
            }

            return(resource);
        }
コード例 #5
0
        private static AccessibilityResource ApplyIsaap(this AccessibilityResource resource, string[] isaap)
        {
            var issapSelection = resource.Selections.FirstOrDefault(sel => isaap.Contains(sel.SelectionCode));

            if (issapSelection == null)
            {
                return(resource);
            }

            return(resource.ApplySelectedCode(issapSelection.SelectionCode));
        }
コード例 #6
0
        private static AccessibilityResource ApplySelectedCode(this AccessibilityResource resource, string code)
        {
            var newSelection = resource.Selections.FirstOrDefault(sel => sel.SelectionCode.Equals(code));

            if (newSelection == null || newSelection.Disabled)
            {
                return(resource);
            }

            var newResource = resource.WithCurrentSelection(newSelection.SelectionCode);

            return(newResource);
        }
コード例 #7
0
        /// <summary>
        /// Helper test method to build a single resource with the given code
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public AccessibilityResource getResourceWithCode(string code, bool isDisabled)
        {
            AccessibilityResource resource = AccessibilityResource.Create(
                resourceCode: code,
                disabled: isDisabled,
                selections: ImmutableArray.Create(
                    new AccessibilitySelection(
                        code: "ACC1_SEL1",
                        order: 1,
                        disabled: true,
                        label: "Selection 1",
                        hidden: false)));

            return(resource);
        }
コード例 #8
0
        /// <summary>
        /// Tests that a global accessibility resource copy is not modified
        /// from the original given a partial accessibility resource that
        /// contains all of the select elements
        /// </summary>
        [Fact] public void TestToAccessibilityResourceNoChanges()
        {
            AccessibilityResource       globalResource  = Resources[1];
            AccessibilityFamilyResource partialResource = new AccessibilityFamilyResource(
                resourceCode: "ACC1",
                selections: ImmutableArray.Create(
                    AccessibilityFamilySelection.Create(code: "ACC2_SEL1"),
                    AccessibilityFamilySelection.Create(code: "ACC2_SEL2")),
                disabled: false,
                defaultSelection: null);

            AccessibilityResource outputResource = AccessibilityResourceTranslation
                                                   .MergeGlobalResource(partialResource, globalResource);

            Assert.Equal(globalResource.CurrentSelectionCode, outputResource.CurrentSelectionCode);
            Assert.Equal(globalResource.Disabled, outputResource.Disabled);
            Assert.Equal(globalResource.Label, outputResource.Label);
            Assert.Equal(globalResource.DefaultSelection, outputResource.DefaultSelection);
            Assert.Equal(globalResource.Selections.Count(), outputResource.Selections.Count());
        }
コード例 #9
0
        public void TestToAccessibilityDisabledAllSelections()
        {
            AccessibilityResource       globalResource  = Resources[1];
            AccessibilityFamilyResource partialResource = new AccessibilityFamilyResource(
                resourceCode: "ACC2",
                selections: ImmutableArray <AccessibilityFamilySelection> .Empty,
                disabled: false,
                defaultSelection: null);

            AccessibilityResource outputResource = AccessibilityResourceTranslation
                                                   .MergeGlobalResource(partialResource, globalResource);

            Assert.Equal(globalResource.CurrentSelectionCode, outputResource.CurrentSelectionCode);
            Assert.Equal(false, outputResource.Disabled);
            Assert.Equal(globalResource.Label, outputResource.Label);
            Assert.Equal(globalResource.Selections.Count(), outputResource.Selections.Count());
            foreach (var sel in outputResource.Selections)
            {
                Assert.Equal(true, sel.Disabled);
            }
        }
コード例 #10
0
        public void TestToAccessibilityDisabledSomeSelections()
        {
            AccessibilityResource       globalResource  = Resources[1];
            AccessibilityFamilyResource partialResource = new AccessibilityFamilyResource(
                resourceCode: "TDS_CC",
                disabled: false,
                defaultSelection: null,
                selections: ImmutableArray.Create(AccessibilityFamilySelection.Create(code: "ACC2_SEL1")));

            AccessibilityResource outputResource = AccessibilityResourceTranslation
                                                   .MergeGlobalResource(partialResource, globalResource);

            Assert.Equal("ACC2_SEL1", outputResource.CurrentSelectionCode);
            Assert.Equal(false, outputResource.Disabled);
            Assert.Equal(globalResource.Label, outputResource.Label);

            // Check that default selection was also updated
            Assert.Equal("ACC2_SEL1", outputResource.DefaultSelection);

            Assert.Equal(globalResource.Selections.Length, outputResource.Selections.Length);
            Assert.Equal(false, outputResource.Selections[0].Disabled);
            Assert.Equal(true, outputResource.Selections[1].Disabled);
        }
コード例 #11
0
        public static AccessibilityResource MergeGlobalResource(AccessibilityFamilyResource familyResource, AccessibilityResource globalResource)
        {
            if (familyResource == null)
            {
                throw new ArgumentNullException(nameof(familyResource));
            }
            else if (globalResource == null)
            {
                throw new ArgumentNullException(nameof(globalResource));
            }

            var newSelections = globalResource.Selections
                                .Select(sel => MergeSelection(sel, familyResource))
                                .ToImmutableArray();

            string defaultSelection = (!string.IsNullOrEmpty(familyResource.DefaultSelection)) ? familyResource.DefaultSelection : globalResource.DefaultSelection;

            var  matchingSelection = newSelections.FirstOrDefault(s => s.SelectionCode == defaultSelection);
            bool isDefaultInvalid  = matchingSelection == null || matchingSelection.Disabled;

            string newDefault = isDefaultInvalid
                ? newSelections.FirstOrDefault(s => !s.Disabled && !s.Hidden)?.SelectionCode ?? defaultSelection
                : defaultSelection;

            var newResource = new AccessibilityResource(
                resourceCode: globalResource.ResourceCode,
                currentSelectionCode: newDefault,
                order: globalResource.Order,
                defaultSelection: newDefault,
                selections: newSelections,
                label: globalResource.Label,
                description: globalResource.Description,
                disabled: familyResource.Disabled,
                resourceType: globalResource.ResourceTypeId);

            return(newResource);
        }
コード例 #12
0
        public void TestToAccessibilityDisabledResource()
        {
            AccessibilityResource       globalResource  = Resources[1];
            AccessibilityFamilyResource partialResource = new AccessibilityFamilyResource(
                resourceCode: "ACC2",
                disabled: true,
                defaultSelection: null,
                selections: ImmutableArray.Create(
                    AccessibilityFamilySelection.Create(code: "ACC2_SEL1"),
                    AccessibilityFamilySelection.Create(code: "ACC2_SEL2")));

            AccessibilityResource outputResource = AccessibilityResourceTranslation.MergeGlobalResource(partialResource, globalResource);

            Assert.Equal(globalResource.CurrentSelectionCode, outputResource.CurrentSelectionCode);
            Assert.True(outputResource.Disabled);
            Assert.Equal(globalResource.Label, outputResource.Label);
            Assert.Equal(globalResource.DefaultSelection, outputResource.DefaultSelection);
            Assert.Equal(globalResource.Selections.Length, outputResource.Selections.Length);

            foreach (var sel in outputResource.Selections)
            {
                Assert.True(sel.Disabled);
            }
        }
コード例 #13
0
        public SampleItemTranslationTests()
        {
            rubricEntries = new List <RubricEntry>()
            {
                new RubricEntry
                {
                    Scorepoint = "0",
                    Name       = "TestName",
                    Value      = "TestValue"
                },
                new RubricEntry
                {
                    Scorepoint = "1",
                    Name       = "TestName1",
                    Value      = "TestValue1"
                }
            };

            var sampleResponces = new List <SampleResponse>()
            {
                new SampleResponse()
                {
                    Purpose       = "TestPurpose",
                    ScorePoint    = "0",
                    Name          = "TestName",
                    SampleContent = "TestSampleContent"
                },
                new SampleResponse()
                {
                    Purpose       = "TestPurpose1",
                    ScorePoint    = "1",
                    Name          = "TestName1",
                    SampleContent = "TestSampleContent1"
                }
            };

            rubricSamples = new List <RubricSample>()
            {
                new RubricSample
                {
                    MaxValue        = "MaxVal",
                    MinValue        = "MinVal",
                    SampleResponses = sampleResponces
                },
                new RubricSample
                {
                    MaxValue        = "MaxVal1",
                    MinValue        = "MinVal1",
                    SampleResponses = new List <SampleResponse>()
                }
            };

            rubricList = new RubricList()
            {
                Rubrics       = rubricEntries,
                RubricSamples = rubricSamples
            };

            Resources = new List <AccessibilityResource>
            {
                AccessibilityResource.Create(
                    resourceCode: "ACC1",
                    order: 1,
                    disabled: false,
                    defaultSelection: "ACC1_SEL1",
                    currentSelectionCode:  "ACC1_SEL1",
                    label: "Accessibility 1",
                    description: "Accessibility Selection One",
                    resourceType: "Acc1Type",
                    selections: ImmutableArray.Create(
                        new AccessibilitySelection(
                            code: "ACC1_SEL1",
                            order: 1,
                            disabled: false,
                            label: "Selection 1",
                            hidden: false))),
                AccessibilityResource.Create(
                    resourceCode: "ACC2",
                    order: 2,
                    disabled: false,
                    defaultSelection: "ACC2_SEL2",
                    currentSelectionCode:  "ACC2_SEL2",
                    label: "Accessibility 2",
                    description: "Accessibility Selection Two",
                    resourceType: "Acc2Type",
                    selections: ImmutableArray.Create(
                        new AccessibilitySelection(
                            code: "ACC2_SEL1",
                            order: 1,
                            disabled: false,
                            label: "Selection 1",
                            hidden: false),
                        new AccessibilitySelection(
                            code: "ACC2_SEL2",
                            order: 2,
                            disabled: false,
                            label: "Selection 2",
                            hidden: false)))
            };

            accessibilityType       = new AccessibilityType();
            accessibilityType.Id    = "Acc1Type";
            accessibilityType.Label = "Accessibility 1";
            accessibilityType.Order = 1;

            int    testItemKey  = 1;
            int    testItemBank = 2;
            string testGrade    = "5";

            metadata                                    = new ItemMetadata();
            contents                                    = new ItemContents();
            metadata.Metadata                           = new SmarterAppMetadataXmlRepresentation();
            contents.Item                               = new ItemXmlFieldRepresentation();
            metadata.Metadata.ItemKey                   = testItemKey;
            metadata.Metadata.GradeCode                 = testGrade;
            metadata.Metadata.TargetAssessmentType      = "Test target string";
            metadata.Metadata.SufficientEvidenceOfClaim = "Test claim string";
            metadata.Metadata.InteractionType           = "2";
            metadata.Metadata.SubjectCode               = "MATH";
            metadata.Metadata.MaximumNumberOfPoints     = 2;
            metadata.Metadata.StandardPublications      = new List <StandardPublication>();
            metadata.Metadata.StandardPublications.Add(
                new StandardPublication
            {
                PrimaryStandard = "SBAC-ELA-v1:3-L|4-6|6.SL.2",
                Publication     = "SupportedPubs"
            });

            contents.Item.ItemKey  = testItemKey;
            contents.Item.ItemBank = testItemBank;
            contents.Item.Contents = new List <Content>();
            var placeholderText = new RubricPlaceHolderText
            {
                RubricPlaceHolderContains = new string[] { "RubricSampleText", "RubricSampleText1" },
                RubricPlaceHolderEquals   = new string[0]
            };

            settings = new SettingsConfig
            {
                SupportedPublications = new string[] { "SupportedPubs" },
                AccessibilityTypes    = new List <AccessibilityType>()
                {
                    accessibilityType
                },
                InteractionTypesToItem       = new Dictionary <string, string>(),
                DictionarySupportedItemTypes = new List <string>(),
                LanguageToLabel = new Dictionary <string, string>()
            };

            appSettings = new AppSettings
            {
                SettingsConfig        = settings,
                RubricPlaceHolderText = placeholderText
            };

            digest = ItemDigestTranslation.ToItemDigest(metadata, contents, appSettings);
        }
コード例 #14
0
        public AccessibilityTranslationTests()
        {
            Resources = new List <AccessibilityResource>
            {
                AccessibilityResource.Create(
                    resourceCode: "ACC1",
                    order: 1,
                    disabled: false,
                    defaultSelection: "ACC1_SEL1",
                    currentSelectionCode:  "ACC1_SEL1",
                    label: "Accessibility 1",
                    description: "Accessibility Selection One",
                    selections: ImmutableArray.Create(
                        new AccessibilitySelection(
                            code: "ACC1_SEL1",
                            order: 1,
                            disabled: false,
                            label: "Selection 1",
                            hidden: false))),
                AccessibilityResource.Create(
                    resourceCode: "ACC2",
                    order: 2,
                    disabled: false,
                    defaultSelection: "ACC2_SEL2",
                    currentSelectionCode:  "ACC2_SEL2",
                    label: "Accessibility 2",
                    description: "Accessibility Selection Two",
                    selections: ImmutableArray.Create(
                        new AccessibilitySelection(
                            code: "ACC2_SEL1",
                            order: 1,
                            disabled: false,
                            label: "Selection 1",
                            hidden: false),
                        new AccessibilitySelection(
                            code: "ACC2_SEL2",
                            order: 2,
                            disabled: false,
                            label: "Selection 2",
                            hidden: false)))
            };

            PartialResources = new List <AccessibilityResource>
            {
                AccessibilityResource.Create(
                    resourceCode: "ACC1",
                    selections: ImmutableArray.Create(
                        AccessibilitySelection.Create(
                            code: "ACC1_SEL1",
                            label: "Selection 1"))),
                AccessibilityResource.Create(
                    resourceCode: "ACC2",
                    selections: ImmutableArray.Create(
                        AccessibilitySelection.Create(
                            code: "ACC1_SEL1",
                            label: "Selection 1"),
                        AccessibilitySelection.Create(
                            code: "ACC1_SEL2",
                            label: "Selection 2"))),
            };

            familyResource = new AccessibilityFamilyResource(
                resourceCode: "TDS_CC",
                selections: ImmutableArray <AccessibilityFamilySelection> .Empty,
                disabled: false,
                defaultSelection: null);

            globalResource = new AccessibilityResource(
                resourceCode: "TDS_CC",
                currentSelectionCode: "TDS_CC0",
                order: 5,
                defaultSelection: "TDS_CC0",
                selections: ImmutableArray.Create(
                    new AccessibilitySelection("TDS_CC0", "Black on White", 2, false, false),
                    new AccessibilitySelection("TDS_CCInvert", "Reverse Contrast", 2, false, false),
                    new AccessibilitySelection("TDS_CCMagenta", "Black on Rose", 2, false, false),
                    new AccessibilitySelection("TDS_CCMedGrayLtGray", "Medium Gray on Light Gray", 2, false, false)),
                label: "globalResource",
                description: "globalResource",
                disabled: false,
                resourceType: "globalResource Type");
        }