mazfil / lab-allocator

COMP3500 - Resource maximisation planning system for labs
3 stars 1 forks source link

Check for room overlap when changing tutorial room on manage timetable #112

Closed mazfil closed 1 month ago

mazfil commented 2 months ago

The current implementation:

const changeRoom = async (tutorial, room) => {
        var clash = false;
        var potentialClashes = timetable.filter(otherTutorial => { return otherTutorial.location == room }).filter(otherTutorial => (otherTutorial.daysOfWeek = tutorial.event.daysOfWeek))
        potentialClashes.forEach(potentialClash => {
            console.log(tutorial.event)
            console.log(potentialClash.location + " @ " + potentialClash.start + " - " + potentialClash.end)
            if (!(tutorial.event.end <= potentialClash.start || potentialClash.end <= tutorial.event.start)){
                clash = true;
                console.log("A CLASH")
            }
        });
        if (!clash){
            Object.assign(timetable.find((tut) => {return tut.id === tutorial.event.id}), {location: room, title: tutorial.event.id+"\n"+room})
            await setTimetable(timetable)
            await updateData(timetable, activeCourse);
            await toggleChangeRoom();
            pendingRoomChange.event.setProp('title', tutorial.event.id+"\n"+room)
        }else{
            console.log("ERROR CLASH")
        }
    }

fails to correctly detect and log an error when a tutorial is moved to another room and there is a clash with the times of both tutorials.

RachelCaoCC commented 1 month ago
image

The logic is correct, I think line 102 is the issue...it didn't detect the potential clashes. Probably need to rewrite this part..

RachelCaoCC commented 1 month ago
image

Added another log message, tutorial.event.daysOfWeek is undefined..

matthewcawley02 commented 1 month ago

@RachelCaoCC said that this issue was complete