Esempio n. 1
0
            public CreateCourseCourseRunBuilder WithOnlineCourseRun(
                string courseName               = "Education assessment in Maths",
                bool?flexibleStartDate          = null,
                DateTime?startDate              = null,
                string courseUrl                = null,
                decimal?cost                    = 69m,
                string costDescription          = null,
                CourseDurationUnit durationUnit = CourseDurationUnit.Months,
                int durationValue               = 3,
                string providerCourseRef        = null,
                CourseStatus status             = CourseStatus.Live)
            {
                var courseRunId = Guid.NewGuid();

                _courseRuns.Add(new CreateCourseCourseRun()
                {
                    CourseRunId       = courseRunId,
                    CourseName        = courseName,
                    DeliveryMode      = CourseDeliveryMode.Online,
                    FlexibleStartDate = flexibleStartDate ?? !startDate.HasValue,
                    StartDate         = startDate,
                    CourseUrl         = courseUrl,
                    Cost             = cost,
                    CostDescription  = costDescription,
                    DurationUnit     = durationUnit,
                    DurationValue    = durationValue,
                    National         = true,
                    ProviderCourseId = providerCourseRef
                });

                return(this);
            }
Esempio n. 2
0
        public ActionResult AddCourse(string course_name, CourseStatus status)
        {
            var result = new ResultData <Course>()
            {
                Error = true, Status = HttpStatusCode.BadRequest
            };

            try
            {
                CourseServices.ValidateName(course_name);
                Course course = new Course(course_name, status);
                if (db.Curso.Where(q => q.Name.ToLower() == course_name.ToLower()).Any())
                {
                    throw new ArgumentException($"O nome {course.Name} já esta cadastrado");
                }

                db.Curso.Add(course);
                db.SaveChanges();
                result.Error  = false;
                result.Status = HttpStatusCode.OK;
                result.Data   = db.Curso.ToList();
                return(Ok(result));
            }
            catch (Exception e)
            {
                result.Message.Add(e.Message);
                return(BadRequest(result));
            }
            finally
            {
                db.Dispose();
            }
        }
        /// <summary>
        /// Sets the course status to approved for the given course.
        /// </summary>
        /// <param name="courseId"></param>
        /// <returns></returns>
        public async Task <IActionResult> ApproveCourse(int?courseId)
        {
            if (courseId == null)
            {
                return(new JsonResult(new { success = false }));
            }
            CourseInstance course = await _context.CourseInstance.Include(c => c.Status).Include(c => c.Instructors).ThenInclude(i => i.User)
                                    .Where(c => c.CourseInstanceId == courseId).FirstOrDefaultAsync();

            CourseStatus complete = _context.CourseStatus.Where(s => s.Status == CourseStatusNames.Complete).FirstOrDefault();

            if (complete == null)
            {
                return(new JsonResult(new { success = false }));
            }
            course.Status = complete;
            //Notify Instructors
            foreach (Instructors inst in course.Instructors)
            {
                Notifications notify = new Notifications()
                {
                    CourseInstance = course,
                    User           = inst.User,
                    Text           = "This course was approved.",
                    DateNotified   = DateTime.Now,
                    Read           = false
                };
                _context.Notifications.Add(notify);
            }
            _context.SaveChanges();
            return(new JsonResult(new { success = true }));
        }
        public ActionResult Approve(int?id)
        {
            if (!HasSession())
            {
                return(RedirectToAction("Index", "Home"));
            }

            Boolean IsChairman = Convert.ToBoolean(HttpContext.Session[Variables.IsChairmanSession]);

            if (!IsChairman || id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            TeacherActivity activity = db.TeacherActivity.Where(p => p.id == id).FirstOrDefault();

            string[] arr = activity.Content.Split(',');
            if (arr != null)
            {
                ViewBag.Faculty = arr[0];
                ViewBag.Course  = arr[1];

                for (int i = 2; i < arr.Length; i++)
                {
                    new Marks().SubmitMark(arr[0], arr[1], Convert.ToInt32(arr[i]), true);
                }
            }
            CourseStatus.UpdateCourseStatus(activity.CourseCode, activity.Session, true);

            activity.Approved = true;
            db.SaveChanges();

            return(RedirectToAction("ApproveMarks", "Marks"));
        }
        /// <summary>
        /// Sets the course status to in-review for the given course.
        /// </summary>
        /// <param name="courseId"></param>
        /// <returns></returns>
        public async Task <IActionResult> SetReviewCourse(int?courseId, string message)
        {
            if (courseId == null)
            {
                return(new JsonResult(new { success = false }));
            }
            CourseInstance course = await _context.CourseInstance.Include(c => c.Status)
                                    .Include(c => c.Instructors).ThenInclude(i => i.User)
                                    .Where(c => c.CourseInstanceId == courseId).FirstOrDefaultAsync();

            CourseStatus inRev = _context.CourseStatus.Where(s => s.Status == CourseStatusNames.InReview).FirstOrDefault();

            if (inRev == null)
            {
                return(new JsonResult(new { success = false }));
            }
            course.Status = inRev;
            //Notify Instructors
            foreach (Instructors inst in course.Instructors)
            {
                Notifications notify = new Notifications()
                {
                    CourseInstance = course,
                    User           = inst.User,
                    Text           = "The course status was set to in-review. Chair message: " + message,
                    DateNotified   = DateTime.Now,
                    Read           = false
                };
                _context.Notifications.Add(notify);
            }
            _context.SaveChanges();
            return(new JsonResult(new { success = true }));
        }
        private static bool AllQuizzesAreCompleted(CourseStatus courseStatus)
        {
            var quizStatuses = new List <QuizState>();

            courseStatus.Quizzes.ForEach(x => quizStatuses.AddRange(x.QuizStatuses));
            return(quizStatuses.All(x => x.IsComplete));
        }
Esempio n. 7
0
 protected Course(Discipline discipline, CourseStatus status, int niveauId, DateTime startDate)
     : this()
 {
     Discipline = discipline;
     Status     = status;
     NiveauId   = niveauId;
     StartDate  = startDate;
 }
Esempio n. 8
0
        public void UpdateStatusRange(IEnumerable <UnusedCourse> unusedCourses, CourseStatus status)
        {
            foreach (var course in unusedCourses)
            {
                course.Status = status;
            }

            unusedCourseRepository.UpdateRange(unusedCourses);
        }
 private void DownloaderForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DownloaderStatus != CourseStatus.Finished)
     {
         DownloaderStatus = CourseStatus.Failed;
         _cancellationTokenSource.Cancel();
         _downloader.Dispose();
     }
 }
        public static Course CreateCourse(Semester Semester_Parameter, Teacher Teacher_Parameter, string Number_Parameter, string Name_Parameter, CourseStatus Status_Parameter)
        {
            SampleObjectContext context = new SampleObjectContext();
            Course obj = CreateCourse(context, Semester_Parameter, Teacher_Parameter, Number_Parameter, Name_Parameter, Status_Parameter);

            context.AcceptAllChanges();
            Course.OnCacheNeedsRefresh();

            return obj;
        }
