From d79671ee735879ec524f8e9eea881298f80032ce Mon Sep 17 00:00:00 2001 From: ectasy663 Date: Mon, 27 Jul 2026 15:06:04 +0530 Subject: [PATCH] chore: add mock seeding script for dpps --- backend/seed_dpps_mock.py | 83 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 backend/seed_dpps_mock.py diff --git a/backend/seed_dpps_mock.py b/backend/seed_dpps_mock.py new file mode 100644 index 0000000..54fe129 --- /dev/null +++ b/backend/seed_dpps_mock.py @@ -0,0 +1,83 @@ +import asyncio +import os +import uuid +import random +from sqlmodel import Session, select, delete +from datetime import datetime + +from database import engine +import models + +def seed_tests(): + admin_id_str = "b0e17378-864d-439e-8806-708dc48a891b" + + with Session(engine) as session: + admin = session.exec(select(models.User).limit(1)).first() + admin_id = admin.id if admin else uuid.UUID(admin_id_str) + + # Clear existing DPS tests + statement = select(models.Test).where(models.Test.type == "DPS") + old_tests = session.exec(statement).all() + for t in old_tests: + session.delete(t) + session.commit() + + subjects = [ + ("Physics", "Laws of Motion", "dps-phy-ch4-20260707.pdf"), + ("Chemistry", "Chemical Thermodynamics", "dps-che-ch4-20260707.pdf"), + ("Mathematics", "Calculus", "dps-mth-ch4-20260707.pdf"), + ("Biology", "Genetics", "dps-bio-ch4-20260707.pdf") + ] + + for exam in [models.ExamEnum.JEE_MAIN, models.ExamEnum.JEE_ADVANCED, models.ExamEnum.NEET]: + for subject, topic, pdf in subjects: + # Math for NEET? Biology for JEE? Let's just create them anyway so the UI is populated + question_ids = [] + for i in range(1, 16): + new_q = models.Question( + subject=subject, + topic=topic, + subtopic="General", + difficulty="Medium", + type=models.QuestionTypeEnum.MCQ_SINGLE, + question_text=f"Sample mock question {i} for {subject} - {topic}", + options={ + "A": "Option A", + "B": "Option B", + "C": "Option C", + "D": "Option D" + }, + correct_answer={"value": "A"}, + solution_text="Solution provided here.", + language=models.MediumEnum.ENGLISH, + exam=exam, + created_by=admin_id + ) + session.add(new_q) + session.flush() + question_ids.append(str(new_q.id)) + + test_obj = models.Test( + title=f"{subject} Chapter 4 DPS ({exam})", + type="DPS", + exam_pattern=exam, + sections={ + "Section 1": { + "questions": question_ids, + "time_limit": 30 + } + }, + total_time=30, + difficulty="Medium", + scheduled_date=datetime.utcnow(), + is_active=True, + created_by=admin_id + ) + session.add(test_obj) + print(f"Created Test: {test_obj.title}") + + session.commit() + print("Database seeded with mock CBT DPPs for all exams.") + +if __name__ == "__main__": + seed_tests()