-
setCurrentPage('kids')}
- >
-
👦
-
Za Decu
-
Zabavno učenje za najmlađe
-
-
setCurrentPage('advanced')}
- >
-
🎓
-
Napredni
-
Lekcije za napredne učenike
-
-
setCurrentPage('skill-test')}
- >
-
📝
-
Test Znanja
-
Proveri svoje znanje
-
-
setCurrentPage('resources')}
- >
-
📖
-
Resursi
-
Materijali za učenje
-
+
+
🇩🇪 Dobrodošli na Blebetalo!
+
Platforma za učenje nemačkog jezika na srpskom
+
+ {cards.map(card => (
+
setCurrentPage(card.id)}>
+
{card.icon}
+
{card.title}
+
{card.desc}
+
+ ))}
);
diff --git a/src/pages/Login.js b/src/pages/Login.js
new file mode 100644
index 0000000..5f3cea4
--- /dev/null
+++ b/src/pages/Login.js
@@ -0,0 +1,194 @@
+import React, { useState } from 'react';
+import { useAuth } from '../context/AuthContext';
+
+function GoogleLoginModal({ onConfirm, onClose }) {
+ const [email, setEmail] = useState('');
+ const [name, setName] = useState('');
+
+ function handleSubmit(e) {
+ e.preventDefault();
+ if (!email.trim()) return;
+ onConfirm(email.trim(), name.trim());
+ }
+
+ return (
+
+
e.stopPropagation()}>
+
+
G
+
Prijavite se sa Google nalogom
+
Unesite vaš Google nalog
+
+
+
+
+ );
+}
+
+function Login({ onClose }) {
+ const { loginWithPassword, loginWithGoogle, register } = useAuth();
+ const [mode, setMode] = useState('login'); // 'login' | 'register'
+ const [showGoogleModal, setShowGoogleModal] = useState(false);
+
+ const [email, setEmail] = useState('');
+ const [password, setPassword] = useState('');
+ const [name, setName] = useState('');
+ const [error, setError] = useState('');
+ const [loading, setLoading] = useState(false);
+
+ function handleSubmit(e) {
+ e.preventDefault();
+ setError('');
+ setLoading(true);
+ if (mode === 'login') {
+ const result = loginWithPassword(email, password);
+ if (!result.success) setError(result.error);
+ else if (onClose) onClose();
+ } else {
+ if (!name.trim()) { setError('Unesite vaše ime.'); setLoading(false); return; }
+ const result = register(name, email, password);
+ if (!result.success) setError(result.error);
+ else if (onClose) onClose();
+ }
+ setLoading(false);
+ }
+
+ function handleGoogleLogin(googleEmail, googleName) {
+ loginWithGoogle(googleEmail, googleName);
+ setShowGoogleModal(false);
+ if (onClose) onClose();
+ }
+
+ return (
+ <>
+ {showGoogleModal && (
+
setShowGoogleModal(false)}
+ />
+ )}
+
+
+
+
🇩🇪
+
Blebetalo
+
Platforma za učenje nemačkog
+
+
+
+
+
+
+
+
+
+
+ ili
+
+
+
+
+ {onClose && (
+
+ )}
+
+ {mode === 'login' && (
+
+ Demo admin: admin@blebetalo.rs / admin123
+
+ )}
+
+
+ >
+ );
+}
+
+export default Login;
diff --git a/src/pages/SkillTest.js b/src/pages/SkillTest.js
index 1138697..5f7a2ad 100644
--- a/src/pages/SkillTest.js
+++ b/src/pages/SkillTest.js
@@ -1,45 +1,60 @@
import React, { useState } from 'react';
+import { loadTests } from './AdminPanel';
-const questions = [
+const DEFAULT_QUESTIONS = [
{
question: 'Kako se kaže "Hvala" na nemačkom?',
options: ['Bitte', 'Danke', 'Hallo', 'Tschüss'],
answer: 1,
+ imageUrl: '',
+ soundUrl: '',
},
{
question: 'Koji je tačan prevod reči "Haus"?',
options: ['Miš', 'Kuća', 'Ulica', 'Grad'],
answer: 1,
+ imageUrl: '',
+ soundUrl: '',
},
{
question: 'Kako se kaže "Dobar dan" na nemačkom?',
options: ['Guten Morgen', 'Gute Nacht', 'Guten Tag', 'Auf Wiedersehen'],
answer: 2,
+ imageUrl: '',
+ soundUrl: '',
},
{
question: 'Šta znači reč "Wasser"?',
options: ['Vatra', 'Zemlja', 'Vazduh', 'Voda'],
answer: 3,
+ imageUrl: '',
+ soundUrl: '',
},
];
-function SkillTest() {
+const DEFAULT_TEST = {
+ id: 'default',
+ title: 'Osnovni test',
+ description: 'Test osnovnog znanja nemačkog jezika',
+ questions: DEFAULT_QUESTIONS,
+};
+
+function TestRunner({ test, onBack }) {
+ const questions = test.questions;
const [currentQuestion, setCurrentQuestion] = useState(0);
const [selected, setSelected] = useState(null);
const [score, setScore] = useState(0);
const [finished, setFinished] = useState(false);
- const handleAnswer = (index) => {
- setSelected(index);
- };
+ const handleAnswer = (index) => setSelected(index);
const handleNext = () => {
- if (selected === questions[currentQuestion].answer) {
- setScore(score + 1);
- }
+ const q = questions[currentQuestion];
+ const correctIdx = q.answer !== undefined ? q.answer : q.correctAnswer;
+ if (selected === correctIdx) setScore(s => s + 1);
setSelected(null);
if (currentQuestion + 1 < questions.length) {
- setCurrentQuestion(currentQuestion + 1);
+ setCurrentQuestion(c => c + 1);
} else {
setFinished(true);
}
@@ -53,54 +68,108 @@ function SkillTest() {
};
if (finished) {
+ const pct = Math.round((score / questions.length) * 100);
return (
-
-
📝 Test završen!
-
Rezultat: {score} / {questions.length}
-
+
+
+ {pct >= 75 ? '🏆' : pct >= 50 ? '👍' : '📚'}
+
+
Test završen!
+
+ {score}
+ /
+ {questions.length}
+
+
{pct}% tačnih odgovora
+
+ {pct >= 75 ? 'Odličan rezultat! 🎉' : pct >= 50 ? 'Dobar rezultat, nastavi da vežbaš!' : 'Još malo vežbe i bićeš bolji!'}
+
+
+
+
+
);
}
const q = questions[currentQuestion];
+
return (
-
-
📝 Test Znanja
-
Pitanje {currentQuestion + 1} od {questions.length}
-
-
{q.question}
-
+
+
+
+
{test.title}
+ {currentQuestion + 1} / {questions.length}
+
+
+
+
+
+ {q.imageUrl && (
+
+

+
+ )}
+ {q.soundUrl && (
+
+ )}
+
{q.text || q.question}
+
{q.options.map((option, index) => (
-
+ option.trim() ? (
+
+ ) : null
))}
);
}
+function SkillTest() {
+ const [selectedTest, setSelectedTest] = useState(null);
+ const customTests = loadTests();
+ const allTests = customTests.length > 0 ? [DEFAULT_TEST, ...customTests] : [DEFAULT_TEST];
+
+ if (selectedTest) {
+ return
setSelectedTest(null)} />;
+ }
+
+ return (
+
+
📝 Test Znanja
+
Izaberite test koji želite da uradite
+
+ {allTests.map(test => (
+
setSelectedTest(test)}>
+
📝
+
{test.title}
+ {test.description &&
{test.description}
}
+
{test.questions.length} pitanja
+
+
+ ))}
+
+
+ );
+}
+
export default SkillTest;