Exemplo n.º 1
0
        private bool IsLearningObjectInLearnersCourses(LearningObject learningObject, int learnerId)
        {
            var courseId = _lectureRepository.GetCourseIdByLOId(learningObject.LearningObjectSummaryId);
            var learner  = _learnerRepository.GetById(learnerId);

            return(learner.CourseEnrollments.Any(learnerCourseEnrollment =>
                                                 learnerCourseEnrollment.CourseId == courseId));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 新增学习对象
        /// </summary>
        /// <param name="title">对象名称</param>
        /// <param name="desc">对象描述</param>
        /// <param name="isShare">其他人可见</param>
        /// <param name="lContent">学习内容</param>
        /// <param name="userId">创建者ID</param>
        /// <returns>新增对象的ID</returns>
        public static long AddNewOject(string title, string desc, int isShare, long userId, string lContent)
        {
            var db = new LAActivityEntities();
            var lo = new LearningObject
            {
                Title           = title,
                Description     = desc,
                LearningContent = lContent,
                IsShare         = isShare,
                CreatedBy       = userId,
                CreatedDate     = DateTime.Now
            };

            db.LearningObject.Add(lo);
            db.SaveChanges();
            return(lo.LearningObjectID);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取指定ID的学习对象
        /// </summary>
        /// <param name="loId">学习对象ID</param>
        /// <returns>生成对象详情表</returns>
        public static string GetLObjectById(long loId)
        {
            string         strContent = "<table>";
            var            db         = new LAActivityEntities();
            LearningObject lObjects   = db.LearningObject.FirstOrDefault(lo => lo.LearningObjectID == loId);

            if (lObjects != null)
            {
                strContent += "<tr>";
                strContent += "<td>对象名称:</td><td>" + lObjects.Title + "</td>";
                strContent += "</tr><tr>";
                strContent += "<td>创建时间:</td><td>" + lObjects.CreatedDate + "</td>";
                strContent += "</tr><tr>";
                strContent += "<td>对象描述:</td><td>" + lObjects.Description + "</td>";
                //strContent += "</tr><tr>";
                //strContent += "<td>学习内容:</td><td>" + lObjects.LearningContent + "</td>";
                strContent += "</tr>";
            }
            strContent += "</table>";
            return(strContent);
        }
Exemplo n.º 4
0
        public ITrainer GetTrainer(LearningSubject subject, LearningObject obj, bool useCahce)
        {
            Type learnerType = null;

            switch (obj)
            {
            case LearningObject.Network:
                learnerType = typeof(ILearnableNetwork);
                break;

            case LearningObject.Neuron:
                learnerType = typeof(ILearnableNeuron);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(obj), obj, null);
            }


            return(getTrainer(subject, null, learnerType, useCahce));
        }
        public ActionResult CreateLo(LearningObject incomingLo)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    incomingLo.CreationTime = DateTime.Now;
                    incomingLo.LastModifiedTime = DateTime.Now;

                    var obj = ViewData["CustomUser"];
                    if (obj != null)
                    {
                        User currentUser = obj as User;
                        if (currentUser == null)
                        {
                            _logger.Trace("Error during LO saving: currentUser == null");
                            MessageOnPage errormsg = new MessageOnPage(" Error with current user identification");
                            return RedirectToAction("MessagePage", "Home", errormsg);
                        }

                        incomingLo.AuthorEmail = currentUser.Email;

                        _dbContext.LOs.InsertOneAsync(incomingLo);
                        _logger.Trace("User: "******" succesfully created LO");
                        return RedirectToAction("LOList", "Home");
                    }
                    else
                    {
                        _logger.Trace("Error during new LO saving: user cookies are corrupted or user are not log in");
                        throw new Exception("User cookies are corrupted or user are not log in");
                    }
                }
                catch (Exception ex)
                {
                    _logger.Trace("Error during new LO saving: " + ex.Message);
                    string exceptionMessage = ex.Message;
                    string wholeMessage = @"<script language=""javascript"">alert('\n" + "Error during saving to database\n" + exceptionMessage + @"\n')</script>";
                    Response.Write(wholeMessage);
                }
            }
            return View(incomingLo);
        }
 public ActionResult CreateLo()
 {
     _logger.Trace("New LO creating page requested");
     LearningObject lo = new LearningObject();
     return View(lo);
 }
        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);
            }
        }
        public ActionResult SetDomainToLO(LearningObject lo)
        {
            string domainId = Request["selectedDomainId"];
            ObjectId id;
            if (ObjectId.TryParse(domainId, out id))
            {
                var domain = _dbContext.DomainsCollection.Find(x => x.Id == id).SingleOrDefaultAsync().Result;
                if (domain != null)
                {
                    lo.Domain = domain;
                }
            }

            if (lo.Id == ObjectId.Empty)
            {
                _logger.Trace("Choosed domain:" + domainId + " for LO during LO creating");
                return View("CreateLO", lo);
            }
            else
            {
                _logger.Trace("Choosed domain: " + domainId + " for LO during LO editing");
                return View("EditLO", lo);
            }
        }
        public ActionResult RemovePrerequisiteFromLO(LearningObject lo)
        {
            string idOfRelationEnd = Request["prerequisiteId"];
            ObjectId id = ObjectId.Parse(idOfRelationEnd);

            foreach (var prerequisite in lo.Prerequisites)
            {
                if (prerequisite.KnowledgeId == id)
                {
                    lo.Prerequisites.Remove(prerequisite);
                    break;
                }
            }

            if (lo.Id == ObjectId.Empty)
            {
                _logger.Trace("Removing prerequisite from LO during LO creating.");
                return View("CreateLO", lo);
            }
            else
            {
                _logger.Trace("Removing prerequisite from LO during LO editing.");
                return View("EditLO", lo);
            }
        }
        public ActionResult RemoveOutcomeFromLO(LearningObject lo)
        {
            string idOfRelationEnd = Request["outcomeId"];
            ObjectId id = ObjectId.Parse(idOfRelationEnd);

            foreach (var outcome in lo.Outcomes)
            {
                if (outcome.KnowledgeId == id)
                {
                    lo.Outcomes.Remove(outcome);
                    break;
                }
            }

            if (lo.Id == ObjectId.Empty)
            {
                return View("CreateLO", lo);
            }
            else
            {
                return View("EditLO", lo);
            }
        }
Exemplo n.º 11
0
 public ITrainer GetTrainer(LearningSubject subject, LearningObject obj)
 {
     return(GetTrainer(subject, obj, true));
 }
 public ActionResult CreateLo()
 {
     LearningObject lo = new LearningObject();
     return View(lo);
 }
        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);
            }
        }
Exemplo n.º 14
0
        protected override void Seed(ApplicationDbContext db)
        {
            var progr1 = new ProgressState {
                Name = "Not Started"
            };
            var progr2 = new ProgressState {
                Name = "Started"
            };
            var progr3 = new ProgressState {
                Name = "Complete"
            };

            var filial1 = new Filial {
                Name = "Kiev 01 region"
            };
            var filial2 = new Filial {
                Name = "Kiev 02 region"
            };
            var filial3 = new Filial {
                Name = "Dnipro 01 region"
            };
            var filial4 = new Filial {
                Name = "Kharkiv 01 region"
            };

            var jobPosition1 = new JobPosition {
                Name = "Продавец"
            };
            var jobPosition2 = new JobPosition {
                Name = "Консультант"
            };

            var saleGroup1 = new SaleGroup {
                Code = "SG_INTEL", Name = "Группа продаж Intel"
            };
            var saleGroup2 = new SaleGroup {
                Code = "SG_IBM", Name = "Группа продаж IBM"
            };

            var category1 = new CourseCategory {
                Name = "Технические курсы", Description = "Технические направления"
            };
            var category2 = new CourseCategory {
                Name = "Экономические курсы", Description = "Экономические направления"
            };

            var course1 = new Course {
                Code = "TECH0001", CourseCategory = category1, Title = "C#. Advanced.", SaleGroup = saleGroup1
            };
            var course2 = new Course {
                Code = "ECON0001", CourseCategory = category2, Title = "Маркетинг. Продажа RAID-массивов.", SaleGroup = saleGroup2
            };

            var lo1 = new LearningObject {
                Course = course1, Name = "C# Intro", Description = "KPI", Order = 0
            };
            var lo2 = new LearningObject {
                Course = course1, Name = "Math Functions", Description = "KPI", Order = 1
            };
            var lo3 = new LearningObject {
                Course = course1, Name = "String Operations", Description = "KPI", Order = 2
            };

            var lo4 = new LearningObject {
                Course = course2, Name = "Маркетинг IBM", Description = "eco", Order = 0
            };
            var lo5 = new LearningObject {
                Course = course2, Name = "Карта потребительского рынка", Description = "eco", Order = 1
            };
            var lo6 = new LearningObject {
                Course = course2, Name = "Стратегия продаж", Description = "eco", Order = 2
            };

            var q1 = new Question {
                QuestionTypeId = 1, Content = "Who am I?"
            };

            db.Questions.Add(q1);

            db.Filials.Add(filial1);
            db.Filials.Add(filial2);
            db.Filials.Add(filial3);
            db.Filials.Add(filial4);
            db.JobPositions.Add(jobPosition1);
            db.JobPositions.Add(jobPosition2);
            db.SaleGroups.Add(saleGroup1);
            db.SaleGroups.Add(saleGroup2);
            db.CourseCategories.Add(category1);
            db.CourseCategories.Add(category2);
            db.Courses.Add(course1);
            db.Courses.Add(course2);

            db.LearningObjects.Add(lo1);
            db.LearningObjects.Add(lo2);
            db.LearningObjects.Add(lo3);

            db.LearningObjects.Add(lo4);
            db.LearningObjects.Add(lo5);
            db.LearningObjects.Add(lo6);


            //db.SaveChanges();
        }
 public ActionResult EditLo(LearningObject incomingLo)
 {
     if (ModelState.IsValid)
     {
         try
         {
             incomingLo.LastModifiedTime = DateTime.Now;
             _dbContext.LOs.ReplaceOneAsync(x=>x.Id == incomingLo.Id, incomingLo);
             _logger.Trace("LO editing page query. Save LO");
             return RedirectToAction("LOList", "Home");
         }
         catch (Exception ex)
         {
             _logger.Trace("LO editing page query. Error: " + ex.Message);
             string exceptionMessage = ex.Message;
             string wholeMessage = @"<script language=""javascript"">alert('\n" + "Error during saving to database\n" + exceptionMessage + @"\n')</script>";
             Response.Write(wholeMessage);
         }
     }
     return View(incomingLo);
 }
 public ActionResult EditLo(LearningObject incomingLo)
 {
     if (ModelState.IsValid)
     {
         try
         {
             incomingLo.LastModifiedTime = DateTime.Now;
             _dbContext.LOs.ReplaceOneAsync(x=>x.Id == incomingLo.Id, incomingLo);
             //db.EditLO(incomingLo);
             //MessageOnPage msg = new MessageOnPage("Succes", "LO succesfully added to DB");
             return RedirectToAction("LOList", "Home");
         }
         catch (Exception ex)
         {
             string exceptionMessage = ex.Message;
             string wholeMessage = @"<script language=""javascript"">alert('\n" + "Error during saving to database\n" + exceptionMessage + @"\n')</script>";
             Response.Write(wholeMessage);
         }
     }
     return View(incomingLo);
 }
Exemplo n.º 17
0
 public void Update(LearningObject item)
 {
     throw new NotImplementedException();
 }