Fixed CSV export & Course and Classroom views to use time instead of slot number

This commit is contained in:
haxala1r
2025-12-18 15:56:14 +03:00
parent 93ac7d55a6
commit 39ad08d836
2 changed files with 25 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ import javafx.scene.control.TableView;
import org.example.se302.model.Classroom; import org.example.se302.model.Classroom;
import org.example.se302.model.Course; import org.example.se302.model.Course;
import org.example.se302.model.ScheduleConfiguration; import org.example.se302.model.ScheduleConfiguration;
import org.example.se302.model.TimeSlot;
import org.example.se302.service.DataManager; import org.example.se302.service.DataManager;
import java.time.LocalDate; import java.time.LocalDate;
@@ -170,7 +171,18 @@ public class ScheduleClassroomController {
dateStr = "Day " + (dayIndex + 1); dateStr = "Day " + (dayIndex + 1);
} }
String timeStr = "Slot " + (slotIndex + 1); // Format time
String timeStr;
if (config != null) {
TimeSlot timeSlot = config.getTimeSlot(dayIndex, slotIndex);
if (timeSlot != null) {
timeStr = timeSlot.getStartTime() + " - " + timeSlot.getEndTime();
} else {
timeStr = "Slot " + (slotIndex + 1);
}
} else {
timeStr = "Slot " + (slotIndex + 1);
}
// Calculate utilization // Calculate utilization
int studentCount = course.getEnrolledStudentsCount(); int studentCount = course.getEnrolledStudentsCount();

View File

@@ -10,6 +10,7 @@ import javafx.scene.control.TableRow;
import javafx.scene.control.TableView; import javafx.scene.control.TableView;
import org.example.se302.model.Course; import org.example.se302.model.Course;
import org.example.se302.model.ScheduleConfiguration; import org.example.se302.model.ScheduleConfiguration;
import org.example.se302.model.TimeSlot;
import org.example.se302.service.DataManager; import org.example.se302.service.DataManager;
import java.time.LocalDate; import java.time.LocalDate;
@@ -173,8 +174,18 @@ public class ScheduleCourseController {
dateStr = "Day " + (dayIndex + 1); dateStr = "Day " + (dayIndex + 1);
} }
// Format time using configuration's time slots
if (config != null) {
TimeSlot timeSlot = config.getTimeSlot(dayIndex, slotIndex);
if (timeSlot != null) {
timeStr = timeSlot.getStartTime() + " - " + timeSlot.getEndTime();
} else {
timeStr = "Slot " + (slotIndex + 1); timeStr = "Slot " + (slotIndex + 1);
} }
} else {
timeStr = "Slot " + (slotIndex + 1);
}
}
entries.add(new CourseScheduleEntry(courseCode, enrolled, dateStr, timeStr, classroomStr, entries.add(new CourseScheduleEntry(courseCode, enrolled, dateStr, timeStr, classroomStr,
dayIndex, slotIndex)); dayIndex, slotIndex));