コード例 #1
0
        public ActionResult AddSelectedKnowledgesAsPrerequisites(LearningObject lo)
        {
            string stringOfKnowledgesIds = Request["selectedIds"];
            if (!stringOfKnowledgesIds.IsEmpty())
            {
                HashSet<string> listOfKnIds = new HashSet<string>(stringOfKnowledgesIds.Split(',').ToList());
                foreach (var id in listOfKnIds)
                {
                    //var lo = db.GetLOByID(id);
                    var id1 = id;
                    var kn = _dbContext.KnowledgesCollection.Find(x => x.Id == ObjectId.Parse(id1)).SingleOrDefaultAsync().Result;
                    if (kn != null)
                    {
                        var comp = new Competence(kn.Id, BloomLevel.None);
                        if (!lo.Prerequisites.Contains(comp))
                        {
                            lo.Prerequisites.Add(comp);
                        }
                    }
                }
            }

            if (lo.Id == ObjectId.Empty)
            {
                _logger.Trace("Knowledge added to LO as prerequisite during LO creating");
                return View("CreateLO", lo);
            }
            else
            {
                _logger.Trace("Knowledge added to LO as prerequisite during LO editing");
                return View("EditLO", lo);
            }
        }
コード例 #2
0
        public ActionResult AddSelectedKnowledgesAsOutcomes(LearningObject lo)
        {
            string stringOfKnowledgesIds = Request["selectedIds"];
            if (!stringOfKnowledgesIds.IsEmpty())
            {
                HashSet<string> listOfKnIds = new HashSet<string>(stringOfKnowledgesIds.Split(',').ToList());
                foreach (var id in listOfKnIds)
                {
                    //var lo = db.GetLOByID(id);
                    var kn = _dbContext.Ontology.Find(x => x.Id == ObjectId.Parse(id)).SingleOrDefaultAsync().Result;
                    if (kn != null)
                    {
                        Competence comp = new Competence(kn.Id, BloomLevel.None);
                        if (!lo.Outcomes.Contains(comp))
                        {
                            lo.Outcomes.Add(comp);
                        }
                    }
                }
            }

            if (lo.Id == ObjectId.Empty)
            {
                return View("CreateLO", lo);
            }
            else
            {
                return View("EditLO", lo);
            }
        }