//Creates a view showing what courses the user still needs towards their degree public ActionResult RequiredCourses() { if (User.Identity.IsAuthenticated) { Students user = new StudentsController().QueryStudentID(User.Identity.GetUserId()); var taken = from s in db.Registrations where s.StudentID == user.StudentID select s.AvailableCourses.CourseID; var needs = from s in db.MajorRequirements where !taken.Contains(s.CourseID) select s; var genED = from s in needs where s.CoursePriority.PriorityLevel == 1 select s; var Supple = from s in needs where s.CoursePriority.PriorityLevel == 2 select s; var core = from s in needs where s.CoursePriority.PriorityLevel == 3 select s; ViewBag.Core = core.OrderBy(x => x.Courses.CourseNumber); ViewBag.GenED = genED.OrderBy(x => x.Courses.CourseNumber);; ViewBag.Supplemental = Supple.OrderBy(x => x.Courses.CourseNumber); return(View()); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public ActionResult Search() { if (User.Identity.IsAuthenticated) { Students user = new StudentsController().QueryStudentID(User.Identity.GetUserId()); var taken = from s in db.Registrations where s.StudentID == user.StudentID select s.AvailableCourseID; var Courses = from s in db.AvailableCourses.OrderByDescending(x => x.SemesterYear.Years.Year).ThenByDescending(x => x.SemesterYear.SemesterID).ThenBy(x => x.Courses.Departments.DepartmentName).ThenBy(x => x.Courses.CourseNumber) where !taken.Contains(s.AvailalbeCourseID) select s; var Department = (from s in db.Departments select new SelectListItem { Text = s.DepartmentName, Value = s.DepartmentID.ToString() }).ToList(); ViewBag.Departments = Department; ViewData["Course"] = Courses.ToList(); return(View()); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public ActionResult SearchAndRegister(AvailableCourses model, int?id) { if (id == 0) { RedirectToAction("Search"); } Students user = new StudentsController().QueryStudentID(User.Identity.GetUserId()); var taken = from s in db.Registrations where s.StudentID == user.StudentID select s.AvailableCourseID; var NotTaken = from s in db.AvailableCourses.OrderByDescending(x => x.SemesterYear.Years.Year).ThenBy(x => x.SemesterYear.SemesterID).ThenBy(x => x.Courses.Departments.DepartmentName).ThenBy(x => x.Courses.CourseNumber) where !taken.Contains(s.AvailalbeCourseID) && s.Courses.DepartmentID == id select s; var search = (from s in NotTaken select s); if (model.CourseID != 0) { search = (from s in search where (model.CourseID == s.CourseID) select s); } if (model.SemesterYearID != 0) { search = (from s in search where (model.SemesterYearID == s.SemesterYearID) select s); } var SemesterYear = (from s in db.SemesterYear.OrderByDescending(x => x.Years.Year).ThenByDescending(x => x.SemesterID).AsEnumerable() select new SelectListItem { Text = s.SemesterYearName, Value = s.SemesterYearID.ToString() }).ToList(); var Course = (from s in db.Courses.OrderBy(x => x.Departments.Abbreviation).ThenBy(x => x.CourseNumber).AsEnumerable() where s.DepartmentID == id select new SelectListItem { Text = s.CourseName, Value = s.CourseID.ToString() }).ToList(); ViewBag.SemesterYearID = new SelectList(SemesterYear, "Value", "Text"); ViewBag.CourseID = new SelectList(Course, "Value", "Text"); ViewData["Course"] = search.OrderByDescending(x => x.SemesterYear.Years.Year).ThenByDescending(x => x.SemesterYear.SemesterID).ThenBy(x => x.Courses.Departments.DepartmentName).ThenBy(x => x.Courses.CourseNumber); return(View()); }
public ActionResult RegisterStudent(int id) { Registrations reg = new Registrations(); Students user = new StudentsController().QueryStudentID(User.Identity.GetUserId()); AvailableCourses course = db.AvailableCourses.Find(id); reg.AvailableCourseID = id; reg.StudentID = user.StudentID; db.Registrations.Add(reg); db.SaveChanges(); return(RedirectToAction("Search")); }
public ActionResult IndexStudent() { if (User.Identity.IsAuthenticated) { Students student = new StudentsController().QueryStudentID(User.Identity.GetUserId());; var history = (from s in db.Registrations where s.StudentID == student.StudentID select s).OrderBy(s => s.AvailableCourses.Courses.Departments.DepartmentName).ThenBy(x => x.AvailableCourses.Courses.CourseNumber); ViewData["History"] = history; ViewBag.Student = student; return(View()); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public ActionResult RecommendCourse() { if (User.Identity.IsAuthenticated) { //Taken Courses Students user = new StudentsController().QueryStudentID(User.Identity.GetUserId()); int Year = (from s in db.Years select s.Year).Max(); int Semester = (from s in db.SemesterYear where s.Years.Year == Year select s.SemesterID).Max(); var taken = from s in db.Registrations where s.StudentID == user.StudentID select s.AvailableCourses.CourseID; //Has taken pre-reqs for var Aval = from s in db.Prerequisites where taken.Contains(s.RequiredCourseID) select s.CourseID; //Remove duplicates part 1 var RemFalses = from s in db.Prerequisites where !taken.Contains(s.RequiredCourseID) select s.CourseID; var ClassWithPreq = from s in db.Prerequisites select s.CourseID; //Remove duplicates part 2 Aval = from s in Aval where !RemFalses.Contains(s) select s; //Availble next Semester var nextSemester = from s in db.AvailableCourses where s.SemesterYear.Years.Year == Year && s.SemesterYear.SemesterID == Semester select s.CourseID; var major = from s in db.MajorRequirements select s; //Pull needed class from avalible var Recommend = (from s in major where Aval.Contains(s.CourseID) || (!ClassWithPreq.Contains(s.CourseID) && (!taken.Contains(s.CourseID))) && nextSemester.Contains(s.CourseID) select s); //Sort class based on priority var Queue = new PriorityQueue <MajorRequirements>(); foreach (var item in Recommend) { if (item.CoursePriority.PriorityLevel == 1) { Queue.Enqueue(QueuePriorityEnum.Medium, item); } if (item.CoursePriority.PriorityLevel == 2) { Queue.Enqueue(QueuePriorityEnum.Low, item); } if (item.CoursePriority.PriorityLevel == 3) { Queue.Enqueue(QueuePriorityEnum.High, item); } } List <MajorRequirements> Recommendation = new List <MajorRequirements>(); try { for (int i = 0; i < 6; i++) { Recommendation.Add(Queue.Dequeue()); } } catch (InvalidOperationException) { } ViewBag.Recommendation = Recommendation; return(View()); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }