fix: resolve all QA/UAT report issues (P0-P3)
Made-with: Cursor
This commit is contained in:
@@ -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("");
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user