import DataSortModal from '@/components/data-sort-modal'; import QuestionTypeBadge from '@/components/exam/question-type-badge'; import DeleteModal from '@/components/inertia/delete-modal'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; import { router, usePage } from '@inertiajs/react'; import { ArrowRight, ArrowUpDown, CheckCircle2, Circle, CircleCheck, Copy, Edit, HelpCircle, Plus, Trash2 } from 'lucide-react'; import { Renderer } from 'richtor'; import 'richtor/styles'; import { ExamUpdateProps } from '../../update'; import QuestionDialog from '../question-dialog'; const Questions = () => { const { props } = usePage(); const { exam } = props; const { questions } = exam; const handleDuplicateQuestion = (questionId: number) => { router.post( route('exam-questions.duplicate', { question: questionId }), {}, { preserveScroll: true, }, ); }; if (questions.length === 0) { return (

No Questions Yet

Start building your exam by adding questions. You can create multiple choice, short answer, and many other question types.

Add First Question } />
); } return (

Exam Questions

{questions.length} {questions.length === 1 ? 'question' : 'questions'} • Total: {exam.total_marks} marks

Reorder } onOrderChange={(newOrder, setOpen) => { router.post( route('exam-questions.reorder'), { sortedData: newOrder, }, { preserveScroll: true, onSuccess: () => setOpen && setOpen(false), }, ); }} renderContent={(item) => (

{item.title}

)} /> Add Question } />
{questions.map((question, index) => (
Q{index + 1} {question.marks} marks
} /> } />

{question.title}

{/* Show options for multiple choice/select */} {(question.question_type === 'multiple_choice' || question.question_type === 'multiple_select') && question.question_options && question.question_options.length > 0 && (
{question.question_options.map((option) => (
{option.is_correct ? ( ) : ( )} {option.option_text}
))}
)} {/* Show matching pairs */} {question.question_type === 'matching' && question.options?.matches && question.options.matches.length > 0 && (

Matching Pairs:

{question.options.matches.map((match: any, idx: number) => (
{match.question} {match.answer}
))}
)} {/* Show fill blank answers */} {question.question_type === 'fill_blank' && question.options?.answers && question.options.answers.length > 0 && (

Accepted Answers:

{question.options.answers.map((answer: string, idx: number) => ( {answer} ))}
)} {/* Show ordering items */} {question.question_type === 'ordering' && question.options?.items && question.options.items.length > 0 && (

Correct Order:

    {question.options.items.map((item: string, idx: number) => (
  1. {item}
  2. ))}
)} {/* Show short answer sample */} {question.question_type === 'short_answer' && question.options?.sample_answer && (

Guidelines:

{question.options.sample_answer}

)} {/* Show listening info */} {question.question_type === 'listening' && (
{question.options?.audio_url && ( )} {question.options?.instructions && (

Instructions:

{question.options.instructions}

)}
)}
))}
); }; export default Questions;