diff --git a/src/pages/content-management/HumanLanguagePage.tsx b/src/pages/content-management/HumanLanguagePage.tsx index 3419790..3b8da01 100644 --- a/src/pages/content-management/HumanLanguagePage.tsx +++ b/src/pages/content-management/HumanLanguagePage.tsx @@ -1042,6 +1042,9 @@ export function HumanLanguagePage() { }) toast.error("Could not load full lesson details") } + + // Preload questions so the lesson edit dialog can show the question bank immediately. + if (lesson.question_set_id > 0) void loadLessonQuestionsIfNeeded(lesson.question_set_id) } const handleSaveLesson = async () => { @@ -1845,11 +1848,9 @@ export function HumanLanguagePage() { const selectedLessonFetch = cardSel.lessonId !== null ? lessonDetailState[cardSel.lessonId] : undefined const selectedLessonDetail = - selectedLessonFetch?.status === "ok" ? selectedLessonFetch.data : null - const selectedLessonQuestionSetId = - selectedLessonDetail?.question_set_id ?? selectedLesson?.question_set_id ?? 0 - const lessonFetch = - selectedLessonQuestionSetId > 0 ? lessonQuestionsState[selectedLessonQuestionSetId] : undefined + selectedLessonFetch && selectedLessonFetch.status === "ok" + ? selectedLessonFetch.data + : null const selectedLessonIds = selectedLessonIdsBySubModule[smKey] ?? [] const selectedLessonRows = lessonRows.filter((row) => selectedLessonIds.includes(row.id)) const selectedPracticeMeta = @@ -2006,6 +2007,16 @@ export function HumanLanguagePage() {
- Question bank -
-- {selectedLessonDetail?.question_count ?? selectedLesson?.question_count ?? 0}{" "} - {Number( - selectedLessonDetail?.question_count ?? selectedLesson?.question_count ?? 0, - ) === 1 - ? "question" - : "questions"}{" "} - in this lesson -
-{lessonFetch.message}
- -No questions in this lesson yet.
-- Add them via Open editor. -
-- Prompt -
-- {q.question_text?.trim() || ( - No prompt text - )} -
-
-
-
{q.tips}
-- Assets -
-- Sample answer text -
-- {q.audio_correct_answer_text} -
-@@ -2980,6 +2756,168 @@ export function HumanLanguagePage() { ? renderMediaPreview(lessonForm.introVideoUrl, "video", "", "Intro video") : null} + + {lessonDialog.open && lessonDialog.questionSetId > 0 ? ( + (() => { + const lessonQuestionSetId = lessonDialog.questionSetId + const lessonId = lessonDialog.lessonId + const lessonFetch = lessonQuestionsState[lessonQuestionSetId] + const lessonDetailFetch = lessonDetailState[lessonId] + const questionCount = + lessonDetailFetch?.status === "ok" + ? lessonDetailFetch.data.question_count + : lessonFetch?.status === "ok" + ? lessonFetch.questions.length + : 0 + + return ( +
+ Question bank +
++ {questionCount} {questionCount === 1 ? "question" : "questions"} in this lesson +
+No questions in this lesson yet.
++ Add them via Open editor. +
++ Prompt +
++ {q.question_text?.trim() || ( + No prompt text + )} +
+
+