import os import tempfile import subprocess from typing import Optional, Tuple, List import pytube from src.video_processing import extract_audio_from_video from src.quiz_processing import analyze_document import docx import PyPDF2 import re def parse_quiz_content(quiz_text): questions = [] lines = quiz_text.split('\n') current_question = None for line in lines: line = line.strip() if not line: continue q_match = re.match(r'^(?:\d+\.|\[?Q\d+\]?\.?)\s+(.*)', line, re.IGNORECASE) if q_match: if current_question: questions.append(current_question) current_question = {"question": q_match.group(1), "answer": ""} elif current_question and line.lower().startswith(("answer:", "a:", "ans:")): answer_text = re.sub(r'^(?:answer:|a:|ans:)\s*', '', line, flags=re.IGNORECASE) current_question["answer"] = answer_text.strip() if current_question: questions.append(current_question) return {"questions": questions}