/// <summary>
        /// Select a list of lecturetimes to be used
        /// </summary>
        /// <param name="course">the current course to be scheduled</param>
        /// <param name="possibleLectureTimes">a list of lecturetimes</param>
        /// <returns>a list of lecturetimes</returns>
        public List <LectureTime> SelectLectureTimes(Kursus course, List <LectureTime> possibleLectureTimes)
        {
            int lectureCount = course.ModuleCount;
            List <LectureTime> listToReturn = new List <LectureTime>();

            listToReturn = possibleLectureTimes.Take(lectureCount).ToList();
            return(listToReturn);
        }
        /// <summary>
        /// method to check if the total number of students is >= the capacity of the lokale
        /// </summary>
        /// <param name="room">a room</param>
        /// <param name="course">the current course to be scheduled</param>
        /// <returns>true if the room has enough space for the course and false otherwise</returns>
        public bool RoomHasCapacity(Lokale room, Kursus course)
        {
            List <int> holdCountList  = HoldCount(course);
            int        totalSumOfHold = holdCountList.Sum();

            return(room.LokaleCapacity >= totalSumOfHold);

            //return room.LokaleCapacity >= course.HoldObjs.Select(h => h.HoldAntal).Sum();
        }
        /// <summary>
        /// method to get all the rooms with sufficient capacity, based on the
        /// total number of students registered for the course
        /// </summary>
        /// <param name="kursus">the current course to be scheduled</param>
        /// <param name="lokalelist">a list of rooms</param>
        /// <returns></returns>
        List <Lokale> FindPossibleRooms(Kursus kursus, List <Lokale> lokalelist)
        {
            List <Lokale> possibleRooms = new List <Lokale>();

            foreach (Lokale lokale in lokalelist)
            {
                if (RoomHasCapacity(lokale, kursus))
                {
                    possibleRooms.Add(lokale);
                }
            }

            return(possibleRooms);
        }
Beispiel #4
0
        //Her kan man opdatere et kursus fra listen
        public void UpdateKursus(Kursus @kurs)
        {
            List <Kursus> @kursus = GetAllKursus().ToList();

            if (@kursus != null)
            {
                foreach (var k in @kursus)
                {
                    if (k.ID == @kurs.ID)
                    {
                        k.ID          = kurs.ID;
                        k.Beskrivelse = kurs.Beskrivelse;
                        k.DateTime    = kurs.DateTime;
                        k.Lokale      = kurs.Lokale;
                        k.Navn        = kurs.Navn;
                        k.Underviser  = kurs.Underviser;
                    }
                }
            }
            JsonFileWritter.WriteToJson(@kursus, JsonFileName);
        }
Beispiel #5
0
        //Tilføjer et kursus, hvor den automatisk giver det næste ID i rækkefølgen
        //Så man ikke selv skal skrive det ind manuelt
        public void AddKursus(Kursus k)
        {
            List <Kursus> @kursuses = GetAllKursus().ToList();
            List <int>    kursusIds = new List <int>();

            foreach (var ku in kursuses)
            {
                kursusIds.Add(ku.ID);
            }
            if (kursusIds.Count != 0)
            {
                int start = kursusIds.Max();
                k.ID = start + 1;
            }
            else
            {
                k.ID = 1;
            }
            kursuses.Add(k);
            JsonFileWritter.WriteToJson(@kursuses, JsonFileName);
        }
Beispiel #6
0
 public IActionResult OnGet(int id)
 {
     Kursus = repo.GetKursus(id);
     return(Page());
 }
        /// <summary>
        ///method for choosing the rooms where the lecturetimes >= number of modules in the course
        /// </summary>
        /// <param name="possibleRoomTimesFiltered">a list of the preferred lecturetimes</param>
        /// <param name="course">the current course to be scheduled</param>
        /// <returns>a list of Rooms</returns>
        public List <Lokale> FindPossibleRoomsWithEnoughLectureTimes(Dictionary <Lokale, List <LectureTime> > possibleRoomTimesFiltered, Kursus course)
        {
            List <Lokale> possibleRoomWithEnoughLectureTimes = new List <Lokale>();
            int           numberOfModules = course.ModuleCount;

            foreach (var r in possibleRoomTimesFiltered)
            {
                if (r.Value.Count >= numberOfModules)
                {
                    possibleRoomWithEnoughLectureTimes.Add(r.Key);
                }
            }
            return(possibleRoomWithEnoughLectureTimes);
        }
        /// <summary>
        /// method to filter and select only some particular day(s) of the week and timeofday from the list of lecturetimes
        /// </summary>
        /// <param name="PossibleRoomTimes">a list of lecturetimes</param>
        /// <param name="course">the current course to be scheduled</param>
        /// <returns>a dictionary containing a filtered list of rooms and
        /// lecturetimes of the preferred day/time</returns>
        Dictionary <Lokale, List <LectureTime> > filterPossibleRoomTimes(Dictionary <Lokale, List <LectureTime> > PossibleRoomTimes, Kursus course)
        {
            Dictionary <Lokale, List <LectureTime> > resultFilteredPossibleRoomTimes = new Dictionary <Lokale, List <LectureTime> >();

            foreach (var r in PossibleRoomTimes)
            {
                TimeOfDay todObj = course.PreferredTimeOfday;
                resultFilteredPossibleRoomTimes[r.Key] = new List <LectureTime>();
                foreach (var lt in r.Value)
                {
                    foreach (DayOfWeek prefd in course.PreferredDays)
                    {
                        if (prefd.Equals(lt.WeekDay) && lt.TimeOfDay.Equals(todObj))
                        {
                            resultFilteredPossibleRoomTimes[r.Key].Add(lt);
                        }
                    }
                }
            }
            return(resultFilteredPossibleRoomTimes);
        }
        /// <summary>
        /// method to select the lecturetimes that can be used in the rooms
        /// </summary>
        /// <param name="planned">a list of courses that have already been scheduled</param>
        /// <param name="course">the current course to be scheduled</param>
        /// <param name="freeRoomTimes">all the lecturetimes in all the rooms</param>
        /// <param name="possibleRooms">the rooms with enough capacity for the students registered for the course</param>
        /// <returns>a dictionary containing a list of rooms and the corresponding lecturetimes that can be used in the room</returns>
        Dictionary <Lokale, List <LectureTime> > FindPossibleRoomTimes(List <SchemaCourse> planned, Kursus course,
                                                                       Dictionary <Lokale, List <LectureTime> > freeRoomTimes, List <Lokale> possibleRooms)
        {
            Dictionary <Lokale, List <LectureTime> > possibleRoomTimes = new Dictionary <Lokale, List <LectureTime> >();

            foreach (var r in possibleRooms)
            {
                possibleRoomTimes[r] = new List <LectureTime>();

                foreach (var lt in freeRoomTimes[r])
                {
                    if (IsPossibleTimeForCourse(planned, course, lt))
                    {
                        possibleRoomTimes[r].Add(lt);
                    }
                }
            }
            return(possibleRoomTimes);
        }
 /// <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));
 }
        /// <summary>
        /// returns the total number of students from each Hold that is participating in a given course
        /// </summary>
        /// <param name="kursus">the current course to be scheduled</param>
        /// <returns>a list of integers representing a count of the number of students in each hold</returns>
        private List <int> HoldCount(Kursus kursus)
        {
            IEnumerable <int> numberOfStudents = kursus.HoldObjs.Select(h => h.HoldAntal);

            return(numberOfStudents.ToList());
        }
 public ExceptionSchemaPlanning(Kursus input)
 {
     this.kursusObj = input;
 }