示例#1
0
        public void CreateCourses(CoursesModel coursesModel)
        {
            var ownerId = _userManager.FindByNameAsync(coursesModel.Owner).Result;

            string uniqueFileName = null;
            if (coursesModel.Img != null)
            {
                string uploadsFolder = Path.Combine(_hostingEnviroment.WebRootPath, "images");
                uniqueFileName = Guid.NewGuid().ToString() + "_" + coursesModel.Img.FileName;
                string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                coursesModel.Img.CopyTo(new FileStream(filePath, FileMode.Create));
            }
            if (coursesModel.Name != null && ownerId.Id != null)
            {
                _coursesInfoRepo.Create(new CourseInfo
                {
                    Description = coursesModel.Description,
                    MainCourseImgPath = uniqueFileName
                });
                _coursesRepo.Create(new Courses
                {
                    Name = coursesModel.Name,
                    OwnerId = ownerId.Id,
                    IsPublic = coursesModel.IsPublic,
                    IsActive = coursesModel.IsActive,
                    DateOfFinish = coursesModel.Start,
                    DateOfStart = coursesModel.Finish,
                    CourseInfoId = _coursesInfoRepo.Get().Count()
                });
            }
        }
示例#2
0
        public ActionResult Index()
        {
            ViewBag.Showing = "Courses";

            var courses  = _courseRepository.GetCourses();
            var campuses = courses.Select(x => x.Campus).Distinct();

            var model = new CoursesModel
            {
                AllCourses = courses.Select(x => new CourseModel
                {
                    Course   = x,
                    Overview = (x.Overview != null
                      ? _generalHelper.ConvertHtmlToPlainText(x.Overview)
                       : "").Length > summaryLength
                               ? (x.Overview != null
                      ? _generalHelper.ConvertHtmlToPlainText(x.Overview)
                       : "").Substring(0, summaryLength) + "... "
                               : (x.Overview != null
                      ? _generalHelper.ConvertHtmlToPlainText(x.Overview)
                       : "") + "..."
                }),
                Campuses = campuses,
            };

            return(View(model));
        }
示例#3
0
        public static CoursesModel TranslateAsCourses(this SqlDataReader reader, bool isList = false)
        {
            if (!isList)
            {
                if (!reader.HasRows)
                {
                    return(null);
                }
                reader.Read();
            }
            var item = new CoursesModel();

            if (reader.IsColumnExists("Id"))
            {
                item.Id = SqlHelper.GetNullableInt32(reader, "Id");
            }

            if (reader.IsColumnExists("Title"))
            {
                item.Title = SqlHelper.GetNullableString(reader, "Title");
            }

            if (reader.IsColumnExists("Discription"))
            {
                item.Discription = SqlHelper.GetNullableString(reader, "Discription");
            }

            if (reader.IsColumnExists("Section"))
            {
                item.Section = SqlHelper.GetNullableString(reader, "Section");
            }

            return(item);
        }
        public void CanAddNewStudentCourseEnrollment()
        {
            // dummy username (provided by an external accounts
            // data store (e.g. ASP .net membership/authentication)
            string username = "******";

            // Create a dummy course and add it to the database (since the student
            // enrollments model will not allow an enrollment to be added to a student
            // for a course that doesn't exist in the database)
            var dummyCourse = DummyDataGenerator.CreateDummyCourse();
            ICoursesModel courseModel = new CoursesModel();
            dummyCourse.Id = courseModel.AddOrUpdateCourse(dummyCourse).Id;

            // add the new enrollment for the given user and specified course
            IStudentEnrollmentsModel model = new StudentEnrollmentsModel();
            StudentRecord studentEnrollmentRecord = model.AddEnrollment(username, dummyCourse.Id);

            Assert.NotNull(studentEnrollmentRecord);
            Assert.IsNotNullOrEmpty(studentEnrollmentRecord.Username);
            Assert.AreEqual(studentEnrollmentRecord.Username, username);
            Assert.NotNull(studentEnrollmentRecord.StudentCourseEnrollments);
            Assert.AreEqual(studentEnrollmentRecord.StudentCourseEnrollments.Count, 1);

            var enrollments = new List<Enrollment>(studentEnrollmentRecord.StudentCourseEnrollments);
            Assert.AreEqual(enrollments[0].CourseId, dummyCourse.Id);

            // clean up Db:  remove student record
            var enrollmentsRepo = new BizCollegeRepository<StudentRecord, string>();
            enrollmentsRepo.Remove(studentEnrollmentRecord.Username);

            // clean up Db:  remove dummy course
            var coursesRepo = new BizCollegeRepository<Course, string>();
            coursesRepo.Remove(dummyCourse.Id);
        }
示例#5
0
        public void CanGetAllCourses()
        {
            List<Course> dummyCourses = new List<Course>();
            dummyCourses.Add(DummyDataGenerator.CreateDummyCourse());
            dummyCourses.Add(DummyDataGenerator.CreateDummyCourse());

            // Add two dummy courses to the database
            ICoursesModel model = new CoursesModel();
            dummyCourses[0].Id = model.AddOrUpdateCourse(dummyCourses[0]).Id;
            dummyCourses[1].Id = model.AddOrUpdateCourse(dummyCourses[1]).Id;

            // Retrieve all the courses in the database (should be only two we added above)
            var repo = new BizCollegeRepository<Course, string>();
            var allCoursesFromDb = repo.GetAllItems();

            Assert.NotNull(allCoursesFromDb);
            Assert.AreEqual(allCoursesFromDb.Count, dummyCourses.Count);

            foreach (var courseInDb in allCoursesFromDb)
            {
                Assert.IsTrue(dummyCourses.Contains(courseInDb));
            }

            // clean up Db
            repo.Remove(dummyCourses[0].Id);
            repo.Remove(dummyCourses[1].Id);
        }
示例#6
0
        public IActionResult ShowCourses()// показать курсы
        {
            CoursesModel cm = new CoursesModel();

            cm.courses = listcourses;
            return(View(cm));
        }
示例#7
0
        public void CanAddNewCourse()
        {
            var dummyCourse = DummyDataGenerator.CreateDummyCourse();

            // Course Id's are autogenerated by the database, so when we
            // add a new one to the db, we cache the assigned Id after the
            // add operation has completed (that way we can retrieve the course
            // from the db to run our assertions on the data
            ICoursesModel model = new CoursesModel();
            dummyCourse.Id = model.AddOrUpdateCourse(dummyCourse).Id;

            // Retrieve the newly added course back out from the Db
            var repo = new BizCollegeRepository<Course, string>();
            var fromDb = repo.Get(dummyCourse.Id);

            // Check the values against our dummy course
            Assert.NotNull(fromDb);
            Assert.AreEqual(dummyCourse.Id, fromDb.Id);
            Assert.AreEqual(dummyCourse.Name, fromDb.Name);
            Assert.AreEqual(dummyCourse.Description, fromDb.Description);
            Assert.AreEqual(dummyCourse.CreatedByUsername, fromDb.CreatedByUsername);
            Assert.AreEqual(dummyCourse.LastUpdateByUsername, fromDb.LastUpdateByUsername);
            Assert.AreEqual(dummyCourse.CourseSlides.Count, fromDb.CourseSlides.Count);

            // clean-up db
            repo.Remove(fromDb.Id);
        }
