Spaces:
Sleeping
Sleeping
| # src/app/quiz_tools.py | |
| # Placeholder restored because modifications moved to main_app. | |
| # This keeps the file present so import does not fail. | |
| import json | |
| import random | |
| from datetime import datetime | |
| from .config import get_user_dir | |
| from .flashcards_tools import ... | |
| def create_semantic_quiz_for_user(username: str, topic: str, num_questions: int = 5): | |
| reading_passages = [ | |
| f"{topic.capitalize()} is important in daily life. Many people enjoy talking about it.", | |
| f"Here is a short story based on the topic '{topic}'.", | |
| f"In this short description, you will learn more about {topic}.", | |
| ] | |
| questions = [] | |
| for i in range(num_questions): | |
| passage = random.choice(reading_passages) | |
| q_type = random.choice(["translate_phrase", "summarize", "interpret"]) | |
| if q_type == "translate_phrase": | |
| questions.append({ | |
| "type": "semantic_translate_phrase", | |
| "prompt": f"Translate: | |
| '{passage}'", | |
| "answer": "(model evaluated)", | |
| "explanation": f"Checks ability to translate topic '{topic}'." | |
| }) | |
| elif q_type == "summarize": | |
| questions.append({ | |
| "type": "semantic_summarize", | |
| "prompt": f"Summarize: | |
| {passage}", | |
| "answer": "(model evaluated)", | |
| "explanation": f"Checks comprehension of topic '{topic}'." | |
| }) | |
| elif q_type == "interpret": | |
| questions.append({ | |
| "type": "semantic_interpret", | |
| "prompt": f"Interpret meaning: | |
| {passage}", | |
| "answer": "(model evaluated)", | |
| "explanation": f"Checks conceptual understanding of '{topic}'." | |
| }) | |
| ts = datetime.utcnow().strftime("%Y-%m-%dT%H-%M-%SZ") | |
| quiz_id = f"semantic_quiz_{ts}" | |
| return { | |
| "id": quiz_id, | |
| "created_at": ts, | |
| "topic": topic, | |
| "questions": questions, | |
| } | |