data templates corrected

This commit is contained in:
Talhadeveloperr
2026-09-09 17:50:37 +05:00
parent 3840d2104c
commit aa3faf674f
61 changed files with 227 additions and 161 deletions

View File

@@ -69,77 +69,91 @@ def main():
all_batches = batches_25 + batches_26
# ---- instructors (4-digit employee codes) ----
instructors = [
["1001", "Dr. Ahsan Raza", "CS"],
["1002", "Ms. Sana Tariq", "CS"],
["1003", "Mr. Bilal Khan", "CS"],
["1004", "Dr. Farah Iqbal", "EE"],
["1005", "Mr. Usman Ali", "EE"],
["1006", "Ms. Hira Shah", "CS"],
]
write_csv(
"instructor/instructors.csv",
["instructor_code", "instructor_name", "department"],
instructors,
)
# ---- courses ----
# is_general courses are shared across all batches of the same session
# (so they can be scheduled together on Tuesday with no clash).
# One row per subject: lectures/labs per week are counted separately so
# a single course can carry both, and each course names its preferred
# lecture/lab room (the scheduler falls back to another same-type room
# only if the preferred one is busy).
# is_general courses are shared across every batch of the same session
# (so they can be scheduled together on Tuesday first, with no clash).
courses = [
["CS101", "Programming Fundamentals", "theory", 3, "no"],
["CS102", "Programming Fundamentals Lab", "lab", 1, "no"],
["CS201", "Data Structures", "theory", 3, "no"],
["CS202", "Data Structures Lab", "lab", 1, "no"],
["EE101", "Basic Electronics", "theory", 3, "no"],
["EE102", "Basic Electronics Lab", "lab", 1, "no"],
["GEN101", "Functional English", "theory", 3, "yes"],
["GEN102", "Islamic Studies", "theory", 2, "yes"],
# course_id, course_name, credit_hours, lectures_per_week, labs_per_week, is_general, lecture_room_id, lab_room_id
["CS101", "Programming Fundamentals", 4, 2, 1, "no", "A-101", "A-L01"],
["CS201", "Data Structures", 4, 2, 1, "no", "A-102", "A-L01"],
["EE101", "Basic Electronics", 4, 2, 1, "no", "A-201", "A-L02"],
["GEN101", "Functional English", 3, 2, 0, "yes", "A-103", ""],
["GEN102", "Islamic Studies", 2, 1, 0, "yes", "A-103", ""],
]
write_csv(
"courses/courses.csv",
["course_id", "course_name", "course_type", "credit_hours", "is_general"],
[
"course_id", "course_name", "credit_hours", "lectures_per_week",
"labs_per_week", "is_general", "lecture_room_id", "lab_room_id",
],
courses,
)
# ---- course offerings: which course is taught to which batch, by whom ----
# General courses (GEN101/GEN102) are offered once per session (25/26)
# and shared across every batch in that session.
# ---- course offerings: course + section (a section groups the batches
# taking that section together) + who teaches it ----
# A course can have many sections; here each CS/EE batch of a session is
# its own section (Section A/B/...), while general courses have a single
# section "ALL" grouping every batch of that session.
offerings = []
dept_theory_lab = {
"CS": [("CS101", "CS102"), ("CS201", "CS202")],
"EE": [("EE101", "EE102")],
}
dept_course = {"CS": ["CS101", "CS201"], "EE": ["EE101"]}
dept_instructors = {
"CS": ["1001", "1002", "1003", "1006"],
"EE": ["1004", "1005"],
}
for batch_code, department, program, session in all_batches:
pairs = dept_theory_lab[department]
instr_pool = dept_instructors[department]
for i, (theory_id, lab_id) in enumerate(pairs):
instr = instr_pool[i % len(instr_pool)]
offerings.append([theory_id, batch_code, instr])
offerings.append([lab_id, batch_code, instr])
section_letters = ["A", "B", "C", "D"]
dept_section_counter = {"CS": 0, "EE": 0}
# general courses: one offering per (course, session), batch_group lists
# every batch code sharing that session, separated by "|"
for batch_code, department, program, session in all_batches:
section_id = section_letters[dept_section_counter[department] % len(section_letters)]
dept_section_counter[department] += 1
for i, course_id in enumerate(dept_course[department]):
instr_pool = dept_instructors[department]
instr = instr_pool[i % len(instr_pool)]
offerings.append([course_id, section_id, batch_code, instr])
# general courses: one offering per (course, session), section "ALL"
# grouping every batch code sharing that session, separated by "|"
for session, batch_group in (
("25", [b[0] for b in batches_25]),
("26", [b[0] for b in batches_26]),
):
offerings.append(["GEN101", "|".join(batch_group), "1002"])
offerings.append(["GEN102", "|".join(batch_group), "1006"])
offerings.append(["GEN101", "ALL", "|".join(batch_group), "1002"])
offerings.append(["GEN102", "ALL", "|".join(batch_group), "1006"])
write_csv(
"courses/course_offering.csv",
["course_id", "batch_code", "instructor_code"],
["course_id", "section_id", "batch_codes", "instructor_code"],
offerings,
)
# ---- instructors (4-digit employee codes) ----
# Derived from the offerings above so it can never drift: one row per
# unique (instructor, course, section) teaching assignment.
instructor_names = {
"1001": "Dr. Ahsan Raza",
"1002": "Ms. Sana Tariq",
"1003": "Mr. Bilal Khan",
"1004": "Dr. Farah Iqbal",
"1005": "Mr. Usman Ali",
"1006": "Ms. Hira Shah",
}
instructors = []
for course_id, section_id, batch_codes, instr_code in offerings:
instructors.append([instr_code, instructor_names[instr_code], course_id, section_id])
write_csv(
"instructor/instructors.csv",
["instructor_code", "instructor_name", "course_id", "section_id"],
instructors,
)
# ---- students (roll_no = batch_code-seq) ----
students = []
for batch_code, department, program, session in all_batches: