import React, { useState } from 'react';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Loader2, Upload } from 'lucide-react';
const PDFQuizGenerator = () => {
const [pdfText, setPdfText] = useState('');
const [questions, setQuestions] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState('');
const [quizConfig, setQuizConfig] = useState({
numQuestions: 5,
includeMultipleChoice: true,
includeTrueFalse: true,
includeMatching: false,
difficulty: 'mixed'
});
const handleTextInput = (e) => {
setPdfText(e.target.value);
};
const generateQuestions = async () => {
if (!pdfText.trim()) {
setError('Bitte fügen Sie zuerst Text ein.');
return;
}
setIsLoading(true);
setError('');
try {
// Hier würde die Verbindung zur OpenAI API erfolgen
// Beispielfragen für Demo
const demoQuestions = [
{
type: 'multiple-choice',
question: 'Beispielfrage aus Ihrem Text?',
options: ['Option A', 'Option B', 'Option C', 'Option D'],
correctAnswer: 0
},
{
type: 'true-false',
question: 'Ist diese Aussage aus dem Text korrekt?',
correctAnswer: true
}
];
setQuestions(demoQuestions);
} catch (err) {
setError('Fehler bei der Fragengenerierung. Bitte versuchen Sie es erneut.');
} finally {
setIsLoading(false);
}
};
return (
PDF Quiz Generator
);
};
export default PDFQuizGenerator;
{/* Text Input */}
{/* Quiz Configuration */}
{/* Question Types */}
{/* Generate Button */}
{/* Error Message */}
{error && (
)}
))}
)}
{error}
)}
{/* Generated Questions */}
{questions.length > 0 && (
Generierte Fragen:
{questions.map((q, idx) => ({idx + 1}. {q.question}
{q.type === 'multiple-choice' && (
{q.options.map((option, optIdx) => (
))}
)}
{q.type === 'true-false' && (
Hinterlasse einen Kommentar