コード例 #1
0
        public override IEnumerable <IVersionable> Build(IEnumerable <IVersionable> ws)
        {
            Collection <IVersionable> allItems = getAllItems();

            var rp  = allItems.OfType <ResourcePackage>().First();
            var qcs = new ControlConstructScheme();

            qcs.ItemName.Add("en-GB", "Topic Question Construct Groups");
            qcs.UserIds.Add(new UserId("closerid", "topics-ccs-000001"));
            var vs = new VariableScheme();

            vs.ItemName.Add("en-GB", "Topic Variable Groups");
            vs.UserIds.Add(new UserId("closerid", "topics-vs-000001"));
            rp.ControlConstructSchemes.Add(qcs);
            rp.VariableSchemes.Add(vs);
            allItems.Add(qcs);
            allItems.Add(vs);

            var concept_lookup_q = new Dictionary <Concept, ControlConstructGroup>();
            var concept_lookup_v = new Dictionary <Concept, VariableGroup>();

            foreach (var concept in allItems.OfType <Concept>().ToList())
            {
                var qcg = new ControlConstructGroup();
                qcg.TypeOfGroup = "ConceptGroup";
                qcg.Concept     = concept;
                qcg.Label.Add("en-GB", concept.Label.Best + " Question Construct Group");
                qcg.ItemName.Add("en-GB", concept.ItemName.Best);
                qcg.UserIds.Add(new UserId("closerid", "topics-qcg-" + concept.ItemName.Best.ToLower()));

                concept_lookup_q[concept] = qcg;

                foreach (var parent_concept in concept.SubclassOf)
                {
                    concept_lookup_q[parent_concept].ChildGroups.Add(qcg);
                }

                qcs.ControlConstructGroups.Add(qcg);
                allItems.Add(qcg);

                var vg = new VariableGroup();
                vg.TypeOfGroup = "ConceptGroup";
                vg.Concept     = concept;
                vg.Label.Add("en-GB", concept.Label.Best + " Variable Group");
                vg.ItemName.Add("en-GB", concept.ItemName.Best);

                concept_lookup_v[concept] = vg;

                foreach (var parent_concept in concept.SubclassOf)
                {
                    concept_lookup_v[parent_concept].ChildGroups.Add(vg);
                }

                vs.VariableGroups.Add(vg);
                allItems.Add(vg);
            }

            return(allItems);
        }
コード例 #2
0
        private void CreateQuestionGroups()
        {
            //Get concepts that are used, add the implicit ones and except for "0" create question groups from them in the relevant question scheme and put into the working set
            this.usedConcepts = questionsConcepts.Values.Distinct().ToList();

            //add implicit level-1 groups that are parents of level-2 groups
            var implicits = new List <string>();

            foreach (var uc in this.usedConcepts)
            {
                if (uc.Length == 1 + 2 + 2)
                {
                    if (!usedConcepts.Contains(uc.Substring(0, 3)))
                    {
                        implicits.Add(uc.Substring(0, 3));
                    }
                }
            }
            this.usedConcepts.AddRange(implicits.Distinct());

            //get the concept scheme from the repository
            //I assume there is only one
            //if there is none, get concepts from the working set
            ConceptScheme qcgConceptScheme = new ConceptScheme();
            var           client           = Utility.GetClient();
            var           facet            = new SearchFacet();

            facet.ItemTypes.Add(DdiItemType.ConceptScheme);
            SearchResponse response = client.Search(facet);
            bool           fromRepo = false;

            if (response.ReturnedResults > 0)
            {
                fromRepo         = true;
                qcgConceptScheme = client.GetItem(response.Results[0].CompositeId, ChildReferenceProcessing.Populate) as ConceptScheme;
            }

            var controlConstructScheme = WorkingSet.OfType <ControlConstructScheme>().Where(x => string.Compare(x.ItemName.Best, this.qcsName, ignoreCase: true) == 0).First();

            foreach (var uc in this.usedConcepts)
            {
                if (uc != "0")
                {
                    ControlConstructGroup qcg = new ControlConstructGroup();
                    qcg.TypeOfGroup = "ConceptGroup";
                    Concept qcgConcept = new Concept();
                    if (fromRepo)
                    {
                        qcgConcept = qcgConceptScheme.Concepts.Where(x => string.Compare(x.ItemName.Best, uc, ignoreCase: true) == 0).First();
                    }
                    else    //from working set
                    {
                        qcgConcept = WorkingSet.OfType <Concept>().Where(x => string.Compare(x.ItemName.Best, uc, ignoreCase: true) == 0).First();
                    }
                    qcg.Concept = qcgConcept;
                    qcg.ItemName.Add("en-GB", "Question Construct Group - " + qcgConcept.Label.Best);
                    //Trace.WriteLine("   " + qcg.ItemName.Best);
                    controlConstructScheme.ControlConstructGroups.Add(qcg);
                }
            }
            WorkingSet.AddRange(controlConstructScheme.ControlConstructGroups);
            Trace.WriteLine("  question construct groups: " + controlConstructScheme.ControlConstructGroups.Count().ToString() + " for " + this.qcsName);
        }
