Revert to version 403c8e4
This commit is contained in:
parent
9ab9dfefba
commit
edea5afdea
@ -104,23 +104,25 @@ foreach ($teacher_schedule_raw as $lesson) {
|
|||||||
if (isset($timeslot_id_to_period_idx[$lesson['timeslot_id']])) {
|
if (isset($timeslot_id_to_period_idx[$lesson['timeslot_id']])) {
|
||||||
$period_idx = $timeslot_id_to_period_idx[$lesson['timeslot_id']];
|
$period_idx = $timeslot_id_to_period_idx[$lesson['timeslot_id']];
|
||||||
|
|
||||||
// Skip if this slot is already filled by a continuation marker
|
if (isset($teacher_timetable_by_period[$day_idx][$period_idx])) {
|
||||||
if (isset($teacher_timetable_by_period[$day_idx][$period_idx]) && isset($teacher_timetable_by_period[$day_idx][$period_idx]['continuation'])) {
|
// This slot is already filled, potentially by a multi-class elective.
|
||||||
continue;
|
// Create an array if it's not already one.
|
||||||
|
if (!is_array($teacher_timetable_by_period[$day_idx][$period_idx])) {
|
||||||
|
$teacher_timetable_by_period[$day_idx][$period_idx] = [$teacher_timetable_by_period[$day_idx][$period_idx]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place the lesson. Handle co-teaching by making it an array.
|
|
||||||
if (!isset($teacher_timetable_by_period[$day_idx][$period_idx]) || $teacher_timetable_by_period[$day_idx][$period_idx] === null) {
|
|
||||||
$teacher_timetable_by_period[$day_idx][$period_idx] = [$lesson];
|
|
||||||
} else {
|
|
||||||
$teacher_timetable_by_period[$day_idx][$period_idx][] = $lesson;
|
$teacher_timetable_by_period[$day_idx][$period_idx][] = $lesson;
|
||||||
|
} else {
|
||||||
|
$teacher_timetable_by_period[$day_idx][$period_idx] = $lesson;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($lesson['is_double'])) {
|
if (!empty($lesson['is_double']) && isset($teacher_timetable_by_period[$day_idx][$period_idx + 1])) {
|
||||||
$next_period_idx = $period_idx + 1;
|
if (isset($teacher_timetable_by_period[$day_idx][$period_idx + 1])) {
|
||||||
if (isset($non_break_periods[$next_period_idx])) {
|
if (!is_array($teacher_timetable_by_period[$day_idx][$period_idx + 1])) {
|
||||||
$continuation_marker = ['continuation' => true, 'original_lesson' => $lesson];
|
$teacher_timetable_by_period[$day_idx][$period_idx + 1] = [$teacher_timetable_by_period[$day_idx][$period_idx + 1]];
|
||||||
$teacher_timetable_by_period[$day_idx][$next_period_idx] = $continuation_marker;
|
}
|
||||||
|
$teacher_timetable_by_period[$day_idx][$period_idx + 1][] = $lesson;
|
||||||
|
} else {
|
||||||
|
$teacher_timetable_by_period[$day_idx][$period_idx + 1] = $lesson;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,27 +234,13 @@ error_log("Final teacher_timetable_by_period structure: " . print_r($teacher_tim
|
|||||||
<small class="text-muted"><?php echo date("g:i A", strtotime($timeslot_info['start_time'])); ?> - <?php echo date("g:i A", strtotime($timeslot_info['end_time'])); ?></small>
|
<small class="text-muted"><?php echo date("g:i A", strtotime($timeslot_info['start_time'])); ?> - <?php echo date("g:i A", strtotime($timeslot_info['end_time'])); ?></small>
|
||||||
</td>
|
</td>
|
||||||
<?php foreach ($days_of_week as $day_idx => $day): ?>
|
<?php foreach ($days_of_week as $day_idx => $day): ?>
|
||||||
|
<td class="timetable-slot align-middle">
|
||||||
<?php
|
<?php
|
||||||
$lessons = $teacher_timetable_by_period[$day_idx][$period_idx] ?? null;
|
$lesson = $teacher_timetable_by_period[$day_idx][$period_idx] ?? null;
|
||||||
|
if ($lesson) {
|
||||||
if (isset($lessons['continuation'])) {
|
// If it's an array of lessons (co-teaching), display them all
|
||||||
// This is a continuation of a double lesson, so we skip rendering the cell.
|
$lessons_to_display = is_array($lesson) && !isset($lesson['id']) ? $lesson : [$lesson];
|
||||||
} else {
|
foreach ($lessons_to_display as $single_lesson) {
|
||||||
$rowspan = 1;
|
|
||||||
// Check if any lesson in this slot is a double lesson
|
|
||||||
if (is_array($lessons)) {
|
|
||||||
foreach ($lessons as $l) {
|
|
||||||
if (!empty($l['is_double'])) {
|
|
||||||
$rowspan = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<td class="timetable-slot align-middle" rowspan="<?php echo $rowspan; ?>">
|
|
||||||
<?php
|
|
||||||
if (is_array($lessons)) {
|
|
||||||
foreach ($lessons as $single_lesson) {
|
|
||||||
if ($single_lesson) { // Check not null
|
if ($single_lesson) { // Check not null
|
||||||
$display_name = $single_lesson['lesson_display_name'];
|
$display_name = $single_lesson['lesson_display_name'];
|
||||||
// For electives, the teacher should see their specific subject.
|
// For electives, the teacher should see their specific subject.
|
||||||
@ -268,9 +256,6 @@ error_log("Final teacher_timetable_by_period structure: " . print_r($teacher_tim
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@ -464,13 +464,7 @@ function get_timetable_from_db($pdo, $classes, $timeslots, $days_of_week) {
|
|||||||
|
|
||||||
$class_timetables[$class_id][$day_idx][$period_idx] = $lesson_data;
|
$class_timetables[$class_id][$day_idx][$period_idx] = $lesson_data;
|
||||||
if ($lesson_data['is_double'] && isset($class_timetables[$class_id][$day_idx][$period_idx + 1])) {
|
if ($lesson_data['is_double'] && isset($class_timetables[$class_id][$day_idx][$period_idx + 1])) {
|
||||||
// For the second part of a double lesson, create a new array
|
$class_timetables[$class_id][$day_idx][$period_idx + 1] = $lesson_data;
|
||||||
// that is marked as a continuation, but does NOT have is_double = true.
|
|
||||||
// This prevents the rendering logic from trying to start a new rowspan.
|
|
||||||
$continuation_data = $lesson_data;
|
|
||||||
$continuation_data['is_double'] = false;
|
|
||||||
$continuation_data['is_continuation'] = true;
|
|
||||||
$class_timetables[$class_id][$day_idx][$period_idx + 1] = $continuation_data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user