diff --git a/src/pages/content-management/AddNewLessonPage.tsx b/src/pages/content-management/AddNewLessonPage.tsx index 8da79af..597165f 100644 --- a/src/pages/content-management/AddNewLessonPage.tsx +++ b/src/pages/content-management/AddNewLessonPage.tsx @@ -2,7 +2,7 @@ import { useMemo, useRef, useState, type ChangeEvent } from "react" import { ArrowLeft, ArrowRight, Check, GripVertical, Loader2, Plus, Rocket, Trash2, Upload } from "lucide-react" import { Link, useLocation, useNavigate, useParams } from "react-router-dom" import { toast } from "sonner" -import { createLesson, createQuestion, addQuestionToSet } from "../../api/courses.api" +import { addQuestionToSet, createLesson, createQuestion } from "../../api/courses.api" import { uploadVideoFile } from "../../api/files.api" import { PracticeQuestionEditorFields } from "../../components/content-management/PracticeQuestionEditorFields" import { Button } from "../../components/ui/button" @@ -10,17 +10,11 @@ import { Card } from "../../components/ui/card" import { Input } from "../../components/ui/input" import type { QuestionOption } from "../../types/course.types" -type Step = 1 | 2 | 3 | 4 | 5 +type Step = 1 | 2 | 3 | 4 type QuestionType = "MCQ" | "TRUE_FALSE" | "SHORT" | "AUDIO" type DifficultyLevel = "EASY" | "MEDIUM" | "HARD" type ResultStatus = "success" | "error" -interface Persona { - id: string - name: string - avatar: string -} - interface MCQOption { text: string isCorrect: boolean @@ -42,18 +36,10 @@ interface Question { imageUrl: string } -const PERSONAS: Persona[] = [ - { id: "1", name: "Dawit", avatar: "https://api.dicebear.com/7.x/avataaars/svg?seed=Dawit" }, - { id: "2", name: "Mahlet", avatar: "https://api.dicebear.com/7.x/avataaars/svg?seed=Mahlet" }, - { id: "3", name: "Amanuel", avatar: "https://api.dicebear.com/7.x/avataaars/svg?seed=Amanuel" }, - { id: "4", name: "Bethel", avatar: "https://api.dicebear.com/7.x/avataaars/svg?seed=Bethel" }, -] - const STEPS = [ { number: 1, label: "Context" }, - { number: 2, label: "Persona" }, - { number: 3, label: "Questions" }, - { number: 4, label: "Review" }, + { number: 2, label: "Questions" }, + { number: 3, label: "Review" }, ] function createEmptyQuestion(id: string): Question { @@ -136,13 +122,9 @@ export function AddNewLessonPage() { const [introVideoUrl, setIntroVideoUrl] = useState("") const [uploadingIntroVideo, setUploadingIntroVideo] = useState(false) const [importingIntroVideoUrl, setImportingIntroVideoUrl] = useState(false) - const [shuffleQuestions, setShuffleQuestions] = useState(false) - const [passingScore, setPassingScore] = useState(50) - const [timeLimitMinutes, setTimeLimitMinutes] = useState(60) - const [selectedPersona, setSelectedPersona] = useState(null) const [questions, setQuestions] = useState([createEmptyQuestion("1")]) - const handleNext = () => setCurrentStep((s) => (s < 4 ? ((s + 1) as Step) : s)) + const handleNext = () => setCurrentStep((s) => (s < 3 ? ((s + 1) as Step) : s)) const handleBack = () => setCurrentStep((s) => (s > 1 ? ((s - 1) as Step) : s)) const handleIntroVideoFileChange = async (event: ChangeEvent) => { @@ -171,8 +153,6 @@ export function AddNewLessonPage() { const source = introVideoUrl.trim() if (!source || !/^https?:\/\//i.test(source)) return const vimeoEmbed = toVimeoEmbedUrl(source) - // Vimeo page URLs can be protected by anti-bot checks when server-side fetched. - // For those links, prefer local normalization to player URL instead of failing import. if (vimeoEmbed) { setIntroVideoUrl(vimeoEmbed) return @@ -217,17 +197,12 @@ export function AddNewLessonPage() { } setSaving(true) try { - const persona = PERSONAS.find((p) => p.id === selectedPersona)?.name const lessonRes = await createLesson({ sub_module_id: Number(subModuleId), title: lessonTitle.trim() || "Untitled Lesson", description: lessonDescription.trim() || undefined, intro_video_url: introVideoUrl.trim() || undefined, - persona, status, - passing_score: passingScore, - time_limit_minutes: timeLimitMinutes, - shuffle_questions: shuffleQuestions, }) const questionSetId = lessonRes.data?.data?.id @@ -268,12 +243,12 @@ export function AddNewLessonPage() { setResultStatus("success") setResultMessage(status === "PUBLISHED" ? "Lesson published successfully." : "Lesson saved as draft.") - setCurrentStep(5) + setCurrentStep(4) } catch (error) { console.error("Failed to save lesson:", error) setResultStatus("error") setResultMessage(error instanceof Error ? error.message : "Failed to save lesson") - setCurrentStep(5) + setCurrentStep(4) } finally { setSaving(false) } @@ -282,7 +257,7 @@ export function AddNewLessonPage() { return (
- {currentStep !== 5 ? ( + {currentStep !== 4 ? ( <>

Add New Lesson

- Create a lesson using the same guided flow and save it under `sub_module_lessons`. + Create a lesson backed by `question_sets` and attach it through `sub_module_lessons`.

@@ -324,160 +299,99 @@ export function AddNewLessonPage() { {currentStep === 1 ? (

Step 1: Context

-
-
-
- - setLessonTitle(e.target.value)} placeholder="Enter lesson title" /> -
-
- -