コード例 #3
0
        private void CreateQuestionGroups()
        {
            //Get concepts that are used, add the implicit ones and except for "0" create question groups from them in the relevant question scheme and put into the working set
            this.usedConcepts = questionsConcepts.Values.Distinct().ToList();

            //add implicit level-1 groups that are parents of level-2 groups
            var implicits = new List<string>();
            foreach (var uc in this.usedConcepts)
            {
                if (uc.Length == 1 + 2 + 2)
                {
                    if (!usedConcepts.Contains(uc.Substring(0, 3)))
                    {
                        implicits.Add(uc.Substring(0, 3));
                    }
                }
            }
            this.usedConcepts.AddRange(implicits.Distinct());

            //get the concept scheme from the repository
            //I assume there is only one
            //if there is none, get concepts from the working set
            ConceptScheme qcgConceptScheme = new ConceptScheme();
            var client = Utility.GetClient();
            var facet = new SearchFacet();
            facet.ItemTypes.Add(DdiItemType.ConceptScheme);
            SearchResponse response = client.Search(facet);
            bool fromRepo = false;
            if (response.ReturnedResults > 0)
            {
                fromRepo = true;
                qcgConceptScheme = client.GetItem(response.Results[0].CompositeId, ChildReferenceProcessing.Populate) as ConceptScheme;
            }

            var controlConstructScheme = WorkingSet.OfType<ControlConstructScheme>().Where(x => string.Compare(x.ItemName.Best, this.qcsName, ignoreCase: true) == 0).First();
            foreach (var uc in this.usedConcepts)
            {
                if (uc != "0")
                {
                    ControlConstructGroup qcg = new ControlConstructGroup();
                    qcg.TypeOfGroup = "ConceptGroup";
                    Concept qcgConcept = new Concept();
                    if (fromRepo)
                    {
                        qcgConcept = qcgConceptScheme.Concepts.Where(x => string.Compare(x.ItemName.Best, uc, ignoreCase: true) == 0).First();
                    }
                    else    //from working set
                    {
                        qcgConcept = WorkingSet.OfType<Concept>().Where(x => string.Compare(x.ItemName.Best, uc, ignoreCase: true) == 0).First();
                    }
                    qcg.Concept = qcgConcept;
                    qcg.ItemName.Add("en-GB", "Question Construct Group - " + qcgConcept.Label.Best);
                    //Trace.WriteLine("   " + qcg.ItemName.Best);
                    controlConstructScheme.ControlConstructGroups.Add(qcg);
                }
            }
            WorkingSet.AddRange(controlConstructScheme.ControlConstructGroups);
            Trace.WriteLine("  question construct groups: " + controlConstructScheme.ControlConstructGroups.Count().ToString() + " for " + this.qcsName);
        }