more chnages
This commit is contained in:
@@ -21,17 +21,26 @@ def generate_batch_wise_templates(sessions, data, output_dir):
|
||||
batch_code = batch["batch_code"]
|
||||
batch_sessions = _sessions_for_batch(sessions, batch_code)
|
||||
|
||||
# A batch-wise view can legitimately show more than one lecture in
|
||||
# the same slot (e.g. sections of the batch split across rooms), so
|
||||
# every session landing on a cell is kept and rendered — none are
|
||||
# dropped or overwritten.
|
||||
by_day_slot = {}
|
||||
for s in batch_sessions:
|
||||
for slot_index in s["slot_indices"]:
|
||||
by_day_slot[(s["day"], slot_index)] = s
|
||||
by_day_slot.setdefault((s["day"], slot_index), []).append(s)
|
||||
|
||||
def cell_text(day, slot_index, by_day_slot=by_day_slot):
|
||||
s = by_day_slot.get((day, slot_index))
|
||||
if not s:
|
||||
entries = by_day_slot.get((day, slot_index))
|
||||
if not entries:
|
||||
return ""
|
||||
tag = " (Lab)" if s["course_type"] == "lab" else (" (General)" if s["is_general"] else "")
|
||||
return f'{s["course_name"]}{tag}\n{s["instructor_name"]}\n{s["room_id"]}'
|
||||
lines = []
|
||||
for s in entries:
|
||||
tag = " (Lab)" if s["course_type"] == "lab" else (" (General)" if s["is_general"] else "")
|
||||
lines.append(f'{s["course_name"]}{tag}\n{s["instructor_name"]}\n{s["room_id"]}')
|
||||
return "\n---\n".join(lines)
|
||||
|
||||
first_by_day_slot = {k: v[0] for k, v in by_day_slot.items()}
|
||||
|
||||
wb = new_workbook()
|
||||
ws = wb.active
|
||||
@@ -41,7 +50,7 @@ def generate_batch_wise_templates(sessions, data, output_dir):
|
||||
title=f"Batch {batch_code}",
|
||||
subtitle=subtitle,
|
||||
time_slots=GRID_TIME_SLOTS,
|
||||
sessions_by_day_slot=by_day_slot,
|
||||
sessions_by_day_slot=first_by_day_slot,
|
||||
cell_text_fn=cell_text,
|
||||
)
|
||||
path = save_workbook(wb, output_dir, f"{batch_code}.xlsx")
|
||||
|
||||
Reference in New Issue
Block a user