Update components/MathQuizApp.tsx
Browse files- components/MathQuizApp.tsx +56 -54
components/MathQuizApp.tsx
CHANGED
@@ -63,62 +63,64 @@ const MathQuizApp = () => {
|
|
63 |
};
|
64 |
|
65 |
return (
|
66 |
-
<div className="
|
67 |
-
<
|
68 |
-
|
69 |
-
<
|
70 |
-
<div className="flex
|
71 |
-
<div className="
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
</div>
|
74 |
-
<
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
</
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
}`}
|
110 |
-
>
|
111 |
-
{result}{' '}
|
112 |
-
{result === 'Correct!' ? (
|
113 |
-
<Check className="inline-block w-6 h-6" />
|
114 |
-
) : (
|
115 |
-
<X className="inline-block w-6 h-6" />
|
116 |
-
)}
|
117 |
-
</p>
|
118 |
-
)}
|
119 |
-
</form>
|
120 |
</div>
|
121 |
);
|
122 |
};
|
123 |
|
124 |
-
export default MathQuizApp;
|
|
|
63 |
};
|
64 |
|
65 |
return (
|
66 |
+
<div className="bg-gray-50 min-h-screen flex items-center justify-center">
|
67 |
+
<div className="max-w-3xl mx-auto p-8 bg-white rounded-lg shadow-md mt-4">
|
68 |
+
<h1 className="text-4xl font-bold mb-8 text-center">Math Quiz App</h1>
|
69 |
+
<form onSubmit={handleSubmit} className="space-y-6">
|
70 |
+
<div className="flex flex-col items-center gap-6">
|
71 |
+
<div className="flex gap-8 items-center justify-center">
|
72 |
+
<div className="text-xl font-bold">Correct: {score}</div>
|
73 |
+
<div className="text-xl font-bold text-red-500">Wrong: {wrongAnswers}</div>
|
74 |
+
</div>
|
75 |
+
<select
|
76 |
+
value={difficulty}
|
77 |
+
onChange={handleDifficultyChange}
|
78 |
+
className="bg-gray-50 border border-gray-300 text-gray-900 text-lg rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2.5 w-48 text-center"
|
79 |
+
>
|
80 |
+
{difficulties.map((difficulty) => (
|
81 |
+
<option key={difficulty} value={difficulty}>
|
82 |
+
{difficulty.charAt(0).toUpperCase() + difficulty.slice(1)}
|
83 |
+
</option>
|
84 |
+
))}
|
85 |
+
</select>
|
86 |
</div>
|
87 |
+
<div className="text-center mt-8">
|
88 |
+
<p className="text-3xl font-bold mb-6">
|
89 |
+
What is {question.num1} {question.operation} {question.num2}?
|
90 |
+
</p>
|
91 |
+
<input
|
92 |
+
type="number"
|
93 |
+
value={userAnswer}
|
94 |
+
onChange={(e) => setUserAnswer(e.target.value)}
|
95 |
+
className="bg-gray-50 border border-gray-300 text-gray-900 text-xl rounded-lg focus:ring-blue-500 focus:border-blue-500 p-4 w-64 text-center"
|
96 |
+
/>
|
97 |
+
</div>
|
98 |
+
<div className="text-center">
|
99 |
+
<button
|
100 |
+
type="submit"
|
101 |
+
className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-lg px-8 py-3 text-center"
|
102 |
+
>
|
103 |
+
Submit
|
104 |
+
</button>
|
105 |
+
</div>
|
106 |
+
{result && (
|
107 |
+
<p
|
108 |
+
className={`text-xl font-bold text-center ${
|
109 |
+
result === 'Correct!' ? 'text-green-500' : 'text-red-500'
|
110 |
+
}`}
|
111 |
+
>
|
112 |
+
{result}{' '}
|
113 |
+
{result === 'Correct!' ? (
|
114 |
+
<Check className="inline-block w-6 h-6" />
|
115 |
+
) : (
|
116 |
+
<X className="inline-block w-6 h-6" />
|
117 |
+
)}
|
118 |
+
</p>
|
119 |
+
)}
|
120 |
+
</form>
|
121 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
</div>
|
123 |
);
|
124 |
};
|
125 |
|
126 |
+
export default MathQuizApp;
|