AI_Toolkit / src /core /QuizEngine.py
NavyDevilDoc's picture
Create QuizEngine.py
9cba4cb verified
raw
history blame
1.77 kB
import random
from core.AcronymManager import AcronymManager
class QuizEngine:
def __init__(self):
# reuse the existing manager to load the JSON
self.acronym_mgr = AcronymManager()
def get_random_acronym(self):
"""
Fetches a random acronym-definition pair.
Returns: dict or None (if empty)
"""
if not self.acronym_mgr.acronyms:
return None
# Pick a random key
acronym = random.choice(list(self.acronym_mgr.acronyms.keys()))
definition = self.acronym_mgr.acronyms[acronym]
return {
"type": "acronym",
"term": acronym,
"correct_definition": definition,
"question": f"What does **{acronym}** stand for?"
}
def construct_grading_prompt(self, term, correct_definition, user_answer):
"""
Builds the prompt for the Board Examiner persona.
We return the string here so app.py can send it to whichever LLM is active.
"""
return (
f"You are a strict US Navy Engineering Duty Officer Board Examiner.\n"
f"I am a candidate. You asked me to define the acronym: {term}\n\n"
f"The Official Definition is: {correct_definition}\n"
f"My Answer was: {user_answer}\n\n"
f"INSTRUCTIONS:\n"
f"1. Grade my answer as PASS (Correct expansion) or FAIL (Incorrect expansion).\n"
f"2. If I got the words right but missed the full context, give me a 'PASS with Comments'.\n"
f"3. Keep your feedback short and military-professional.\n\n"
f"OUTPUT FORMAT:\n"
f"**GRADE:** [PASS/FAIL]\n"
f"**CRITIQUE:** [Your brief feedback]"
)