private void MTabPracticeExam_SelectedIndexChanged(object sender, EventArgs e) { if (mTabPracticeExam.SelectedTab == mTabListPracticeExam) { mBtnReloadListPracticeExam.PerformClick(); } if (mTabPracticeExam.SelectedTab == mTabExamDetail || mTabPracticeExam.SelectedTab == mTabEditPracticeExam) { var practiceExam = (DoAnLTUDQL1.Exam)bsListPracticeExam.CurrencyManager.Current; ReloadListExamDetail(practiceExam.ExamId, null); mGridListExamDetail.DataSource = ExamDetails; // For edited ExamDetailsEdited = ExamDetails.Select(ed => new ExamDetail { ExamDetailId = ed.ExamDetailId, ExamId = ed.ExamId, StartTime = ed.StartTime, Duration = ed.Duration, SubjectId = ed.SubjectId, GradeId = ed.GradeId }).ToList(); if (ExamDetailsEdited == null) { ExamDetailsEdited = new List <ExamDetail>(); } SetHeaderMGridListExamDetail(); } }
/// <summary> /// ExamJoinDetails /// </summary> /// <param name="ExamSelect"></param> /// <returns></returns> public List <ExamDetails> ExamJoinDetails(ExamSelect ExamSelect) { SqlConnection connection = new SqlConnection(CONNECTION_STRING); connection.Open(); SqlCommand command = new SqlCommand("spExamJoinDetails", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@examId", ExamSelect.ExamId)); command.Parameters.Add(new SqlParameter("@pageSize", ExamSelect.PageSize)); command.Parameters.Add(new SqlParameter("@pageIndex", ExamSelect.PageIndex)); command.Parameters.Add(new SqlParameter("@sortWay", ExamSelect.SortWay)); command.Parameters.Add(new SqlParameter("@sortFields", ExamSelect.SortFields)); List <ExamDetails> CurrenExamDetails = new List <ExamDetails>(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ExamDetails examDetail = new ExamDetails(); examDetail.RowNumber = reader.GetInt64(5); examDetail.UserName = reader.GetString(0); examDetail.PassCriteria = reader.GetInt32(1); examDetail.ExamScore = reader.GetInt32(2); examDetail.TotalScore = reader.GetInt32(3); examDetail.IsPass = reader.GetInt32(4); CurrenExamDetails.Add(examDetail); } } return(CurrenExamDetails); }
public string UpdateResultExam(int idUser, int idLesson, int numberRight) { string resultexam = null; try { int totalQuestion = _context.Exams.Where(a => a.Id == idLesson).Select(a => a.NumberQuestion).FirstOrDefault(); //check if not exist is add new else if update point and status if (_context.ExamDetailses.Where(a => a.ExamId == idLesson && a.AccountId == idUser).FirstOrDefault() == null) { _context.ExamDetailses.Add(new ExamDetails { AccountId = _context.Accounts.Where(a => a.Id == idUser).FirstOrDefault().Id, ExamId = _context.Exams.Where(a => a.Id == idLesson).FirstOrDefault().Id, Status = CheckPast(numberRight, totalQuestion) > 75.0 ? true : false, Point = (int)Math.Round(CheckPast(numberRight, totalQuestion), MidpointRounding.AwayFromZero) }); } else { ExamDetails lastExam = _context.ExamDetailses.Where(a => a.ExamId == idLesson && a.AccountId == idUser).FirstOrDefault(); lastExam.Status = CheckPast(numberRight, totalQuestion) > 75.0 ? true : false; lastExam.Point = (int)Math.Round(CheckPast(numberRight, totalQuestion), MidpointRounding.AwayFromZero); lastExam.EditTime = DateTime.Now; _context.ExamDetailses.Update(lastExam); _context.SaveChanges(); } //update progress learn // find column value with idLesson - idUser - idCourses LessonDetails learn = _context.LessonDetailses .Where(a => a.LessonId == _context.Exams.Where(b => b.Id == idLesson).FirstOrDefault().LessonId && a.AccountId == idUser).FirstOrDefault(); if (learn == null) { _context.LessonDetailses.Add(new LessonDetails { AccountId = idUser, LessonId = idLesson, Status = CheckPast(numberRight, totalQuestion) > 75.0 ? true : false, EditTime = DateTime.Now }); resultexam = CheckPast(numberRight, totalQuestion) > 75.0 ? "Chúc mừng. Bạn đã vượt qua" :"Rất tiếc. Bạn chưa đạt yêu cầu"; } else { learn.Status = CheckPast(numberRight, totalQuestion) > 75.0 ? true : false; learn.EditTime = DateTime.Now; resultexam = learn.Status == true ? "Chúc mừng. Bạn đã vượt qua" : "Rất tiếc. Bạn chưa đạt yêu cầu"; _context.LessonDetailses.Update(learn); } _context.SaveChanges(); } catch { resultexam = null; } return(resultexam); }
public IActionResult EditExamDeatils(int id, [FromBody] ExamDetails val) { SaveExamDetails exam = new SaveExamDetails(); if (exam.EditExamDetails(id, val, HttpContext)) { return(Ok(new { msg = "update successful", Status = 200 })); } return(BadRequest(new { msg = "Not Found", status = 404 })); }
public IActionResult SaveExam([FromBody] ExamDetails examDetails) { SaveExamDetails exam = new SaveExamDetails(); if (exam.SaveExam(examDetails, HttpContext)) { return(Ok(new { msg = "exam save successfully", status = 200, flag = true })); } return(BadRequest(new { msg = "something went wrong", status = 404, flag = false })); }
private async Task LoadExamList() { var(code, res) = await ExamServices.GetExams(1); if (code == ErrorCodes.Success) { _examList = res; foreach (var e in _examList) { if (e.StartTime < DateTime.Now && e.StartTime.AddSeconds(e.Duration) > DateTime.Now && e.BanReason == null) { _nextExam = e; _haveOngoingExam = true; break; } if (e.StartTime > DateTime.Now && e.BanReason == null) { if (_nextExam == null || (_nextExam.StartTime - DateTime.Now) > (e.StartTime - DateTime.Now)) { _nextExam = e; } } } return; } if (code == ErrorCodes.NotLoggedIn) { await Modal.ErrorAsync(new ConfirmOptions() { Title = "Please login first", }); NavManager.NavigateTo("/User/Login"); } else { await Modal.ErrorAsync(new ConfirmOptions() { Title = "Failed to get exam list", Content = ErrorCodes.MessageMap[code] }); } }
public bool SaveExam(ExamDetails exam, HttpContext http) { var data = db.ExamDetails.FirstOrDefault(e => e.ExamCode == exam.ExamCode); if (data == null) { exam.CreatedDate = DateTime.Now; exam.Email = FetchEmail(http); exam.CreatedBy = db.Users.FirstOrDefault(e => e.Email == exam.Email).Name; db.ExamDetails.Add(exam); db.SaveChanges(); return(true); } return(false); }
public bool Edit(ExamDetails o) { try { _log.LogInformation("BEGIN => Edit"); _context.Update(o); _context.SaveChanges(); _log.LogInformation("END <= Edit"); return(true); } catch (Exception e) { _log.LogError("ERROR => Edit : [%s]", e); return(false); } }
public bool Add(ExamDetails o) { try { _log.LogInformation("BEGIN => Add"); _context.ExamDetailses.Add(o); _context.SaveChanges(); _log.LogInformation("END <= Add"); return(true); } catch (Exception e) { _log.LogError("ERROR <= Add : [%s]", e); return(false); } }
public ActionResult StudentFee(int class_id=0,int exam_id = 0) { if (Session[Configuration.SESSION_USER_ID] == null) { return RedirectToAction("Index", "Login"); } int school_id = SessionHandler.GetSchoolID(); ExamDetails _ed = new ExamDetails(); ClassDetails _cd = new ClassDetails(); ViewBag.exams = _ed.GetAll(school_id).ToList(); ViewBag.classes = _cd.GetAll(school_id).ToList(); if (school_id != 0 && class_id != 0 && exam_id != 0) { StudentDetails _sd = new StudentDetails(); var stds = _sd.GetAll(school_id,class_id); //if (stds.ToList().Count == 0 || exam_types.Count != rests.ToList().Count) //{ // foreach (var exam in exam_types) // { // if (rests.ToList().Count == 0) // { // _ed.InsertSubjectExam(school_id, subject_id, exam.exam_id, class_id, 1); // } // else // { // foreach (var se in rests) // { // if (se.exam_id == exam.exam_id && se.subject_id == subject_id && class_id == se.class_id) // continue; // _ed.InsertSubjectExam(school_id, subject_id, exam.exam_id, class_id, 1); // } // } // } //} } return View(); }
/// <summary> /// token semd on email and save the token in exam detail /// </summary> /// <param name="model"></param> /// <param name="guid"></param> /// <param name="baseUrl"></param> /// <param name="Id"></param> public void SendAccessMail(CreateSessionModel model, Guid guid, string baseUrl, int Id) { ExamDetails db = new ExamDetails(); db.UniqueId = guid.ToString(); db.Createdate = DateTime.Now; db.Createtime = DateTime.Now.TimeOfDay; db.Ipaddress = GetIPAddress(); db.ExamSesson = _context.ExamSessions.Where(e => e.Id == Id).Select(e => e).FirstOrDefault(); db.ExamStatusId = _context.ExamStatuses.Where(e => e.Name.ToLower() == "pending").FirstOrDefault().Id; _context.ExamDetails.Add(db); _context.SaveChanges(); //using (MailMessage mm = new MailMessage()) //{ // mm.From = new MailAddress("*****@*****.**"); //--- Email address of the sender // mm.To.Add(new MailAddress(model.Email)); //---- Email address of the recipient. // mm.Subject = "Test Link"; //---- Subject of email. // string message = $"Dear {model.FirstName},<br/>Greetings,<br/><br />You have been granted access to start the test.<br/><br />"; // string link = $"{baseUrl}/CreateSession/token?id={HttpUtility.UrlEncode(guid.ToString())}"; // message += $"<a href=\"{link}\">Click here</a><br /><br />"; // message += "Thanks<br/><br />The Technical Team"; // mm.Body = "<div>" + message + "</div>"; //---- Content of email. // mm.IsBodyHtml = true; // using (SmtpClient smtp = new SmtpClient()) // { // var credential = new NetworkCredential // { // UserName = "******", // replace with valid value // Password = "" // replace with valid value // }; // smtp.Credentials = credential; // smtp.Host = "smtp.gmail.com"; // smtp.Port = 587; // smtp.EnableSsl = true; // smtp.Send(mm); // } //} }
private void MTabExam_SelectedIndexChanged(object sender, EventArgs e) { if (mTabExam.SelectedTab == mTabListExam) { mBtnReloadListExam.PerformClick(); } if (mTabExam.SelectedTab == mTabExamDetail || mTabExam.SelectedTab == mTabEditExam) { if (bsListExam.Count > 0) { var exam = (DoAnLTUDQL1.Exam)bsListExam.CurrencyManager.Current; ReloadListExamDetail(exam.ExamId, null); mGridListExamDetail.DataSource = ExamDetails; // For edited ExamDetailsEdited = ExamDetails.Select(ed => new ExamDetail { ExamDetailId = ed.ExamDetailId, ExamId = ed.ExamId, StartTime = ed.StartTime, Duration = ed.Duration, SubjectId = ed.SubjectId, GradeId = ed.GradeId }).ToList(); if (ExamDetailsEdited == null) { ExamDetailsEdited = new List <ExamDetail>(); } SetHeaderMGridListExamDetail(); } } if (mTabExam.SelectedTab == mTabReport) { var frmTeacherExamReport = new frmTeacherExamReport(CurrentUser, CurrentUserInfo); frmTeacherExamReport.ShowDialog(); mTabExam.SelectTab(0); } }
public bool EditExamDetails(int id, ExamDetails val, HttpContext httpContext) { var data = db.ExamDetails.FirstOrDefault(e => e.Id == id); if (data != null) { data.ExamName = val.ExamName; data.ExamDuration = val.ExamDuration; data.ExamStartTime = val.ExamStartTime; data.ModifiedDate = DateTime.Now; db.ExamDetails.Where(s => s.Id == id).ToList().ForEach(e => { e.ExamName = val.ExamName; e.ExamDuration = val.ExamDuration; e.ExamStartTime = val.ExamStartTime; e.ModifiedBy = db.Users.FirstOrDefault(a => a.Email == FetchEmail(httpContext)).Name; }); db.SaveChanges(); return(true); } return(false); }
private void GetExam(XmlDocument XMLExam) { XmlNode AllExams; AllExams = XMLExam.DocumentElement.SelectSingleNode("Exams"); foreach (XmlNode ExamDetails in AllExams.SelectNodes("Exam")) { Exam NewExam = new Exam(); if (ExamDetails.SelectSingleNode("Name") != null) { NewExam.ExamName = ExamDetails.SelectSingleNode("Name").InnerText; } if (ExamDetails.SelectSingleNode("Description") != null) { NewExam.ExamDescription = ExamDetails.SelectSingleNode("Description").InnerText; } if (ExamDetails.SelectSingleNode("Active") != null) { NewExam.ExamActive = Convert.ToBoolean(ExamDetails.SelectSingleNode("Active").InnerText); } if (ExamDetails.SelectSingleNode("OpenDateEnabled") != null) { NewExam.ExamOpenDateEnabled = Convert.ToBoolean(ExamDetails.SelectSingleNode("OpenDateEnabled").InnerText); } if (ExamDetails.SelectSingleNode("OpenDate") != null) { NewExam.ExamOpenDate = Convert.ToDateTime(ExamDetails.SelectSingleNode("OpenDate").InnerText); } if (ExamDetails.SelectSingleNode("ClosedDateEnabled") != null) { NewExam.ExamClosedDateEnabled = Convert.ToBoolean(ExamDetails.SelectSingleNode("ClosedDateEnabled").InnerText); } if (ExamDetails.SelectSingleNode("ClosedDate") != null) { NewExam.ExamClosedDate = Convert.ToDateTime(ExamDetails.SelectSingleNode("ClosedDate").InnerText); } if (ExamDetails.SelectSingleNode("TimeLimitEnabled") != null) { NewExam.ExamTimeLimitEnabled = Convert.ToBoolean(ExamDetails.SelectSingleNode("TimeLimitEnabled").InnerText); } if (ExamDetails.SelectSingleNode("TimeLimit") != null) { NewExam.ExamTimeLimit = Convert.ToInt32(ExamDetails.SelectSingleNode("TimeLimit").InnerText); } if (ExamDetails.SelectSingleNode("AttemptsAllowed") != null) { NewExam.ExamAttemptsAllowed = Convert.ToInt32(ExamDetails.SelectSingleNode("AttemptsAllowed").InnerText); } if (ExamDetails.SelectSingleNode("QuestionsOrdered") != null) { NewExam.ExamQuestionsOrdered = Convert.ToBoolean(ExamDetails.SelectSingleNode("QuestionsOrdered").InnerText); } if (ExamDetails.SelectSingleNode("ShuffleAnswers") != null) { NewExam.ExamQuestionsOrdered = Convert.ToBoolean(ExamDetails.SelectSingleNode("ShuffleAnswers").InnerText); } if (ExamDetails.SelectSingleNode("LearningMode") != null) { NewExam.ExamLearningMode = Convert.ToBoolean(ExamDetails.SelectSingleNode("LearningMode").InnerText); } if (ExamDetails.SelectSingleNode("Password") != null) { NewExam.ExamPassword = Convert.ToString(ExamDetails.SelectSingleNode("Password").InnerText); } NewExam.InsertExam(); } }
public ExamDetails CheckAccessKey(ExamDetails value) { var existingExam = db.ExamDetails.FirstOrDefault(s => s.ExamCode == value.ExamCode); return(existingExam); }