data templates corrected
This commit is contained in:
@@ -14,8 +14,23 @@ from template_logger import log_error # noqa: E402
|
||||
|
||||
def generate_teacher_wise_templates(sessions, data, output_dir):
|
||||
written = []
|
||||
for instructor in data["instructors"]:
|
||||
code = instructor["instructor_code"]
|
||||
|
||||
# instructors.csv has one row per (instructor, course, section) teaching
|
||||
# assignment, so the same instructor_code can repeat; render one sheet
|
||||
# per unique instructor, listing all of their assignments in the subtitle.
|
||||
seen_codes = []
|
||||
assignments_by_code = {}
|
||||
name_by_code = {}
|
||||
for row in data["instructors"]:
|
||||
code = row["instructor_code"]
|
||||
if code not in assignments_by_code:
|
||||
seen_codes.append(code)
|
||||
assignments_by_code[code] = []
|
||||
name_by_code[code] = row["instructor_name"]
|
||||
assignments_by_code[code].append(f'{row["course_id"]} (Sec {row["section_id"]})')
|
||||
|
||||
for code in seen_codes:
|
||||
instructor_name = name_by_code[code]
|
||||
instr_sessions = [s for s in sessions if s["instructor_code"] == code]
|
||||
|
||||
# A teacher can only be in one place at a time: each (day, slot)
|
||||
@@ -35,7 +50,7 @@ def generate_teacher_wise_templates(sessions, data, output_dir):
|
||||
for e in entries
|
||||
)
|
||||
log_error(
|
||||
f"Teacher conflict: {instructor['instructor_name']} ({code}) is double-booked on "
|
||||
f"Teacher conflict: {instructor_name} ({code}) is double-booked on "
|
||||
f"{day} slot {slot_index}: {course_list}"
|
||||
)
|
||||
by_day_slot[(day, slot_index)] = entries[0]
|
||||
@@ -47,17 +62,19 @@ def generate_teacher_wise_templates(sessions, data, output_dir):
|
||||
s = entries[0]
|
||||
tag = " (Lab)" if s["course_type"] == "lab" else (" (General)" if s["is_general"] else "")
|
||||
batches = "+".join(s["batch_codes"])
|
||||
text = f'{s["course_name"]}{tag}\n{batches}\n{s["room_id"]}'
|
||||
text = f'{s["course_name"]}{tag} [Sec {s["section_id"]}]\n{batches}\n{s["room_id"]}'
|
||||
if len(entries) > 1:
|
||||
text = "CONFLICT!\n" + text
|
||||
return text
|
||||
|
||||
subtitle = "Teaches: " + ", ".join(assignments_by_code[code])
|
||||
|
||||
wb = new_workbook()
|
||||
ws = wb.active
|
||||
build_grid_sheet(
|
||||
ws,
|
||||
title=f'{instructor["instructor_name"]} ({code})',
|
||||
subtitle=f'Department: {instructor["department"]}',
|
||||
title=f'{instructor_name} ({code})',
|
||||
subtitle=subtitle,
|
||||
time_slots=GRID_TIME_SLOTS,
|
||||
sessions_by_day_slot=by_day_slot,
|
||||
cell_text_fn=cell_text,
|
||||
|
||||
Reference in New Issue
Block a user