Esempio n. 11
0
 internal Group(IEnumerable <BaseMessage> messages, GroupInfo groupInfo, User teacher, CourseStatus status,
                List <Member> members, List <Invitation> invitations, List <int> kicked)
 {
     Messages    = Ensure.Any.IsNotNull(messages);
     GroupInfo   = Ensure.Any.IsNotNull(groupInfo);
     Teacher     = teacher;
     Status      = status;
     Members     = Ensure.Any.IsNotNull(members);
     Invitations = Ensure.Any.IsNotNull(invitations);
     KickedId    = Ensure.Any.IsNotNull(kicked);
 }
Esempio n. 12
0
        public void Color(CourseStatus status, string expectedResult)
        {
            var course = new Course
            {
                Status = status
            };

            var listItem = new CourseListItem(course);

            listItem.Color.ShouldBe(expectedResult);
        }
Esempio n. 13
0
        public async Task <IActionResult> InsertCourseStatus(string status)
        {
            var courseStatus = new CourseStatus()
            {
                Status = status,
            };

            var courseStatusInserted = await unitOfWork.GetRepository <CourseStatus>().InsertAsync(courseStatus);

            return(ApiResponder.RespondSuccessTo(HttpStatusCode.Ok, courseStatusInserted));
        }
Esempio n. 14
0
        public ActionResult Get(int id, CourseStatus status, string title)
        {
            var model = new CourseApprovalLogModel
            {
                CourseId    = id,
                Status      = status,
                ApproverId  = CurrentUser.UserId,
                CourseTitle = title
            };

            return(PartialView("_approvals", model));
        }
            public void The_Status_is_set(CourseStatus status, string expectedResult)
            {
                var course = new Course
                {
                    Status = status
                };

                var sut = new CourseDetailViewModel();

                sut.Status.ShouldBeNull();
                sut.SetCourse(course);
                sut.Status.ShouldBe(expectedResult);
            }
