public ActionResult Edit(int id) { OnlineExam theExam = work.OnlineExamRepository.GetByID(id); IList <Question> theQs = new ExamService().GetQuestions(theExam); QuestionViewModel theListofQs = new QuestionViewModel(); foreach (var q in theQs) { theListofQs.TheQuestions.Add(q); } ViewBag.ExamCode = theExam.ExamCode; ViewBag.ExamCourse = theExam.Course; if (theExam.Term == "1") { ViewBag.ExamTerm = "First"; } if (theExam.Term == "2") { ViewBag.ExamTerm = "Second"; } if (theExam.Term == "3") { ViewBag.ExamTerm = "Third"; } return(View(theListofQs)); }
public IList <Question> GetQuestions(OnlineExam theMainExam) { UnitOfWork work = new UnitOfWork(); List <Question> questions = new List <Question>(); List <Choice> choices = new List <Choice>(); Question myQuestion = new Question(); int examID = theMainExam.OnlineExamID; List <Question> theQuestions = work.QuestionRepository.Get(a => a.Exam.OnlineExamID == examID).OrderBy(a => a.OrderNumber).ToList(); foreach (Question question in theQuestions) { myQuestion = question; int dID = question.QuestionID; List <Choice> theChoices = work.ChoiceRepository.Get(a => a.QuestionID == dID).ToList(); foreach (Choice choice in theChoices) { myQuestion.AddChoice(choice); // choices.Add(choice); } questions.Add(myQuestion); } // questions.Add(myQuestion); return(questions); }
public ActionResult Edit(OnlineExam theExam) { try { // TODO: Add update logic here work.OnlineExamRepository.Update(theExam); work.Save(); if (User.Identity.Name != "5000001") { AuditTrail audit = new AuditTrail { Date = DateTime.Now, Action = "Edited an Online Exam of code:-" + " " + theExam.ExamCode, UserID = User.Identity.Name }; work.AuditTrailRepository.Insert(audit); work.Save(); } return(RedirectToAction("LoadExamCodes")); } catch { return(View()); } }
public ActionResult LoadNextQuestionNumber(string examCode) { List <OnlineExam> theExams = work.OnlineExamRepository.Get(a => a.ExamCode.Equals(examCode)).ToList(); OnlineExam theRealExam = theExams[0]; List <Question> theQuestions = work.QuestionRepository.Get(a => a.OnlineExamID == theRealExam.OnlineExamID).ToList(); int theCount = theQuestions.Count() + 1; return(Json(theCount, JsonRequestBehavior.AllowGet)); }
public Grade Grade(OnlineExam toBeGradedExam) { UnitOfWork work = new UnitOfWork(); Question thE = toBeGradedExam.Questions[0]; List <Question> theQuestion = work.QuestionRepository.Get(a => a.QuestionID == thE.QuestionID).ToList(); Question theQuestio = theQuestion[0]; List <OnlineExam> theExam = work.OnlineExamRepository.Get(a => a.OnlineExamID == theQuestio.OnlineExamID).ToList(); OnlineExam persistedExam = new OnlineExam(); persistedExam = theExam[0]; IList <Question> theQs = new ExamService().GetQuestions(theExam[0]); persistedExam.AddQuestion(theQs); var grade = new Grade() { Exam = persistedExam }; foreach (var question in toBeGradedExam.Questions) { var persistedQuestion = (from q in persistedExam.Questions where q.QuestionID == question.QuestionID select q).SingleOrDefault(); if (persistedQuestion != null) { grade.TotalPoints += persistedQuestion.Point; foreach (var choice in question.Choices) { var persistedChoice = (from c in persistedQuestion.Choices where c.ChoiceID == choice.ChoiceID select c).SingleOrDefault(); // sets the user choice in the actual exam fetched from database! persistedChoice.IsSelected = true; // grade.TotalPoints += persistedQuestion.Point; if (persistedChoice.IsAnswer) { grade.Score += persistedQuestion.Point; } } } } return(grade); }
public Grade Grade(OnlineExam toBeGradedExam) { UnitOfWork work = new UnitOfWork(); Question thE = toBeGradedExam.Questions[0]; List<Question> theQuestion = work.QuestionRepository.Get(a => a.QuestionID == thE.QuestionID).ToList(); Question theQuestio = theQuestion[0]; List<OnlineExam> theExam = work.OnlineExamRepository.Get(a => a.OnlineExamID == theQuestio.OnlineExamID).ToList(); OnlineExam persistedExam = new OnlineExam(); persistedExam = theExam[0]; IList<Question> theQs = new ExamService().GetQuestions(theExam[0]); persistedExam.AddQuestion(theQs); var grade = new Grade() { Exam = persistedExam }; foreach (var question in toBeGradedExam.Questions) { var persistedQuestion = (from q in persistedExam.Questions where q.QuestionID == question.QuestionID select q).SingleOrDefault(); if (persistedQuestion != null) { grade.TotalPoints += persistedQuestion.Point; foreach (var choice in question.Choices) { var persistedChoice = (from c in persistedQuestion.Choices where c.ChoiceID == choice.ChoiceID select c).SingleOrDefault(); // sets the user choice in the actual exam fetched from database! persistedChoice.IsSelected = true; // grade.TotalPoints += persistedQuestion.Point; if (persistedChoice.IsAnswer) { grade.Score += persistedQuestion.Point; } } } } return grade; }
public ActionResult Delete(OnlineExam theExam) { try { //PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(model.PersonID); //work.PrimarySchoolStudentRepository.Delete(theStudent); OnlineExam theMainExam = work.OnlineExamRepository.GetByID(theExam.OnlineExamID); string examName = theMainExam.ExamCode; // GetQuestions(Exam theMainExam, ref UnitOfWork work) IList <Question> theQs = new ExamService().GetQuestions(theMainExam, ref work); foreach (var theQ in theQs) { // foreach (var choice in theQ.Choices) // { // work.ChoiceRepository.Delete(choice); // } work.QuestionRepository.Delete(theQ); } // IList<Question> theQs = new ExamService().GetQuestions(theMainExa); // examCodes.AddQuestion(theQs); work.OnlineExamRepository.Delete(theMainExam); work.Save(); if (User.Identity.Name != "5000001") { AuditTrail audit = new AuditTrail { Date = DateTime.Now, Action = "Deleted an online exam name:-" + " " + examName, UserID = User.Identity.Name }; work.AuditTrailRepository.Insert(audit); work.Save(); } return(RedirectToAction("LoadExamCodes")); } catch { return(View()); } }
public ActionResult Edit(int id) { OnlineExam theExam = work.OnlineExamRepository.GetByID(id); List <SelectListItem> theSubjectList = new List <SelectListItem>(); List <Subject> theSubject = work.SubjectRepository.Get().ToList(); foreach (var subject in theSubject) { theSubjectList.Add(new SelectListItem() { Text = subject.Name, Value = subject.Name }); } // theItem.Add(new SelectListItem() { Text = "PRIMART 1A", Value = "PRIMART 1A" }); ViewData["Subject"] = theSubjectList; return(View(theExam)); }
public ActionResult Create(OnlineExam theExam) { try { if (ModelState.IsValid) { // TODO: Add insert logic here string theExamCode = theExam.ExamCode.Trim().ToLower(); List <OnlineExam> theExams = work.OnlineExamRepository.Get(a => a.ExamCode.Equals(theExamCode)).ToList(); if (theExams.Count > 0) { return(RedirectToAction("Create", "Question")); } else { OnlineExam theEx = theExam; theEx.Date = DateTime.Now; // smContext c = new smContext(); // c.Entry(theEx).State = System.Data.Entity.EntityState.Added; // UnitOfWork w = new UnitOfWork(); work.OnlineExamRepository.Insert(theEx); work.Save(); // w.OnlineExamRepository.Insert(theEx); // c.SaveChanges(); ; return(RedirectToAction("Create", "Question")); } // return RedirectToAction("Index"); } else { return(View("_Create", theExam)); } } catch { return(View()); } }
public IList<Question> GetQuestions(OnlineExam theMainExam, ref UnitOfWork work) { List<Question> questions = new List<Question>(); List<Choice> choices = new List<Choice>(); Question myQuestion = new Question(); int examID = theMainExam.OnlineExamID; List<Question> theQuestions = work.QuestionRepository.Get(a => a.Exam.OnlineExamID == examID).OrderBy(a => a.OrderNumber).ToList(); foreach (Question question in theQuestions) { myQuestion = question; int dID = question.QuestionID; List<Choice> theChoices = work.ChoiceRepository.Get(a => a.QuestionID == dID).ToList(); foreach (Choice choice in theChoices) { myQuestion.AddChoice(choice); // choices.Add(choice); } questions.Add(myQuestion); } // questions.Add(myQuestion); return questions; }
// [DynamicAuthorize] public ActionResult Create(Question model) { try { if (model.Answer == null) { ModelState.AddModelError("", "Select an Answer to Question First!"); return(View("Create2")); } ICollection <Choice> theChoices = new List <Choice>(); // if (ModelState.IsValid) // { //List<Level> theLevel = work.LevelRepository.Get(a => a.Name.Equals(model.Exam.LevelName)).ToList(); // string theExamCode = model.Exam.ExamCode; // List<Course> theCourse = work.CourseRepository.Get(a => a.CourseID == model.Exam.CourseID).ToList(); List <OnlineExam> theExama = work.OnlineExamRepository.Get(a => a.ExamCode == model.Exam.ExamCode).ToList(); OnlineExam theMainExam = theExama[0]; model.Exam = theMainExam; model.OnlineExamID = theMainExam.OnlineExamID; //model.Exam.LevelID = theLevel[0].LevelID; // model.Exam.CourseID = theCourse[0].CourseID; // Exam theMainExam = new Exam(); // List<Choice> theChoices = new List<Choice>(); Choice theChoice1 = new Choice(); if (model.Answer.Equals("A")) { theChoice1.IsAnswer = true; } else { theChoice1.IsAnswer = false; } theChoice1.Question = model; theChoice1.Text = model.Choice1; Choice theChoice2 = new Choice(); if (model.Answer.Equals("B")) { theChoice2.IsAnswer = true; } else { theChoice2.IsAnswer = false; } theChoice2.Question = model; theChoice2.Text = model.Choice2; Choice theChoice3 = new Choice(); if (model.Answer.Equals("C")) { theChoice3.IsAnswer = true; } else { theChoice3.IsAnswer = false; } theChoice3.Question = model; theChoice3.Text = model.Choice3; Choice theChoice4 = new Choice(); if (model.Answer.Equals("D")) { theChoice4.IsAnswer = true; } else { theChoice4.IsAnswer = false; } theChoice4.Question = model; theChoice4.Text = model.Choice4; theChoices.Add(theChoice1); theChoices.Add(theChoice2); theChoices.Add(theChoice3); theChoices.Add(theChoice4); if (model.Choice5 != null) { Choice theChoice5 = new Choice(); if (model.Answer.Equals("E")) { theChoice5.IsAnswer = true; } else { theChoice5.IsAnswer = false; } theChoice5.Question = model; theChoice5.Text = model.Choice5; theChoices.Add(theChoice5); } // } // TODO: Add insert logic here model.Choice = theChoices; // work.ExamRepository.Insert(model.Exam); work.QuestionRepository.Insert(model); work.Save(); // work.ChoiceRepository.Insert(); if (model.HasImage == true) { // Create2(int questionID, int examID) return(RedirectToAction("Create2", "Photo", new { questionID = model.QuestionID, onlineExamID = model.OnlineExamID })); // return RedirectToAction("Create","Photo"); } else { return(RedirectToAction("Create", new { examCode = model.Exam.ExamCode })); } } catch { return(View()); } }
public ActionResult Delete(int id) { OnlineExam theExam = work.OnlineExamRepository.GetByID(id); return(View(theExam)); }
// public ActionResult IndexAsync(string ExamCode = "kababa") public ActionResult Index(string ExamCode = "kababa") { //HttpContext.Server.ScriptTimeout = 888888888; List <OnlineExam> theExam = null; Int32 examStudentUserName = Convert.ToInt32(User.Identity.Name); //List<PrimarySchoolStudent> examStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == examStudentUserName).ToList(); //PrimarySchoolStudent examStudent = examStudents[0]; PrimarySchoolStudent examStudent = work.PrimarySchoolStudentRepository.Get(a => a.UserID == examStudentUserName).First(); // PrimarySchoolStudent examStudent = examStudents[0]; //Course theCourse = work.CourseRepository.GetByID(id); if (ExamCode == "kababa") { if (examStudent.ExamWritingNow != null) { theExam = work.OnlineExamRepository.Get(a => a.Visible == "true" && a.LevelName.Equals(examStudent.PresentLevel) && !(a.ExamCode.Equals(examStudent.ExamWritingNow))).ToList(); } else { theExam = work.OnlineExamRepository.Get(a => a.Visible == "true" && a.LevelName.Equals(examStudent.PresentLevel)).ToList(); } // List<Exam> theExam = work.ExamRepository.Get(a => a.LevelName.Equals(level) && a.Term== term && a.Visible== "true").ToList();// && a.CourseID == courseID } else { if (examStudent.ExamWritingNow != null) { theExam = work.OnlineExamRepository.Get(a => a.Visible == "true" && a.ExamCode.Equals(ExamCode) && a.LevelName.Equals(examStudent.PresentLevel) && !(a.ExamCode.Equals(examStudent.ExamWritingNow))).ToList(); } else { theExam = work.OnlineExamRepository.Get(a => a.Visible == "true" && a.ExamCode.Equals(ExamCode) && a.LevelName.Equals(examStudent.PresentLevel)).ToList(); } if (theExam.Count > 0) { Examme = theExam[0]; IList <Question> theQs = new ExamService().GetQuestions(theExam[0]); var rnd = new Random(); IList <Question> theRamdomExam = theQs.OrderBy(x => rnd.Next()).ToList(); IList <Question> theRealRamdomExam = new List <Question>(); int counter = 0; foreach (var q in theRamdomExam) { counter = counter + 1; q.FakeNumber = counter; theRealRamdomExam.Add(q); } // Examme.AddQuestion(theQs); // Examme.AddQuestion(theRamdomExam); Examme.AddQuestion(theRealRamdomExam); } } // if its only a practise exam/test dont update anyfin if ((Examme.ExamType != "Practise" && Examme.ExamType != "PractiseRecord")) { if (examStudent.ExamWritingNow != null && theExam.Count > 0 && ExamCode != "kababa") { if (examStudent.ExamWritingNow.Equals(ExamCode)) { ModelState.AddModelError("", "Becuase you Refreshed(or Pressed the back Button) this page, you are now disqalified from this Exam!"); OnlineExam myFakeExam = new OnlineExam(); return(View(myFakeExam)); } else { //examStudent.ExamWritingNow = ExamCode; //work.PrimarySchoolStudentRepository.Update(examStudent); //work.Save(); int personID = examStudent.PersonID; PrimarySchoolStudent studentEx = work2.PrimarySchoolStudentRepository.GetByID(personID); studentEx.ExamWritingNow = ExamCode; //examStudent.ExamWritingNow = ExamCode; work2.PrimarySchoolStudentRepository.Update(studentEx); work2.Save(); } } if (examStudent.ExamWritingNow == null && theExam.Count > 0 && ExamCode != "kababa") { int personID = examStudent.PersonID; PrimarySchoolStudent studentEx = work2.PrimarySchoolStudentRepository.GetByID(personID); studentEx.ExamWritingNow = ExamCode; //examStudent.ExamWritingNow = ExamCode; work2.PrimarySchoolStudentRepository.Update(studentEx); work2.Save(); } } List <SelectListItem> ExamCodes = new List <SelectListItem>(); foreach (var exam in theExam) { ExamCodes.Add(new SelectListItem() { Text = exam.ExamCode, Value = exam.ExamCode }); } ViewData["ExamCodes"] = ExamCodes; return(View(Examme)); }
public ActionResult Grade(OnlineExam exam) { if (exam.Questions.Count == 0) { // RedirectToAction("Index"); return(View("Error")); } else { var grade = new ExamService().Grade(exam); Question theQuestion = work.QuestionRepository.GetByID(exam.Questions[0].QuestionID); OnlineExam theOnlineExam = work.OnlineExamRepository.GetByID(theQuestion.OnlineExamID); //get user who has just finished the exam Int32 UserName = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == UserName).ToList(); PrimarySchoolStudent theStudent = theStudents[0]; if (theOnlineExam.ExamType == "PractiseRecord") { string theUserID = Convert.ToString(theStudent.UserID); List <PractiseSave> thePractice = work.PractiseSaveRepository.Get(a => a.Term.Equals(theOnlineExam.Term) && a.Code.Equals(theOnlineExam.ExamCode) && a.StudentID.Equals(theUserID)).ToList(); //Check if there is not an exam code equal to this one if (thePractice.Count == 0) { PractiseSave theStudentScore = new PractiseSave(); double e = ((grade.Score / grade.TotalPoints) * 100); theStudentScore.Score = Convert.ToDecimal(e); theStudentScore.Level = theStudent.PresentLevel; theStudentScore.StudentID = Convert.ToString(theStudent.UserID); theStudentScore.Subject = theOnlineExam.Course; theStudentScore.Term = theOnlineExam.Term; theStudentScore.Code = theOnlineExam.ExamCode; theStudentScore.LevelType = theStudent.LevelType; // theStudentScore. work.PractiseSaveRepository.Insert(theStudentScore); work.Save(); } } if (theOnlineExam.ExamType == "Exam" || theOnlineExam.ExamType == "TEST 1" || theOnlineExam.ExamType == "TEST 2") { //if student has no repeat if (theStudent.RepeatTimes == 0) { List <Exam> theExam0 = work.ExamRepository.Get(a => a.StudentCode == theStudent.UserID && a.Level.Equals(theStudent.PresentLevel) && a.SubjectName.Equals(theOnlineExam.Course) && a.Term.Equals(theOnlineExam.Term)).ToList(); // if (theOnlineExam.ExamType == "Exam") { if (theExam0.Count > 0) { // if(theExam0) Exam theStudentScore = theExam0[0]; if (theStudentScore.SubjectExam == 0) { double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.ExamRepository.Update(theStudentScore); work2.Save(); } } else { Exam theStudentScore = new Exam(); theStudentScore.Term = theOnlineExam.Term; theStudentScore.SubjectName = theOnlineExam.Course; theStudentScore.Level = theStudent.PresentLevel; theStudentScore.StudentCode = theStudent.UserID; double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.ExamRepository.Insert(theStudentScore); work2.Save(); } } if (theOnlineExam.ExamType == "TEST 1") { if (theExam0.Count > 0) { Exam theStudentScore = theExam0[0]; if (theStudentScore.FirstCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.FirstCA = Convert.ToDecimal(t2); work2.ExamRepository.Update(theStudentScore); work2.Save(); } } else { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam theExam = new Exam(); theExam.FirstCA = Convert.ToDecimal(t1); theExam.Term = theOnlineExam.Term; theExam.SubjectName = theOnlineExam.Course; theExam.Level = theStudent.PresentLevel; theExam.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.ExamRepository.Insert(theExam); work2.Save(); } } if (theOnlineExam.ExamType == "TEST 2") { if (theExam0.Count > 0) { Exam theStudentScore = theExam0[0]; if (theStudentScore.SecondCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.SecondCA = Convert.ToDecimal(t2); work2.ExamRepository.Update(theStudentScore); work2.Save(); } } else { if (theOnlineExam.ExamType == "TEST 2") { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam theExam = new Exam(); theExam.SecondCA = Convert.ToDecimal(t1); theExam.Term = theOnlineExam.Term; theExam.SubjectName = theOnlineExam.Course; theExam.Level = theStudent.PresentLevel; theExam.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.ExamRepository.Insert(theExam); work2.Save(); //Exam theStudentScore = theExam0[0]; //double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.3; //theStudentScore.SecondCA = Convert.ToDecimal(t2); //work2.ExamRepository.Update(theStudentScore); //work2.Save(); } } } } //check for repeat 1 if (theStudent.RepeatTimes == 1) { List <Exam1> theExam1 = work.Exam1Repository.Get(a => a.StudentCode == theStudent.UserID && a.Level.Equals(theStudent.PresentLevel) && a.SubjectName.Equals(theOnlineExam.Course) && a.Term.Equals(theOnlineExam.Term)).ToList(); // if (theOnlineExam.ExamType == "Exam") { if (theExam1.Count > 0) { Exam1 theStudentScore = theExam1[0]; if (theStudentScore.SubjectExam == 0) { double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.Exam1Repository.Update(theStudentScore); work2.Save(); } } else { if (theOnlineExam.ExamType == "Exam") { Exam1 theStudentScore = new Exam1(); theStudentScore.Term = theOnlineExam.Term; theStudentScore.SubjectName = theOnlineExam.Course; theStudentScore.Level = theStudent.PresentLevel; theStudentScore.StudentCode = theStudent.UserID; double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.Exam1Repository.Insert(theStudentScore); work2.Save(); //Exam1 theStudentScore = new Exam1(); //theStudentScore.SecondCA = 0.00M; //double e = ((grade.Score / grade.TotalPoints) * 100) * 0.5; //// theStudentScore.SubjectExam = e; //theStudentScore.SubjectExam = Convert.ToDecimal(e); //work2.Exam1Repository.Insert(theStudentScore); //work2.Save(); } } } if (theOnlineExam.ExamType == "TEST 1") { if (theExam1.Count > 0) { Exam1 theStudentScore = theExam1[0]; if (theStudentScore.FirstCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.FirstCA = Convert.ToDecimal(t2); work2.Exam1Repository.Update(theStudentScore); work2.Save(); } } else { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam1 theExamlocal1 = new Exam1(); theExamlocal1.FirstCA = Convert.ToDecimal(t1); theExamlocal1.Term = theOnlineExam.Term; theExamlocal1.SubjectName = theOnlineExam.Course; theExamlocal1.Level = theStudent.PresentLevel; theExamlocal1.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.Exam1Repository.Insert(theExamlocal1); work2.Save(); } } if (theExam1.Count > 0) { if (theOnlineExam.ExamType == "TEST 2") { Exam1 theStudentScore = theExam1[0]; if (theStudentScore.SecondCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.SecondCA = Convert.ToDecimal(t2); work2.Exam1Repository.Update(theStudentScore); work2.Save(); } } } else { if (theOnlineExam.ExamType == "TEST 2") { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam1 theExam = new Exam1(); theExam.SecondCA = Convert.ToDecimal(t1); theExam.Term = theOnlineExam.Term; theExam.SubjectName = theOnlineExam.Course; theExam.Level = theStudent.PresentLevel; theExam.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.Exam1Repository.Insert(theExam); work2.Save(); } } } //check for repeat 2 if (theStudent.RepeatTimes == 2) { List <Exam2> theExam2 = work.Exam2Repository.Get(a => a.StudentCode == theStudent.UserID && a.Level.Equals(theStudent.PresentLevel) && a.SubjectName.Equals(theOnlineExam.Course) && a.Term.Equals(theOnlineExam.Term)).ToList(); // if (theOnlineExam.ExamType == "Exam") { if (theExam2.Count > 0) { Exam2 theStudentScore = theExam2[0]; if (theStudentScore.SubjectExam == 0) { double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.Exam2Repository.Update(theStudentScore); work2.Save(); } } else { if (theOnlineExam.ExamType == "Exam") { Exam2 theStudentScore = new Exam2(); theStudentScore.Term = theOnlineExam.Term; theStudentScore.SubjectName = theOnlineExam.Course; theStudentScore.Level = theStudent.PresentLevel; theStudentScore.StudentCode = theStudent.UserID; double e = ((grade.Score / grade.TotalPoints) * 100) * 0.6; theStudentScore.SubjectExam = Convert.ToDecimal(e); work2.Exam2Repository.Insert(theStudentScore); work2.Save(); //Exam2 theStudentScore = new Exam2(); //theStudentScore.SecondCA = 0.00M; //double e = ((grade.Score / grade.TotalPoints) * 100) * 0.5; //// theStudentScore.SubjectExam = e; //theStudentScore.SubjectExam = Convert.ToDecimal(e); //work2.Exam2Repository.Insert(theStudentScore); //work2.Save(); } } } if (theOnlineExam.ExamType == "TEST 1") { if (theExam2.Count == 0) { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam2 theExamlocal2 = new Exam2(); theExamlocal2.FirstCA = Convert.ToDecimal(t1); theExamlocal2.Term = theOnlineExam.Term; theExamlocal2.SubjectName = theOnlineExam.Course; theExamlocal2.Level = theStudent.PresentLevel; theExamlocal2.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.Exam2Repository.Insert(theExamlocal2); work2.Save(); } else { Exam2 theStudentScore = theExam2[0]; if (theStudentScore.FirstCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.FirstCA = Convert.ToDecimal(t2); work2.Exam2Repository.Update(theStudentScore); work2.Save(); } } } if (theOnlineExam.ExamType == "TEST 2") { if (theExam2.Count > 0) { Exam2 theStudentScore = theExam2[0]; if (theStudentScore.SecondCA == 0) { double t2 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; theStudentScore.SecondCA = Convert.ToDecimal(t2); work2.Exam2Repository.Update(theStudentScore); work2.Save(); } } else { if (theOnlineExam.ExamType == "TEST 2") { double t1 = ((grade.Score / grade.TotalPoints) * 100) * 0.2; Exam2 theExam = new Exam2(); theExam.SecondCA = Convert.ToDecimal(t1); theExam.Term = theOnlineExam.Term; theExam.SubjectName = theOnlineExam.Course; theExam.Level = theStudent.PresentLevel; theExam.StudentCode = theStudent.UserID; // theStudentScore.FirstCA = work2.Exam2Repository.Insert(theExam); work2.Save(); } } } } } return(View(grade)); } //return View(); }
public ActionResult LoadExamDuration(int examID) { OnlineExam theExam = work.OnlineExamRepository.GetByID(examID); return(Json(theExam.Duration, JsonRequestBehavior.AllowGet)); }