161 lines
5.1 KiB
Python
161 lines
5.1 KiB
Python
"""
|
|
Generates small illustrative dummy CSV datasets under data/dummy/ so the
|
|
timetable template generator has something to schedule and render.
|
|
|
|
Run once:
|
|
python data/dummy/generate_dummy_data.py
|
|
"""
|
|
|
|
import csv
|
|
import os
|
|
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
def write_csv(relative_path, header, rows):
|
|
path = os.path.join(BASE_DIR, relative_path)
|
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
with open(path, "w", newline="", encoding="utf-8") as f:
|
|
writer = csv.writer(f)
|
|
writer.writerow(header)
|
|
writer.writerows(rows)
|
|
print(f"wrote {len(rows)} rows -> {path}")
|
|
|
|
|
|
def main():
|
|
# ---- blocks & rooms (Building/Block A only) ----
|
|
write_csv(
|
|
"blocks/blocks.csv",
|
|
["block_id", "block_name"],
|
|
[["A", "Block A"]],
|
|
)
|
|
|
|
write_csv(
|
|
"blocks/rooms.csv",
|
|
["room_id", "room_name", "block_id", "room_type", "capacity"],
|
|
[
|
|
["A-101", "Room 101", "A", "classroom", 60],
|
|
["A-102", "Room 102", "A", "classroom", 60],
|
|
["A-103", "Room 103", "A", "classroom", 50],
|
|
["A-201", "Room 201", "A", "classroom", 60],
|
|
["A-L01", "Computer Lab 1", "A", "lab", 35],
|
|
["A-L02", "Computer Lab 2", "A", "lab", 35],
|
|
],
|
|
)
|
|
|
|
# ---- departments / programs / batches ----
|
|
# batch_code = session(2) + program_id(6) e.g. 25021519
|
|
batches_25 = [
|
|
["25021519", "CS", "BSCS", "25"],
|
|
["25021520", "CS", "BSSE", "25"],
|
|
["25031519", "EE", "BSEE", "25"],
|
|
]
|
|
batches_26 = [
|
|
["26021519", "CS", "BSCS", "26"],
|
|
["26021520", "CS", "BSSE", "26"],
|
|
["26031519", "EE", "BSEE", "26"],
|
|
]
|
|
|
|
write_csv(
|
|
"batch_codes/25/batches.csv",
|
|
["batch_code", "department", "program", "session"],
|
|
batches_25,
|
|
)
|
|
write_csv(
|
|
"batch_codes/26/batches.csv",
|
|
["batch_code", "department", "program", "session"],
|
|
batches_26,
|
|
)
|
|
|
|
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).
|
|
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"],
|
|
]
|
|
write_csv(
|
|
"courses/courses.csv",
|
|
["course_id", "course_name", "course_type", "credit_hours", "is_general"],
|
|
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.
|
|
offerings = []
|
|
|
|
dept_theory_lab = {
|
|
"CS": [("CS101", "CS102"), ("CS201", "CS202")],
|
|
"EE": [("EE101", "EE102")],
|
|
}
|
|
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])
|
|
|
|
# general courses: one offering per (course, session), batch_group lists
|
|
# 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"])
|
|
|
|
write_csv(
|
|
"courses/course_offering.csv",
|
|
["course_id", "batch_code", "instructor_code"],
|
|
offerings,
|
|
)
|
|
|
|
# ---- students (roll_no = batch_code-seq) ----
|
|
students = []
|
|
for batch_code, department, program, session in all_batches:
|
|
for seq in range(1, 6): # 5 sample students per batch
|
|
roll_no = f"{batch_code}-{seq:03d}"
|
|
students.append([roll_no, batch_code, f"Student {roll_no}"])
|
|
|
|
write_csv(
|
|
"roll_no/students.csv",
|
|
["roll_no", "batch_code", "student_name"],
|
|
students,
|
|
)
|
|
|
|
print("\nDummy data generation complete.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|