Exemple #1
0
 public static SampleItem Create(
     int bankKey       = -1,
     int itemKey       = -1,
     string itemType   = "",
     GradeLevels grade = GradeLevels.NA,
     Subject subject   = null,
     Claim claim       = null,
     ImmutableArray <Rubric> rubrics = new ImmutableArray <Rubric>(),
     InteractionType interactionType = null,
     ImmutableArray <AccessibilityResourceGroup> accessibilityResourceGroups = new ImmutableArray <AccessibilityResourceGroup>(),
     string targetAssessmentType     = "",
     string sufficentEvidenceOfClaim = "",
     int?associatedStimulus          = -1,
     bool aslSupported                           = false,
     bool allowCalculator                        = false,
     string depthOfKnowledge                     = "",
     bool isPerformanceItem                      = false,
     CoreStandards coreStandards                 = null,
     FieldTestUse fieldTestUse                   = null,
     string interactionTypeSubCat                = "",
     ImmutableArray <string> brailleItemCodes    = new ImmutableArray <string>(),
     ImmutableArray <string> braillePassageCodes = new ImmutableArray <string>(),
     bool brailleOnlyItem                        = false,
     int?copiedFromItem                          = null)
 {
     return(new SampleItem(
                bankKey,
                itemKey,
                itemType,
                grade,
                subject,
                claim,
                rubrics,
                interactionType,
                accessibilityResourceGroups,
                targetAssessmentType,
                sufficentEvidenceOfClaim,
                associatedStimulus,
                aslSupported,
                allowCalculator,
                depthOfKnowledge,
                isPerformanceItem,
                coreStandards,
                fieldTestUse,
                interactionTypeSubCat,
                brailleItemCodes,
                braillePassageCodes,
                brailleOnlyItem,
                copiedFromItem
                ));
 }
Exemple #2
0
 public SampleItem(
     int bankKey,
     int itemKey,
     string itemType,
     GradeLevels grade,
     Subject subject,
     Claim claim,
     ImmutableArray <Rubric> rubrics,
     InteractionType interactionType,
     ImmutableArray <AccessibilityResourceGroup> accessibilityResourceGroups,
     string targetAssessmentType,
     string sufficentEvidenceOfClaim,
     int?associatedStimulus,
     bool aslSupported,
     bool allowCalculator,
     string depthOfKnowledge,
     bool isPerformanceItem,
     CoreStandards coreStandards,
     FieldTestUse fieldTestUse,
     string interactionTypeSubCat,
     ImmutableArray <string> brailleItemCodes,
     ImmutableArray <string> braillePassageCodes,
     bool brailleOnlyItem,
     int?copiedFromitem
     )
 {
     BankKey                     = bankKey;
     ItemKey                     = itemKey;
     ItemType                    = itemType;
     Grade                       = grade;
     Subject                     = subject;
     Claim                       = claim;
     Rubrics                     = rubrics;
     InteractionType             = interactionType;
     AccessibilityResourceGroups = accessibilityResourceGroups;
     TargetAssessmentType        = targetAssessmentType;
     SufficentEvidenceOfClaim    = sufficentEvidenceOfClaim;
     AssociatedStimulus          = associatedStimulus;
     AslSupported                = aslSupported;
     AllowCalculator             = allowCalculator;
     DepthOfKnowledge            = depthOfKnowledge;
     IsPerformanceItem           = isPerformanceItem;
     CoreStandards               = coreStandards;
     FieldTestUse                = fieldTestUse;
     InteractionTypeSubCat       = interactionTypeSubCat;
     BrailleItemCodes            = brailleItemCodes;
     BraillePassageCodes         = braillePassageCodes;
     CopiedFromItem              = copiedFromitem;
     BrailleOnlyItem             = brailleOnlyItem;
 }
        private static FieldTestUse ApplyPatchFieldTestUse(FieldTestUse fieldTestUse, ItemPatch patch)
        {
            int patchQuestion;

            int.TryParse(patch.QuestionNumber, out patchQuestion);

            var newFieldTestUse = new FieldTestUse
            {
                Code           = fieldTestUse?.Code,
                CodeYear       = fieldTestUse?.CodeYear,
                QuestionNumber = patchQuestion,
                Section        = fieldTestUse?.Section
            };

            return(newFieldTestUse);
        }
        public ItemViewRepoTests()
        {
            GoodBankKey      = 1;
            BadBankKey       = 3;
            BadItemKey       = 9;
            GoodItemKey      = 4;
            DuplicateBankKey = 5;
            DuplicateItemKey = 6;
            MathCard         = ItemCardViewModel.Create(bankKey: GoodBankKey, itemKey: GoodItemKey);
            ElaCard          = ItemCardViewModel.Create(bankKey: BadBankKey, itemKey: BadItemKey);
            DuplicateCard    = ItemCardViewModel.Create(bankKey: DuplicateBankKey, itemKey: DuplicateItemKey);
            MathDigest       = SampleItem.Create(bankKey: GoodBankKey, itemKey: GoodItemKey);
            ElaDigest        = SampleItem.Create(bankKey: BadBankKey, itemKey: BadItemKey);

            fieldTestUseVar                = new FieldTestUse();
            fieldTestUseVar.Code           = "ELA";
            fieldTestUseVar.QuestionNumber = 1;

            DuplicateDigest = SampleItem.Create(bankKey: GoodBankKey, itemKey: DuplicateItemKey);
            var duplicateDigest2 = SampleItem.Create(bankKey: GoodBankKey, itemKey: DuplicateItemKey);

            PerformanceDigest          = SampleItem.Create(bankKey: GoodBankKey, itemKey: 209, isPerformanceItem: true, associatedStimulus: 1, fieldTestUse: fieldTestUseVar);
            PerformanceDigestDuplicate = SampleItem.Create(bankKey: DuplicateBankKey, itemKey: 210, isPerformanceItem: true, associatedStimulus: 1, fieldTestUse: fieldTestUseVar);

            BrailleItem = SampleItem.Create(bankKey: GoodBankKey, itemKey: 211, isPerformanceItem: true, associatedStimulus: 1,
                                            fieldTestUse: fieldTestUseVar,
                                            brailleOnlyItem: false,
                                            brailleItemCodes: ImmutableArray.Create("123"),
                                            braillePassageCodes: ImmutableArray.Create("123"));

            BrailleItemDuplicate = SampleItem.Create(bankKey: DuplicateBankKey, itemKey: 212, isPerformanceItem: true, associatedStimulus: 1,
                                                     fieldTestUse: fieldTestUseVar,
                                                     brailleOnlyItem: false,
                                                     brailleItemCodes: ImmutableArray.Create("123"),
                                                     braillePassageCodes: ImmutableArray.Create("123"));

            BrailleItemReplace = SampleItem.Create(bankKey: DuplicateBankKey, itemKey: 213, isPerformanceItem: true, associatedStimulus: 2,
                                                   fieldTestUse: fieldTestUseVar,
                                                   brailleOnlyItem: true,
                                                   brailleItemCodes: ImmutableArray.Create("123"),
                                                   braillePassageCodes: ImmutableArray.Create("123"),
                                                   copiedFromItem: 211);

            SampleItems = ImmutableArray.Create(MathDigest, ElaDigest, DuplicateDigest, DuplicateDigest, DuplicateDigest, PerformanceDigest, PerformanceDigestDuplicate, BrailleItem, BrailleItemDuplicate, BrailleItemReplace);
            var itemCards = ImmutableArray.Create(MathCard, ElaCard, DuplicateCard, DuplicateCard, DuplicateCard);

            Math = new Subject("Math", "", "", new ImmutableArray <Claim>()
            {
            }, new ImmutableArray <string>()
            {
            });
            Ela = new Subject("ELA", "", "", new ImmutableArray <Claim>()
            {
            }, new ImmutableArray <string>()
            {
            });
            NotASubject = new Subject("NotASubject", "", "", new ImmutableArray <Claim>()
            {
            }, new ImmutableArray <string>()
            {
            });
            Claim1 = new Claim("1", "", "");
            Claim2 = new Claim("2", "", "");

            //generated item cards for more like this tests
            itemCards = itemCards.AddRange(MoreItemCards());
            var settings = new AppSettings()
            {
                SettingsConfig = new SettingsConfig()
                {
                    NumMoreLikeThisItems = 3
                }
            };

            Context = SampleItemsContext.Create(sampleItems: SampleItems, itemCards: itemCards, appSettings: settings);

            var loggerFactory = new Mock <ILoggerFactory>();
            var logger        = new Mock <ILogger>();

            loggerFactory.Setup(lf => lf.CreateLogger(It.IsAny <string>())).Returns(logger.Object);
            ItemViewRepo = new ItemViewRepo(Context, loggerFactory.Object);
        }
        /// <summary>
        /// Translates metadata, itemcontents and lookups to item digest
        /// </summary>
        public static SampleItem ToSampleItem(
            ItemDigest itemDigest,
            CoreStandardsXml standardsXml,
            IList <Subject> subjects,
            IList <InteractionType> interactionTypes,
            IList <MergedAccessibilityFamily> resourceFamilies,
            IList <ItemPatch> patches,
            IList <BrailleFileInfo> brailleFileInfo,
            AppSettings settings)
        {
            var supportedPubs       = settings.SettingsConfig.SupportedPublications;
            var rubrics             = GetRubrics(itemDigest, settings);
            var brailleItemCodes    = GetBrailleItemCodes(itemDigest.ItemKey, brailleFileInfo);
            var braillePassageCodes = GetBraillePassageCodes(itemDigest, brailleFileInfo);
            var interactionType     = interactionTypes.FirstOrDefault(t => t.Code == itemDigest.InteractionTypeCode);
            var grade            = GradeLevelsUtils.FromString(itemDigest.GradeCode);
            var patch            = patches.FirstOrDefault(p => p.ItemId == itemDigest.ItemKey);
            var copiedItemPatch  = patches.FirstOrDefault(p => p.BrailleCopiedId == itemDigest.ItemKey.ToString());
            var subject          = subjects.FirstOrDefault(s => s.Code == itemDigest.SubjectCode);
            var depthOfKnowledge = itemDigest.DepthOfKnowledge;
            var itemType         = itemDigest.ItemType;

            var fieldTestUseAttribute = itemDigest.ItemMetadataAttributes?.FirstOrDefault(a => a.Code == "itm_FTUse");
            var fieldTestUse          = FieldTestUse.Create(fieldTestUseAttribute, itemDigest.SubjectCode);

            StandardIdentifier identifier    = StandardIdentifierTranslation.ToStandardIdentifier(itemDigest, supportedPubs);
            CoreStandards      coreStandards = StandardIdentifierTranslation.CoreStandardFromIdentifier(standardsXml, identifier);
            int?copiedFromItem = null;

            if (patch != null)
            {
                int tmp;
                copiedFromItem   = int.TryParse(patch.BrailleCopiedId, out tmp) ? (int?)tmp : null;
                depthOfKnowledge = !string.IsNullOrEmpty(patch.DepthOfKnowledge) ? patch.DepthOfKnowledge : depthOfKnowledge;
                itemType         = !string.IsNullOrEmpty(patch.ItemType) ? patch.ItemType : itemType;
                coreStandards    = ApplyPatchToCoreStandards(identifier, coreStandards, standardsXml, patch);
            }

            if (copiedItemPatch != null)
            {
                var copyBrailleItemCodes = GetBrailleItemCodes(copiedItemPatch.ItemId, brailleFileInfo);
                brailleItemCodes = brailleItemCodes.Concat(copyBrailleItemCodes).Distinct().ToImmutableArray();
            }

            if (patch != null && !string.IsNullOrEmpty(patch.QuestionNumber))
            {
                fieldTestUse = ApplyPatchFieldTestUse(fieldTestUse, patch);
            }

            var  claim         = subject?.Claims.FirstOrDefault(t => t.ClaimNumber == coreStandards.ClaimId);
            bool brailleOnly   = copiedFromItem.HasValue;
            bool isPerformance = fieldTestUse != null && itemDigest.AssociatedPassage.HasValue;

            if (itemDigest.AssociatedPassage.HasValue)
            {
                braillePassageCodes = brailleFileInfo
                                      .Where(f => f.ItemKey == itemDigest.AssociatedPassage.Value)
                                      .Select(b => b.BrailleType).ToImmutableArray();
            }
            else
            {
                braillePassageCodes = ImmutableArray.Create <string>();
            }

            bool aslSupported = AslSupported(itemDigest);

            var groups = GetAccessibilityResourceGroups(itemDigest, resourceFamilies, grade,
                                                        isPerformance, aslSupported, claim, interactionType, brailleItemCodes, settings);

            string interactionTypeSubCat = "";

            settings.SettingsConfig.InteractionTypesToItem.TryGetValue(itemDigest.ToString(), out interactionTypeSubCat);

            SampleItem sampleItem = new SampleItem(
                itemType: itemType,
                itemKey: itemDigest.ItemKey,
                bankKey: itemDigest.BankKey,
                targetAssessmentType: itemDigest.TargetAssessmentType,
                depthOfKnowledge: depthOfKnowledge,
                sufficentEvidenceOfClaim: itemDigest.SufficentEvidenceOfClaim,
                associatedStimulus: itemDigest.AssociatedStimulus,
                aslSupported: aslSupported,
                allowCalculator: itemDigest.AllowCalculator,
                isPerformanceItem: isPerformance,
                accessibilityResourceGroups: groups,
                rubrics: rubrics,
                interactionType: interactionType,
                subject: subject,
                claim: claim,
                grade: grade,
                coreStandards: coreStandards,
                fieldTestUse: fieldTestUse,
                interactionTypeSubCat: interactionTypeSubCat,
                brailleItemCodes: brailleItemCodes,
                braillePassageCodes: braillePassageCodes,
                brailleOnlyItem: brailleOnly,
                copiedFromitem: copiedFromItem);

            return(sampleItem);
        }