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()); } }
private void btnSaveExams_Click(object sender, RoutedEventArgs e) { if (DeletedExamList != null) { foreach (var item in DeletedExamList) { ExamRepo.Remove(item.ExamID); } } if (ExamList != null) { foreach (var item in ExamList) { item.updated_by = item.created_by = UserID; if (item.ExamID == 0) { ExamRepo.Insert(item); } else { ExamRepo.Update(item); } } } RefreshList(); }
// 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 <string> GetNewGiud() { string guid = GlobalHelpers.GetShortGuid; while (await ExamRepo.FindBy(a => a.Code == guid).CountAsync() > 0) { guid = GlobalHelpers.GetShortGuid; } return(guid); }
public async Task <Exam> GetExamwithQuestionsWithAnswers(int id) { var exam = await ExamRepo.GetAsync(id); var questions = await QuestionRepo.FindBy(a => a.ExamId == id).ToListAsync(); foreach (var q in questions) { q.Answers = await AnswersRepo.FindBy(a => a.QuestionId == q.Id).ToListAsync(); } return(exam); }
public ucStudentResult() { this.DataContext = this; InitializeComponent(); ExamList = ExamRepo.GetManadatoryExams(); int count = 1; foreach (var exam in ExamList) { grid.Columns[count].Visibility = System.Windows.Visibility.Visible; grid.Columns[count].Header = exam.Description; count++; } }
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)); }
public UnitOfWork(ExamicaDbContext _context) { context = _context; Answers = new AnswerRepo(_context); AppUsers = new AppUserRepo(_context); ComplexQuestions = new ComplexQuestionRepo(_context); ExamAppUsers = new ExamAppUserRepo(_context); ExamComplexQuestions = new ExamComplexQuestionRepo(_context); ExamQuestions = new ExamQuestionRepo(_context); Exams = new ExamRepo(_context); Options = new OptionRepo(_context); OrganizationAdmins = new OrganizationAdminRepo(_context); organizationExaminees = new OrganizationExamineeRepo(_context); OrganizationExaminers = new OrganizationExaminerRepo(_context); OrganizationObservers = new OrganizationObsereverRepo(_context); Organizations = new OrganizationRepo(_context); QuestionComplexQuestions = new QuestionComplexQuestionRepo(_context); Questions = new QuestionRepo(_context); QuestionOptions = new QuestionOptionRepo(_context); Results = new ResultRepo(_context); PricingPlans = new PricingPlanRepo(_context); }
public ActionResult Exam(int id) { //examID = id; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1)); Response.Cache.SetNoStore(); Exam exam = erepo.GetById(id); if (exam != null && exam.ExamEndTime > DateTime.Now && exam.ExamStartTime < DateTime.Now) { Session.Add("ExamTempID", id); Student student = stdRepo.GetById(Convert.ToInt32(Session["UserID"])); ExamOfStudent examOfStudent = eIslem.GetAll().Where(x => x.StudentID == student.Id && x.IsActive == true && x.ExamID == id).SingleOrDefault(); if (examOfStudent != null) { Session.Add("ExamID", examOfStudent.ExamID); Session.Add("ExamOfStudentID", examOfStudent.Id); } if (Session["UserID"] != null && Session["ExamOfStudentID"] != null) { examQuestions = new List <ExamQuestion>(); examQuestions = eQuestionRepo.GetAll().Where(x => x.ExamID == id).ToList(); QuestionDTO questionDTO = new QuestionDTO(); List <Question> questionList = new List <Question>(); questionList = StripQuestions(examQuestions); ExamRepo eRepo = new ExamRepo(); Exam Sinav = eRepo.GetById(id); ExamEnd = Convert.ToDateTime(Sinav.ExamEndTime); Session["ExamEnd"] = ExamEnd; TempData["ExamName"] = exam.Name; return(View(questionDTO.QuestionToDTO(questionList))); } } return(RedirectToAction("NoExamError", "Error")); }
public async Task Clone(Exam item) { var newItem = new Exam { Id = 0, Active = true, DurationMinutes = item.DurationMinutes, Login = item.Login, MaxStart = item.MaxStart, MinStart = item.MinStart, Name = $"{item.Name} ({DateTime.Now})", Questions = null, Users = null }; newItem.Code = await GetNewGiud(); var examId = await ExamRepo.AddAsync(newItem); foreach (var q in item.Questions) { var answers = q.Answers; q.ExamId = examId; q.Id = 0; q.Answers = null; var qId = await QuestionRepo.AddAsync(q); foreach (var a in answers) { a.QuestionId = qId; a.Id = 0; await AnswersRepo.AddAsync(a); } } await ExamRepo.SaveChangesAsync(); }
public async Task <Exam> GetExamwithQuestionsWithAnswers(string code) { var exam = await ExamRepo.FindBy(a => a.Code == code).FirstOrDefaultAsync(); return(exam != null ? await GetExamwithQuestionsWithAnswers(exam.Id) : null); }
// GET: ExamTypes /// <summary> /// View active exam types /// </summary> public ActionResult Index() { return(View(ExamRepo.GetInstance().GetActiveExamTypes())); }
private void RefreshList() { ExamList = ExamRepo.GetAll(); }