Esempio n. 16
0
        public void Status(CourseStatus status, string expectedResult)
        {
            var date = new DateTime(2019, 4, 15);

            var course = new Course
            {
                DateOfExamination = date,
                Status            = status
            };

            var listItem = new CourseListItem(course);

            listItem.Status.ShouldBe(expectedResult);
        }
Esempio n. 17
0
            public void Its_Status_is_being_mapped_and_set(
                string statusCode,
                CourseStatus expectedStatus
                )
            {
                var rawCourse = new RawCourse
                {
                    Status = statusCode
                };

                var result = Course.FromRawCourse(rawCourse, DateTime.UtcNow);

                result.Status.ShouldBe(expectedStatus);
            }
        private void InitControlValuesForEdit(int id)
        {
            train_course_view info = context.train_course_view.Single(i => i.Id == id);

            Name.Text           = info.Name;
            Name.Enabled        = false;
            Number.Text         = info.Number;
            Number.Enabled      = false;
            Time.Text           = info.Time.ToString();
            Time.Enabled        = false;
            Description.Text    = info.Description;
            Description.Enabled = false;

            Type.Value = info.Type;

            Type.DataBind();
            Type.Enabled = false;
            lessonType.DataBind();

            ContentType.Value = info.ContentTypeId;
            ContentType.DataBind();
            ContentType.Enabled = false;
            LinqContentType.DataBind();

            Place.Text    = info.Place;
            Place.Enabled = false;

            Class_time.Text    = info.Class_time;
            Class_time.Enabled = false;

            start_date.Date    = info.Start_date;
            start_date.Enabled = false;

            end_date.Date    = info.End_date;
            end_date.Enabled = false;

            EndChooseDate.Date    = info.End_choose_date;
            EndChooseDate.Enabled = false;

            Teacher.Value = info.Teacher;
            TeacherType.DataBind();
            //TeacherType.Enabled = false;

            Status.Value = info.Status;
            Status.DataBind();
            Status.Enabled = false;
            CourseStatus.DataBind();
            Create_time.Text    = info.Create_time.ToString();
            Create_time.Enabled = false;
        }
Esempio n. 19
0
        private CertStatusQuiz GetQuiz(CourseStatus courseStatus, ObjectId quizId)
        {
            var quiz = courseStatus.Quizzes.SingleOrDefault(x => x.QuizId == quizId);

            if (quiz == null)
            {
                throw new HttpNotFoundException(new ApiError(
                                                    nameof(NotFound),
                                                    $"Could not find {nameof(Quiz)} by $id",
                                                    additionalData: new Dictionary <string, string> {
                    { "id", quizId.ToString() }
                }));
            }
            return(quiz);
        }
Esempio n. 20
0
 public FullGroupInfo(string title, int size, int memberAmount, double cost, GroupType groupType,
                      IEnumerable <string> tags, string description, CourseStatus courseStatus,
                      bool isPrivate, string curriculum, int votersAmount)
 {
     Title        = title;
     Size         = size;
     MemberAmount = memberAmount;
     Cost         = cost;
     GroupType    = groupType;
     Tags         = tags;
     Description  = description;
     CourseStatus = courseStatus;
     IsPrivate    = isPrivate;
     Curriculum   = curriculum;
     VotersAmount = votersAmount;
 }
Esempio n. 21
0
        /// <summary>
        /// Instructor changes the course's status to 'Awaiting Approval'
        /// </summary>
        /// <param name="courseId"></param>
        /// <returns></returns>
        public async Task <IActionResult> RequestApproval(int?courseId)
        {
            if (courseId == null)
            {
                return(new JsonResult(new { success = false }));
            }
            CourseInstance course = _context.CourseInstance.Include(c => c.Status)
                                    .Where(c => c.CourseInstanceId == courseId).FirstOrDefault();

            if (course == null)
            {
                return(new JsonResult(new { success = false }));
            }
            if (course.Status.Status.Equals(CourseStatusNames.InProgress) || course.Status.Status.Equals(CourseStatusNames.InReview))
            {
                //Change status
                CourseStatus app = _context.CourseStatus.Where(s => s.Status == CourseStatusNames.AwaitingApproval).FirstOrDefault();
                if (app == null)
                {
                    return(new JsonResult(new { success = false }));
                }
                course.Status = app;
                //Notify Chairs
                foreach (IdentityUser user in _userManager.GetUsersInRoleAsync("Chair").Result)
                {
                    UserLocator userLoc = _context.UserLocator.Where(u => u.UserLoginEmail == user.Email).FirstOrDefault();
                    if (userLoc != null)
                    {
                        Notifications notify = new Notifications()
                        {
                            CourseInstance = course,
                            Text           = "Course approval requested.",
                            DateNotified   = DateTime.Now,
                            User           = userLoc
                        };
                        _context.Notifications.Add(notify);
                    }
                }
                _context.SaveChanges();
                return(new JsonResult(new { success = true }));
            }
            else
            {
                return(new JsonResult(new { success = false }));
            }
        }
