public ActionResult UserCourses()
        {
            if (User.Identity.IsAuthenticated)
            {
                UserCoursesDto        dto;
                List <UserCoursesDto> uc = new List <UserCoursesDto>();
                int userId = Utilities.GetInstance().GetCurrentUserId();

                var _uc = Utilities.GetInstance().GetStudentClasses(userId.ToString());
                foreach (var v in _uc)
                {
                    dto            = new UserCoursesDto();
                    dto.UserId     = userId;
                    dto.FullName   = Utilities.GetInstance().GetUserFullName(v.InstructorId);
                    dto.Course     = v.Title;
                    dto.CourseId   = v.Id;
                    dto.Status     = v.Status;
                    dto.AddedDate  = v.AddedDate;
                    dto.TotalExams = v.Exam.Count();
                    dto.ExamTaken  = ExamRepo.GetInstance().UserExamsCount(userId, v.CourseId);
                    dto.StudentIds = v.StudentIds;
                    dto.EndDate    = v.EndDate;
                    uc.Add(dto);
                }

                return(PartialView("_UserCourses", uc));
            }
            else
            {
                return(View());
            }
        }
        // GET: Exams/Create
        /// <summary>
        /// Create new exam
        /// </summary>
        public ActionResult Create()
        {
            int instID = Utilities.GetInstance().GetCurrentUserId();

            ViewBag.CourseId   = new SelectList(db.CourseClass.Where(x => x.InstructorId == instID && x.Status && x.StartDate <DateTime.Now && x.EndDate> DateTime.Now), "Id", "Title");
            ViewBag.ExamTypeId = new SelectList(ExamRepo.GetInstance().GetActiveExamTypes(), "Id", "Type");
            return(View());
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Title,CreationDate,IsPublished,CourseClassId,ExamTypeId,MaxGrade,UserId,Duration")] Exam exam)
        {
            if (ModelState.IsValid)
            {
                db.Entry(exam).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            int instID = Utilities.GetInstance().GetCurrentUserId();

            ViewBag.CourseId   = new SelectList(db.CourseClass.Where(x => x.InstructorId == instID && x.Status && x.StartDate <DateTime.Now && x.EndDate> DateTime.Now), "Id", "Title", exam.CourseClassId);
            ViewBag.ExamTypeId = new SelectList(ExamRepo.GetInstance().GetActiveExamTypes(), "Id", "Type", exam.ExamTypeId);
            return(View(exam));
        }
        // GET: Exams/Edit/5
        /// <summary>
        /// Edit existing exam
        /// </summary>
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Exam exam = await db.Exam.FindAsync(id);

            if (exam == null)
            {
                return(HttpNotFound());
            }
            int instID = Utilities.GetInstance().GetCurrentUserId();

            ViewBag.CourseId   = new SelectList(db.CourseClass.Where(x => x.InstructorId == instID && x.Status && x.StartDate <DateTime.Now && x.EndDate> DateTime.Now), "Id", "Title", exam.CourseClassId);
            ViewBag.ExamTypeId = new SelectList(ExamRepo.GetInstance().GetActiveExamTypes(), "Id", "Type", exam.ExamTypeId);
            return(View(exam));
        }
Ejemplo n.º 5
0
 // GET: ExamTypes
 /// <summary>
 /// View active exam types
 /// </summary>
 public ActionResult Index()
 {
     return(View(ExamRepo.GetInstance().GetActiveExamTypes()));
 }