private void SetPriorityByLectureTimes() { foreach (SubjectSelection selection in AllSelections) { if (selection.Priority > 0) { foreach (LectureTime time in selection.Times) { foreach (LectureTime denied_time in Denied_Lecture_Times) { if (LectureTime.Intersect(time, denied_time)) { selection.Priority = 0; break; } } if (selection.Priority == 0) { break; } foreach (LectureTime preferred_time in Preferred_Lecture_Times) { if (LectureTime.IsSubset(preferred_time, time)) { selection.Priority += 10; } } } } } }
public ActionResult DeleteConfirmed(int id) { LectureTime lectureTime = db.LectureTimes.Find(id); db.LectureTimes.Remove(lectureTime); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool AddTime(ref SubjectSelection ss, LectureTime lt) { return(connection.Insert <Selection_Time>( new Selection_Time() { LectureTimeId = lt.Id, SelectionId = ss.Id } ) > 0); //insert success }
public ActionResult Edit([Bind(Include = "ID,Start,End")] LectureTime lectureTime) { if (ModelState.IsValid) { db.Entry(lectureTime).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lectureTime)); }
// GET: Home //public ActionResult profile() //{ // //AspNetUser Aspuser =new // // (from c in db.AspNetUsers // // where c.Id == User.Identity.GetUserId() // // select c).ToList(); // return View(); //} public ActionResult About() { ViewBag.Message = "The generation done successfully"; CollegeDatabaseEntities10 _db = new CollegeDatabaseEntities10(); var del = (from x in db.LectureTimes select x); db.LectureTimes.RemoveRange(del); var dell = (from x in db.SectionTimes select x); db.SectionTimes.RemoveRange(dell); // var res = functions.Generatelecandsec() List <GroupModel> GrpList = new List <GroupModel>(); functions func = new functions(); var res = func.Generate_lect(ref GrpList); var assin = func.generatesecs(GrpList); var lecTimeTable = new LectureTime(); foreach (var item in res) { var crs_id = _db.Courses.Where(x => x.Name == item.CourseName).Select(x => x.ID).Single(); lecTimeTable = new LectureTime() { Course_id = crs_id, Room_id = item.RoomId, DayOfWeek = item.Day, Grp_id = item.GrpId, StartHour = item.StartHour }; _db.LectureTimes.Add(lecTimeTable); _db.SaveChanges(); Console.WriteLine("{0} : {1} : {2}", item.CourseName, item.StartHour, item.Day.ToString()); } foreach (var item in assin) { if (item.RoomId != -1) { SectionTime x = new SectionTime(); x.Course_id = item.CourseId; x.Section_id = item.SectionId; x.Room_id = item.RoomId; x.DayOfWeek = item.Day; x.StartHour = item.Start; x.isLab = item.IsLab; x.isSection = item.IsSection; // if(item.Tasids) x.Ta_id = item.Tasids[0]; _db.SectionTimes.Add(x); _db.SaveChanges(); } } return(View()); }
private void AddToTable(SubjectSelection selection) { all_selections.Rows.Add( selection.Id, selection.Subject, selection.Hall, Lecturer.LecturersToString(selection.Lecturers), LectureTime.TimeListToString(selection.Times), selection.ToString() ); }
public ActionResult Create([Bind(Include = "ID,Start,End")] LectureTime lectureTime) { if (ModelState.IsValid) { db.LectureTimes.Add(lectureTime); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lectureTime)); }
private void UpdateInTable(SubjectSelection selection) { foreach (DataRow row in all_selections.Rows) { if (Convert.ToInt32(row["Id"]) == selection.Id) { row["Subject"] = selection.Subject; row["Hall"] = selection.Hall; row["Lecturers"] = Lecturer.LecturersToString(selection.Lecturers); row["Times"] = LectureTime.TimeListToString(selection.Times); row["Filter"] = selection.ToString(); } } }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LectureTime lectureTime = db.LectureTimes.Find(id); if (lectureTime == null) { return(HttpNotFound()); } return(View(lectureTime)); }
//// there is a teacher clash if the teacher for the lecture has already been assigned to the same timeslot //public bool TeacherClash2(List<SchemaCourse> planned, Laerer teacher, LectureTime time) //{ // // All the already planned schemacourses, where a teacher has been booked to teach a course // IEnumerable<SchemaCourse> coursesForThisTeacher = planned.Where(sc => sc.Course.LaererObj == teacher); // //a call to the method 'Any' returns true or false // return coursesForThisTeacher.Any(sc => sc.LectureTimes.Contains(time)); // //return planned.Where(sc => sc.Course.LaererObj == teacher).Any(sc => sc.LectureTimes.Contains(time)); //} /// <summary> /// checks if the teacher for the lecture has already been assigned to the same timeslot somewhere else /// </summary> /// <param name="planned">a list containing all the already scheduled courses</param> /// <param name="teacher">the teacher we are making a check for</param> /// <param name="time">the lecturetime we are checking</param> /// <returns>true if either a teacher or a hold has been scheduled at the same time and false otherwise</returns> public bool TeacherClash(List <SchemaCourse> planned, Laerer teacher, LectureTime time) { bool result = false; foreach (SchemaCourse sc in planned) { if (sc.Course.LaererObj == teacher) { foreach (LectureTime lt in sc.LectureTimes) { if (lt == time) { result = true; } } } } return(result); }
public bool RemoveTime(ref SubjectSelection selection, LectureTime time) { throw new System.Exception("Not implementated"); }
/// <summary> /// Stop Recording the audio voice for lecture /// </summary> public void StopRecordingAudio() { audRec.StopRecording(); timingFile.Close(); this.GenerateHandouts(LectureTime.ToString("HHmmddMMyyyy")); }
// /// <summary> /// method to check if any of the hold in the course has already been scheduled /// at the same time somewhere else /// </summary> /// <param name="planned">a list of courses that have already been scheduled</param> /// <param name="hold">the list of hold participating in the course</param> /// <param name="time">the time we are checking</param> /// <returns></returns> private bool HoldClash(List <SchemaCourse> planned, List <Hold> hold, LectureTime time) { return(hold.Any(h => planned.Where(sc => sc.Course.HoldObjs.Contains(h)).Any(sc => sc.LectureTimes.Contains(time)))); }
/// <summary> /// method used for checking that neither the teacher nor any of the hold have been booked /// elsewhere at the same time /// </summary> /// <param name="planned">a list of planned schemacourses</param> /// <param name="course">the current course to be scheduled</param> /// <param name="time">the lecturetime we are checking</param> /// <returns>returns true if no time clash and false otherwise</returns> public bool IsPossibleTimeForCourse(List <SchemaCourse> planned, Kursus course, LectureTime time) { return(!TeacherClash(planned, course.LaererObj, time) && !HoldClash(planned, course.HoldObjs, time)); }