Esempio n. 22
0
        public static Course Create(Guid id, Teacher teacher, string name, string syllabus, CourseStatus status, DateTimeOffset createdOn)
        {
            id.ThrowIfEmpty("id");
            teacher.ThrowIfNull("teacher");
            name.ThrowIfNullOrEmpty("name");
            syllabus.ThrowIfNullOrEmpty("syllabus");

            try
            {
                Course course = new Course(id, teacher, name, syllabus, status, createdOn);
                return course;
            }
            catch (Exception ex)
            {
                throw new ObjectNotCreatedException("Teacher", ex);
            }
        }
Esempio n. 23
0
        public void SetUp()
        {
            _objectId = new ObjectId();
            _user     = new User
            {
                UserId    = UserId,
                Username  = Username,
                FirstName = FirstName,
                LastName  = LastName
            };

            var cert    = CreateCertification();
            var courses = CreateCourses();

            _certStatus   = new CertificationStatus(cert, courses, _user);
            _courseStatus = _certStatus.Courses.First();
        }
        private async void DownloaderForm_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < _courses.Count; i++)
            {
                _currentVideoIndex = 1;
                var course = _courses[i];
                lblTotal.Text = $"Downloading Course : {course.Title} [{i + 1}/{_courses.Count}]";
                if (_cancellationToken.IsCancellationRequested)
                {
                    return;
                }
                await DownloadCourse(course);

                progressBarTotal.Value = (i + 1) * 100 / _courses.Count;
            }
            DownloaderStatus = CourseStatus.Finished;
            Close();
        }
        private async Task Add()
        {
            string name = await App.Current.MainPage.DisplayPromptAsync("Name", "Name of Course");

            string strstartdate = await App.Current.MainPage.DisplayPromptAsync("Start Date", "Course Start Date");

            string strenddate = await App.Current.MainPage.DisplayPromptAsync("End Date", "Course End Date");

            DateTime startdate = DateTime.Parse(strstartdate);
            DateTime enddate   = DateTime.Parse(strenddate);

            // DateTime startdate = new DateTime(2020, 01, 01);
            // DateTime enddate = new DateTime(2020, 06, 30);
            const CourseStatus status = CourseStatus.Started;

            await DBService.AddCourse(name, startdate, enddate, status);

            await Task.Run(() => Refresh());
        }
Esempio n. 26
0
 public GroupInfoView(int groupId, string title, int size,
                      int memberAmount, double price, GroupType groupType, IEnumerable <string> tags,
                      string description, string curriculum, bool isPrivate, bool isActive,
                      CourseStatus courseStatus, int votersAmount)
 {
     GroupId      = groupId;
     Title        = title;
     Size         = size;
     MemberAmount = memberAmount;
     Price        = price;
     GroupType    = groupType;
     Tags         = tags;
     Description  = description;
     Curriculum   = curriculum;
     IsPrivate    = isPrivate;
     IsActive     = isActive;
     CourseStatus = courseStatus;
     VotersAmount = votersAmount;
 }
