Add operator note controls for admin visibility and AI prompt inclusion

This commit is contained in:
dwindown
2026-04-28 19:42:16 +07:00
parent 86ddeb442a
commit 1326f0a25b
2 changed files with 61 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ def get_prompt_template(
basis_correct: str,
basis_explanation: Optional[str],
target_level: Literal["mudah", "sulit"],
operator_notes: Optional[str] = None,
) -> str:
"""
Generate standardized prompt for AI question generation.
@@ -75,6 +76,15 @@ def get_prompt_template(
else "Explanation: (not provided)"
)
notes_block = ""
if operator_notes and operator_notes.strip():
notes_block = f"""
ADDITIONAL OPERATOR NOTES:
{operator_notes.strip()}
Apply these notes as style constraints as long as they do not conflict with correctness.
"""
prompt = f"""You are an educational content creator specializing in creating assessment questions.
Given a "Sedang" (medium difficulty) question, generate a new question at a different difficulty level.
@@ -88,6 +98,7 @@ Correct Answer: {basis_correct}
TASK:
Generate 1 new question that is {level_desc} than the basis question above.
{notes_block}
REQUIREMENTS:
1. Keep the SAME topic/subject matter as the basis question
@@ -380,6 +391,7 @@ async def generate_question(
basis_item: Item,
target_level: Literal["mudah", "sulit"],
ai_model: str = settings.OPENROUTER_MODEL_QWEN,
operator_notes: Optional[str] = None,
) -> Optional[GeneratedQuestion]:
"""
Generate a new question based on a basis item.
@@ -399,6 +411,7 @@ async def generate_question(
basis_correct=basis_item.correct_answer,
basis_explanation=basis_item.explanation,
target_level=target_level,
operator_notes=operator_notes,
)
max_generation_attempts = 2
@@ -679,6 +692,7 @@ async def generate_questions_batch(
target_level: Literal["mudah", "sulit"],
ai_model: str,
count: int,
operator_notes: Optional[str] = None,
) -> list[GeneratedQuestion]:
generated_items: list[GeneratedQuestion] = []
for _ in range(count):
@@ -686,6 +700,7 @@ async def generate_questions_batch(
basis_item=basis_item,
target_level=target_level,
ai_model=ai_model,
operator_notes=operator_notes,
)
if generated is not None:
generated_items.append(generated)