Fix UI bugs, admin bulk upload limits, test ingestion bugs, and reset demo users

This commit is contained in:
2026-09-25 14:21:48 +05:30
parent 08e54ac055
commit eefcb12ffc
9 changed files with 5911 additions and 146 deletions

64
backend/upload_test.py Normal file
View File

@@ -0,0 +1,64 @@
import sys
sys.path.append('.')
from sqlmodel import Session, select
from database import engine
from models import User, Test, Question, QuestionTypeEnum, ExamEnum
def upload_json():
import json
with open('neet_180_questions.json', 'r', encoding='utf-8') as f:
questions = json.load(f)
with Session(engine) as session:
admin = session.exec(select(User).where(User.tier == 'AI Coach')).first()
if not admin:
print('No admin found')
return
payload = {
'title': 'Test NEET Mock Upload',
'type': 'Mock',
'exam_pattern': 'NEET',
'time_limit': 180,
'admin_id': str(admin.id),
'questions_json': questions
}
test_obj = Test(
title=payload['title'],
type=payload['type'],
exam_pattern=ExamEnum.NEET,
sections={},
total_time=payload['time_limit'],
difficulty='Hard',
is_active=True,
created_by=admin.id
)
session.add(test_obj)
session.flush()
for q in questions:
q_obj = Question(
subject=q.get('subject'),
topic=q.get('topic', 'General'),
subtopic=q.get('subtopic', ''),
difficulty=q.get('difficulty', 'Medium'),
type=QuestionTypeEnum(q.get('type', 'SCQ')),
question_text=q.get('question_text', ''),
options_json=q.get('options', []),
correct_answer=q.get('correct_answer', ''),
solution_text=q.get('explanation', ''), language='English',
test_id=test_obj.id, created_by=admin.id,
section_name=q.get('subject')
)
session.add(q_obj)
session.commit()
print('Successfully added test with ID:', test_obj.id)
upload_json()