Esempio n. 27
0
        public static CourseCompletion ToCourseCompletion(this CourseStatus status)
        {
            var quizAttempts = 0;

            status.Quizzes.ForEach(q => quizAttempts += q.QuizStatuses.Count);

            return(new CourseCompletion
            {
                CourseVersion = status.CourseVersion,
                ProgramId = status.TenantId,
                CertificationId = status.CertificationId,
                CourseId = status.CourseId,
                NumberOfAttempts = quizAttempts,
                CompletedAt = status.CompletedAt ?? DateTime.UtcNow,
                CreatedBy = status.CreatedBy,
                Name = status.Name,
                Description = status.Description
            });
        }
        public static Course CreateCourse(SampleObjectContext context, Semester Semester_Parameter, Teacher Teacher_Parameter, string Number_Parameter, string Name_Parameter, CourseStatus Status_Parameter)
        {
            Course obj = new Course();

            obj.Semester = Semester_Parameter;
            obj.Teacher = Teacher_Parameter;
            obj.Number = Number_Parameter;
            obj.Name = Name_Parameter;
            obj.Status = Status_Parameter;

            Validate(context, obj);

            PerformPreCreateLogic(context, obj);

            context.Courses.AddObject(obj);

            PerformPostCreateLogic(context, obj);

            return obj;
        }
        public void SetUp()
        {
            _objectIdString = new ObjectId().ToString();
            _messenger      = new Mock <IMessenger>();
            _messenger.Setup(x => x.SendMessage(It.IsAny <string>(), It.IsAny <object>())).ReturnsAsync(true);
            _handler = new CourseCompletionHandler(Repository.Object, _messenger.Object);

            var courses = new List <Course>
            {
                new Course {
                    IsActive = true, CertificationId = _objectIdString
                },
                new Course {
                    IsActive = true, CertificationId = _objectIdString
                }
            };

            _certStatus = new CertificationStatus(new Certification(), courses, new User {
                UserId = UserId
            });
            _courseStatus = _certStatus.Courses.First();
        }
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     if (backgroundWorker.IsBusy)
     {
         DownloaderStatus = CourseStatus.Failed;
         UpdateUI(() =>
         {
             lblDownloadingVideo.Text = "Closing...";
             Text = "Closing";
             lblPercentage.Visible    = false;
             lblTotal.Visible         = false;
             lblVideo.Visible         = false;
             progressBarTotal.Visible = false;
             progressBarVideo.Visible = false;
         });
         closePending = true;
         backgroundWorker.CancelAsync();
         e.Cancel = true;
         Enabled  = false;
         return;
     }
     base.OnFormClosing(e);
 }
 private void Then_TheCourseStatusIs(CourseStatus status, int courseId, CourseManager sut)
 {
     Course info = sut.GetCourse(courseId);
     Assert.Equal(status.ToString(), info.Status);
 }
Esempio n. 32
0
 /// <summary>
 /// 用于更新课程的状态,状态包括Pending、OK、Cancel三项
 /// </summary>
 /// <param name="course_id">课程的ID</param>
 /// <param name="state">课程的状态,类型为枚举CourseStatus</param>
 /// <returns>true表示成功,false表示失败</returns>
 public static bool UpdateCourseStatus(int course_id, CourseStatus state)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             COURSE course = ctx.COURSEs.Where(c => c.ID == course_id).FirstOrDefault();
             course.COURSE_STATUS = state.ToString();
             ctx.Entry(course).State = System.Data.EntityState.Modified;
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
Esempio n. 33
0
        public m_validation_error[] ValidateAndUpdateStatus(Guid courseID, CourseStatus courseStatus)
        {
            var course = _courseService.GetCourse(courseID, status: null);
            if (course == null)
                throw new NullReferenceException("Course not found to update.");

            m_validation_error[] errors = null;
            if (courseStatus == CourseStatus.Active &&
                (errors = course.Validate().ToArray()).Any(e => e.severity == m_validation_error.Severity.Error))
                return errors;

            course.Status = courseStatus;
            _entityRepository.Save(course);

            return errors ?? new m_validation_error[0];
        }
Esempio n. 34
0
 public virtual void ChangeCourseStatus(CourseStatus courseStatus)
 {
     CourseStatusName = courseStatus.Name;
 }
Esempio n. 35
0
        public static async Task <int> AddCourse(string name, DateTime startdate, DateTime enddate, CourseStatus status)
        {
            await InitDB();

            var course = new Course
            {
                Name      = name,
                StartDate = startdate,
                EndDate   = enddate,
                Status    = status
            };

            await db.InsertAsync(course);

            return(course.Id);
        }
partial         void OnStatusChanging(CourseStatus value);
 public void AddToCourseStatuses(CourseStatus courseStatus)
 {
     base.AddObject("CourseStatuses", courseStatus);
 }
        public async Task <bool> CompleteCourse(CertificationStatus certStatus, CourseStatus courseStatus)
        {
            await _messenger.SendMessage(CourseCompletionName, courseStatus.ToCourseCompletion());

            return(await CheckForCertificationCompletion(certStatus));
        }
 public static CourseStatus CreateCourseStatus(int ID, string status, byte[] rowVersion)
 {
     CourseStatus courseStatus = new CourseStatus();
     courseStatus.Id = ID;
     courseStatus.Status = status;
     courseStatus.RowVersion = rowVersion;
     return courseStatus;
 }