course-creator / generators.py
Prof-Reza's picture
Upload 7 files
d50fc97 verified
raw
history blame contribute delete
676 Bytes
import os
import json
import zipfile
def generate_course_zip(plan, sources, out_dir="/tmp/course_agent"):
"""Generate a zip package containing the course plan and sources."""
os.makedirs(out_dir, exist_ok=True)
plan_path = os.path.join(out_dir, "plan.txt")
with open(plan_path, "w") as f:
f.write(plan)
sources_path = os.path.join(out_dir, "sources.json")
with open(sources_path, "w") as f:
json.dump(sources, f)
zip_path = os.path.join(out_dir, "course.zip")
with zipfile.ZipFile(zip_path, "w") as zf:
zf.write(plan_path, arcname="plan.txt")
zf.write(sources_path, arcname="sources.json")
return zip_path