示例#8
0
        public FindCourseBaseViewModel()
        {
            DisplayedCourses = new ObservableCollection <CourseViewModel>();
            courseViewModels = new List <CourseViewModel>();

            CoursesModel = new CoursesModel();
            GetDataAsync();
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            CoursesModel coursesModel = db.CoursesModels.Find(id);

            db.CoursesModels.Remove(coursesModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult RemoveSubjectsForSelectedDegree(IEnumerable <Guid> subjects, string selectedDegID, string degree)
        {
            if (degree != null)
            {
                //int degID = int.Parse(degree);
                Guid degID = Guid.Parse(degree);

                Degree_Program deg = r.Degree_Program.Where(s => s.ProgramID == degID).Select(s => s).FirstOrDefault();
                ViewBag.DegreeSelected = deg;
                ViewBag.DegreeName     = deg.Degree_ProgramName;
                var getSubjects = r.Degree_Subject.OrderBy(s => s.ID).Where(s => s.DegreeID == degID).Select(s => s);
                return(View(getSubjects));
            }
            else
            {
                if (subjects != null)
                {
                    try
                    {
                        //int degID = int.Parse(selectedDegID);
                        Guid degID = Guid.Parse(degree);

                        Degree_Program        getDegree    = r.Degree_Program.Where(s => s.ProgramID == degID).Select(s => s).FirstOrDefault();
                        List <Degree_Subject> listToDelete = r.Degree_Subject.Where(s => subjects.Contains(s.SubjectID.Value) &&
                                                                                    s.DegreeID == getDegree.ProgramID).ToList();
                        if (CoursesModel.DeleteRelatedBPSRecordsOnDeletionOfSubjects(listToDelete))
                        {
                            foreach (var item in listToDelete)
                            {
                                r.Degree_Subject.Remove(item);
                            }
                            r.SaveChanges();
                            ViewBag.DegreeSelected = getDegree.Degree_ProgramName;
                            ViewBag.Message        = "Succesfully Subjects Removed";
                            return(View(listToDelete));
                        }
                        else
                        {
                            ViewBag.DegreeSelected = getDegree.Degree_ProgramName;
                            ViewBag.Message        = "Unable To Delete Subjects";
                            return(View(listToDelete));
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                else
                {
                    ViewBag.Message = "Plz Select A Degree First";
                    return(View());
                }
            }
        }
        public AddNewCoursePage()
        {
            InitializeComponent();
            CoursesModel = new CoursesModel
            {
                Id        = "Course ID",
                HeadLines = "Course Name"
            };

            BindingContext = this;
        }
示例#12
0
    protected override void Init()
    {
        base.Init();
        creatorParent = GameObject.Find("UI/CreateGOUI").transform;
        currentCourse = new CoursesModel()
        {
            assetID = CoursesManager.Instance.currentCourse
        };
        GameResourceManager.Instance.LoadConfigData(currentCourse);

        SetCourse(currentCourse);
    }
        public ActionResult AddSubjectsForSelectedDegree(IEnumerable <Guid> subjects, string selectedDegID, string degree)
        {
            if (degree != null)
            {
                Guid           degID = Guid.Parse(degree);
                Degree_Program deg   = r.Degree_Program.Where(s => s.ProgramID == degID).Select(s => s).FirstOrDefault();
                ViewBag.DegreeSelected = deg;
                ViewBag.DegreeName     = deg.Degree_ProgramName
                ;
                var getSubjects = r.Subjects.OrderBy(s => s.SubjectID).Select(s => s);
                return(View(getSubjects));
            }
            else
            {
                if (subjects != null)
                {
                    //int degID = int.Parse(selectedDegID);
                    Guid degID = Guid.Parse(degree);

                    Degree_Program getDegree = r.Degree_Program.Where(s => s.ProgramID == degID).Select(s => s).FirstOrDefault();

                    List <Subject> listToDelete = r.Subjects.Where(s => subjects.Contains(s.SubjectID)).ToList();

                    if (CoursesModel.CheckToSeeIfThereExistARecordWithSameDegreeNameAndSubject(getDegree, listToDelete))
                    {
                        foreach (var item in listToDelete)
                        {
                            r.Degree_Subject.Add(new Degree_Subject
                            {
                                DegreeID  = getDegree.ProgramID,
                                SubjectID = item.SubjectID,
                                ID        = Guid.NewGuid()
                            });
                        }
                        r.SaveChanges();
                        ViewBag.DegreeSelected = getDegree.Degree_ProgramName;
                        ViewBag.Message        = "Succesfully Subjects Assigned";
                        return(View(listToDelete));
                    }
                    else
                    {
                        ViewBag.Message = "The Degree " + getDegree.Degree_ProgramName + " has already assigned some Selected Subjects";
                        return(View(listToDelete));
                    }
                }
                else
                {
                    ViewBag.Message = "Plz Select A Degree First";
                    return(View());
                }
            }
        }
示例#14
0
        public async Task CoursesModelShouldLoadAllCoursesWhenNoCategoryIsSelected()
        {
            //Arrange
            var categories = new ContentfulCollection <Category>();

            categories.Items = new List <Category>()
            {
                new Category()
                {
                    Title = "Cat1",
                    Slug  = "sluggish"
                },
                new Category()
                {
                    Title = "Cat5",
                    Slug  = "another-slug"
                }
            };

            var courses = new ContentfulCollection <Course>();

            courses.Items = new List <Course>()
            {
                new Course()
                {
                    Title = "Course1",
                    Slug  = "bah-slug"
                },
                new Course()
                {
                    Title = "Cruiser2",
                    Slug  = "kah-slug"
                }
            };

            var client = new Mock <IContentfulClient>();

            client.SetupGet(c => c.SerializerSettings).Returns(new JsonSerializerSettings());
            client.Setup(c => c.GetEntries(It.IsAny <QueryBuilder <Course> >(), default(CancellationToken)))
            .Returns(Task.FromResult(courses));
            client.Setup(c => c.GetEntriesByType("category", It.IsAny <QueryBuilder <Category> >(), default(CancellationToken)))
            .Returns(Task.FromResult(categories));
            var crumbs    = new Mock <IBreadcrumbsManager>();
            var localizer = new Mock <IViewLocalizer>();

            var model = new CoursesModel(client.Object, crumbs.Object, localizer.Object);
            //Act
            await model.OnGet(null);

            //Assert
            Assert.Equal(courses, model.Courses);
        }
示例#15
0
 public bool AddCourse([FromBody] CoursesModel CoursesModel)
 {
     try
     {
         CoursesRepository _searchRepository = new CoursesRepository();
         var Result = _searchRepository.AddCourse(CoursesModel);
         return(Result);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#16
0
 public List <EnrolledStudents> GetEnrolledCoursesStudent(CoursesModel Model)
 {
     try
     {
         CoursesRepository _searchRepository = new CoursesRepository();
         var result = _searchRepository.GetEnrolledCoursesStudent(Model.CourseID);
         return(result);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#17
0
 public List <CoursesModel> GetSingleTeachersCourses([FromBody] CoursesModel Model)
 {
     try
     {
         CoursesRepository _searchRepository = new CoursesRepository();
         var result = _searchRepository.GetSingleTeachersCourses(Model.TeacherUsername);
         return(result);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#18
0
 public List <EnrolledStudents> GetExamResult(CoursesModel Model)
 {
     try
     {
         CoursesRepository _searchRepository = new CoursesRepository();
         var result = _searchRepository.GetExamResult(Model.TeacherUsername);
         return(result);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#19
0
 public bool DeleteCourses([FromBody] CoursesModel Model)
 {
     try
     {
         CoursesRepository _searchRepository = new CoursesRepository();
         var result = _searchRepository.DeleteCourses(Model);
         return(result);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
 public ActionResult Edit([Bind(Include = "CourseId,CourseName,DepartmentId,CourseTypeID,CourseIdfk")] CoursesModel coursesModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(coursesModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CourseIdfk   = new SelectList(db.CoursesModels, "CourseId", "CourseName", coursesModel.CourseIdfk);
     ViewBag.CourseTypeID = new SelectList(db.CourseTypesModels, "Id", "coursename", coursesModel.CourseTypeID);
     ViewBag.DepartmentId = new SelectList(db.DepartmentsModels, "DepartmentId", "DepartmentName", coursesModel.DepartmentId);
     return(View(coursesModel));
 }
 public void InstantiateGameObject(CoursesModel model)
 {
     if (model.createModelsAssetID != null)
     {
         model.createModelsAssetID.ForEach((id) =>
         {
             Type modelType      = ReflectionManager.Instance.GetAssetType(id, "gameobject_", "Model") ?? typeof(InteractiveGameObjectModel);
             Type viewType       = ReflectionManager.Instance.GetAssetType(id, "gameobject_", "View") ?? typeof(InteractiveGameObjectView);
             Type controllerType = ReflectionManager.Instance.GetAssetType(id, "gameobject_", "Controller") ?? typeof(InteractiveGameObjectController);
             GameResourceManager.Instance.CreateEntityController(modelType, viewType, controllerType, id);
         });
     }
 }
示例#22
0
        public CourseDetailPage()
        {
            InitializeComponent();

            var course = new CoursesModel
            {
                HeadLines     = "This is a course code",
                HeadLinesDesc = "This is a course description"
            };

            viewModel      = new CourseDetailViewModel(course);
            BindingContext = viewModel;
        }
        // GET: CoursesModels/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CoursesModel coursesModel = db.CoursesModels.Find(id);

            if (coursesModel == null)
            {
                return(HttpNotFound());
            }
            return(View(coursesModel));
        }
示例#24
0
 private void RefreshCoursesModel()
 {
     if (CoursesModel != null)
     {
         try
         {
             CoursesModel.RefreshCoursesFromData();
         }
         catch (DataServiceException e)
         {
             Debug.WriteLine(e.Message);
         }
     }
 }
        public ActionResult Create([Bind(Include = "CourseId,CourseName,DepartmentId,CourseTypeID,CourseIdfk")] CoursesModel coursesModel)
        {
            if (ModelState.IsValid)
            {
                coursesModel.CourseId = Guid.NewGuid();
                db.CoursesModels.Add(coursesModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseIdfk   = new SelectList(db.CoursesModels, "CourseId", "CourseName", coursesModel.CourseIdfk);
            ViewBag.CourseTypeID = new SelectList(db.CourseTypesModels, "Id", "coursename", coursesModel.CourseTypeID);
            ViewBag.DepartmentId = new SelectList(db.DepartmentsModels, "DepartmentId", "DepartmentName", coursesModel.DepartmentId);
            return(View(coursesModel));
        }
示例#26
0
 public void UpdateCourses(int id, [FromBody] CoursesModel model)
 {
     try
     {
         coursesService.UpdateCourses(id, model);
     }
     catch (ApiException)
     {
         throw;
     }
     catch (Exception exception)
     {
         throw new ApiException(exception.GetExceptionMessage());
     }
 }
示例#27
0
 public void SaveCourses([FromBody] CoursesModel model)
 {
     try
     {
         coursesService.SaveCourses(model);
     }
     catch (ApiException)
     {
         throw;
     }
     catch (Exception exception)
     {
         throw new ApiException(exception.GetExceptionMessage());
     }
 }
        // GET: CoursesModels/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CoursesModel coursesModel = db.CoursesModels.Find(id);

            if (coursesModel == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CourseIdfk   = new SelectList(db.CoursesModels, "CourseId", "CourseName", coursesModel.CourseIdfk);
            ViewBag.CourseTypeID = new SelectList(db.CourseTypesModels, "Id", "coursename", coursesModel.CourseTypeID);
            ViewBag.DepartmentId = new SelectList(db.DepartmentsModels, "DepartmentId", "DepartmentName", coursesModel.DepartmentId);
            return(View(coursesModel));
        }
示例#29
0
        private async void GetDataAsync()
        {
            await Task.Run(() =>
            {
                try
                {
                    CoursesModel.RefreshCoursesFromData();
                }
                catch (DataServiceException e)
                {
                    Debug.WriteLine(e.Message);
                    ShowAlert();
                }
            });

            RefreshLocalCourses();
        }
        public ActionResult EditCourse(IEnumerable <Guid> subjects, Guid degID, int part)
        {
            //int degreeID = int.Parse(degID);
            var getDegreeProgram = r.Degree_Program.Where(s => s.ProgramID == degID).Select(s => s).FirstOrDefault();

            if (subjects != null)
            {
                string result = CoursesModel.SubjectAddToDegree(subjects, degID, part);

                if (result == "OK")
                {
                    IEnumerable <Subject> ds = CoursesModel.getSubjectsRelatedToDegreeForEditing();
                    ViewBag.Degree  = getDegreeProgram;
                    ViewBag.level   = getDegreeProgram.Level.Level_Name;
                    ViewBag.Message = "Successfully Records Updated";
                    return(View(ds));
                }
                else
                {
                    IEnumerable <Subject> ds = CoursesModel.getSubjectsRelatedToDegreeForEditing();
                    ViewBag.Degree  = getDegreeProgram;
                    ViewBag.level   = getDegreeProgram.Level.Level_Name;
                    ViewBag.Message = result;
                    return(View());
                }
            }
            else
            {
                IEnumerable <Subject> ds = CoursesModel.getSubjectsRelatedToDegreeForEditing();
                if (CoursesModel.DeleteAllSubjects(getDegreeProgram, part))
                {
                    ViewBag.Degree  = getDegreeProgram;
                    ViewBag.level   = getDegreeProgram.Level.Level_Name;
                    ViewBag.Message = "Successfully Records Updated";
                    return(View(ds));
                }
                else
                {
                    ViewBag.Degree  = getDegreeProgram;
                    ViewBag.level   = getDegreeProgram.Level.Level_Name;
                    ViewBag.Message = "Unable to Update Subjects";
                    return(View(ds));
                }
            }
        }
        public ActionResult AddDegreeRecords(Degree_Program deg, string level)
        {
            if (level == "Select")
            {
                ViewBag.Message = "Error! Unable to Add Record!" + " Plz Select a Valid Degree level";
                var AlltheLevels = r.Levels.Select(s => s).OrderBy(s => s.LevelID);
                ViewBag.Levels = AlltheLevels;
                return(View());
            }
            else
            {
                Guid levelID = Guid.Parse(level);
                deg.LevelID = levelID;
                deg.Level   = r.Levels.Where(s => s.LevelID == levelID).Select(s => s).FirstOrDefault();

                if (CoursesModel.AddCourse(levelID, deg))
                {
                    ViewBag.Message = "Successfully Record Added";
                    var AlltheLevels = r.Levels.Select(s => s).OrderBy(s => s.LevelID);
                    ViewBag.Levels = AlltheLevels;
                    return(View());
                }
                else
                {
                    ViewBag.Message = "Error! Unable to Add Record! " + deg.Degree_ProgramName + " Already Exists";
                    var AlltheLevels = r.Levels.Select(s => s).OrderBy(s => s.LevelID);
                    ViewBag.Levels = AlltheLevels;
                    return(View());
                }

                //}
                //else
                //{
                //    foreach (var item in ModelState)
                //    {
                //        ViewBag.M2 = item.Key;
                //        ViewBag.M1 = item.Value;
                //    }
                //    ViewBag.Message = "Error! Unable to Add Record!";
                //    var AlltheLevels = r.Levels.Select(s => s).OrderBy(s => s.LevelID);
                //    ViewBag.Levels = AlltheLevels;
                //    return View();
                //}
            }
        }
示例#32
0
        public ActionResult AddCourse(FormCollection collection)
        {
            try
            {
                CoursesModel newCourse = new CoursesModel
                {
                    name = collection["name"],
                    link = collection["link"]
                };
                db.CoursesModels.Add(newCourse);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(View());
            }
        }
        public ActionResult DetailCourse(string id)
        {
            try
            {
                Guid degID                      = Guid.Parse(id);
                var  getDegreeProgram           = r.Degree_Program.Where(s => s.ProgramID == degID).Select(s => s).FirstOrDefault();
                var  specificLevel              = r.Levels.Where(s => s.LevelID == getDegreeProgram.LevelID).Select(s => s.Level_Name).FirstOrDefault();
                IEnumerable <Degree_Subject> ds = CoursesModel.getSubjectsRelatedToDegree(degID);

                ViewBag.level  = specificLevel;
                ViewBag.Degree = getDegreeProgram.Degree_ProgramName;

                return(View(ds));
            }
            catch (Exception)
            {
                return(RedirectToAction("ManageCourses"));
            }
        }
示例#34
0
        public void CanGetCourseByCourseId()
        {
            var dummyCourse = DummyDataGenerator.CreateDummyCourse();

            ICoursesModel model = new CoursesModel();
            dummyCourse.Id = model.AddOrUpdateCourse(dummyCourse).Id;

            var fromDb = model.GetCourse(dummyCourse.Id);

            // Check the values against our dummy course
            Assert.NotNull(fromDb);
            Assert.AreEqual(dummyCourse.Id, fromDb.Id);
            Assert.AreEqual(dummyCourse.Name, fromDb.Name);
            Assert.AreEqual(dummyCourse.Description, fromDb.Description);
            Assert.AreEqual(dummyCourse.CreatedByUsername, fromDb.CreatedByUsername);
            Assert.AreEqual(dummyCourse.LastUpdateByUsername, fromDb.LastUpdateByUsername);
            Assert.AreEqual(dummyCourse.CourseSlides.Count, fromDb.CourseSlides.Count);

            // clean-up db
            var repo = new BizCollegeRepository<Course, string>();
            repo.Remove(fromDb.Id);
        }
        public void CanSetStudentEnrollmentCourseCompletion()
        {
            string username = "******";

            // Create a dummy course and add it to the database
            var dummyCourse = DummyDataGenerator.CreateDummyCourse();
            ICoursesModel courseModel = new CoursesModel();
            dummyCourse.Id = courseModel.AddOrUpdateCourse(dummyCourse).Id;

            // add the new enrollment for the given user and specified course
            IStudentEnrollmentsModel model = new StudentEnrollmentsModel();
            StudentRecord studentEnrollmentRecord = model.AddEnrollment(username, dummyCourse.Id);

            // set the course as completed
            model.SetStudentCourseCompletion(username, dummyCourse.Id);

            //  retrieve the record from the database and make sure that course
            // was set to complete.
            var enrollmentsRepo = new BizCollegeRepository<StudentRecord, string>();
            var fromDb = enrollmentsRepo.Get(studentEnrollmentRecord.Username);

            Assert.NotNull(fromDb);
            Assert.IsTrue(fromDb.StudentCourseEnrollments[0].WasCourseCompleted);

            // clean up Db:  remove student record
            enrollmentsRepo.Remove(studentEnrollmentRecord.Username);

            // clean up Db:  remove dummy course
            var coursesRepo = new BizCollegeRepository<Course, string>();
            coursesRepo.Remove(dummyCourse.Id);
        }
        public void CanSetStudentEnrollmentLastViewedSlide()
        {
            string username = "******";

            // Create a dummy course
            var dummyCourse = DummyDataGenerator.CreateDummyCourse();
            ICoursesModel courseModel = new CoursesModel();
            dummyCourse.Id = courseModel.AddOrUpdateCourse(dummyCourse).Id;

            // add a new enrollment for the given user and specified dummy course
            IStudentEnrollmentsModel model = new StudentEnrollmentsModel();
            StudentRecord studentEnrollmentRecord = model.AddEnrollment(username, dummyCourse.Id);

            // Simulate that the user last viewed/accessed slide 5 of the dummy course
            int lastViewedSlideIndex = 5;

            // Update the student enrollment for the dummy course with the specified last viewed slide index
            StudentRecord updatedRecord = model.SetStudentEnrollmentLastViewedSlide(username, dummyCourse.Id, lastViewedSlideIndex);

            Assert.NotNull(updatedRecord);
            Assert.AreEqual(updatedRecord.StudentCourseEnrollments[0].LastViewedSlideIndex, lastViewedSlideIndex);

            // clean up Db:  remove student record
            var enrollmentsRepo = new BizCollegeRepository<StudentRecord, string>();
            enrollmentsRepo.Remove(studentEnrollmentRecord.Username);

            // clean up Db:  remove dummy course
            var coursesRepo = new BizCollegeRepository<Course, string>();
            coursesRepo.Remove(dummyCourse.Id);
        }
示例#37
0
        public void CanUpdateExistingCourse()
        {
            // Create a dummy course and add it to the database
            var dummyCourse = DummyDataGenerator.CreateDummyCourse();
            ICoursesModel model = new CoursesModel();
            dummyCourse.Id = model.AddOrUpdateCourse(dummyCourse).Id;

            // Update the course by adding a course slide and changing
            dummyCourse.CourseSlides.Add(new CourseContent()
            {
                CourseContentType = ContentType.Video,
                Description = "This video talks about how to start your own business",
                ResourcePath = "http://www.youtube.com",
                Title = "Business Course Introduction Video",
                IndexInSquence = 0,
            });

            // Also update the other properties of the coures
            dummyCourse.Name = "Business Savvy 101";
            dummyCourse.Description = "Tips on how to run a business properly";
            dummyCourse.State = CourseState.Active;
            dummyCourse.LastUpdateByUsername = "******";
            dummyCourse.CreatedByUsername = "******";

            //  Persist the course udpates to the database
            model.AddOrUpdateCourse(dummyCourse);

            // Retrieve a copy of the updated course back out from the Db
            var repo = new BizCollegeRepository<Course, string>();
            var fromDb = repo.Get(dummyCourse.Id);

            // Check that the course properties we updated were persisted
            Assert.NotNull(fromDb);
            Assert.AreEqual(dummyCourse.Id, fromDb.Id);

            Assert.AreEqual(dummyCourse.Name,                 fromDb.Name);
            Assert.AreEqual(dummyCourse.Description,          fromDb.Description);
            Assert.AreEqual(dummyCourse.State,                fromDb.State);
            Assert.AreEqual(dummyCourse.LastUpdateByUsername, fromDb.LastUpdateByUsername);
            Assert.AreEqual(dummyCourse.CreatedByUsername,    fromDb.CreatedByUsername);

            Assert.NotNull(fromDb.CourseSlides[0]);
            Assert.AreEqual(dummyCourse.CourseSlides.Count,                fromDb.CourseSlides.Count);
            Assert.AreEqual(dummyCourse.CourseSlides[0].CourseContentType, fromDb.CourseSlides[0].CourseContentType);
            Assert.AreEqual(dummyCourse.CourseSlides[0].Description,       fromDb.CourseSlides[0].Description);
            Assert.AreEqual(dummyCourse.CourseSlides[0].ResourcePath,      fromDb.CourseSlides[0].ResourcePath);
            Assert.AreEqual(dummyCourse.CourseSlides[0].Title,             fromDb.CourseSlides[0].Title);
            Assert.AreEqual(dummyCourse.CourseSlides[0].IndexInSquence,    fromDb.CourseSlides[0].IndexInSquence);

            // clean-up db
            repo.Remove(fromDb.Id);
        }
示例#38
0
        public void CanRemoveExistingCourse()
        {
            var dummyCourse = DummyDataGenerator.CreateDummyCourse();

            ICoursesModel model = new CoursesModel();
            dummyCourse.Id = model.AddOrUpdateCourse(dummyCourse).Id;

            // Remove the dummyCourse
            model.RemoveCourse(dummyCourse.Id);

            // Check that the course was removed from the Db
            var repo = new BizCollegeRepository<Course, string>();
            var fromDb = repo.Get(dummyCourse.Id);

            Assert.IsNull(fromDb);
        }