ロシアの歴史クイズ

import { useState } from ‘react’;
import { Card, CardContent, CardHeader, CardTitle } from ‘@/components/ui/card’;
import { Button } from ‘@/components/ui/button’;
import { CheckCircle, XCircle } from ‘lucide-react’;

const questions = [
{
question: “ロシア帝国初代皇帝は誰ですか?”,
options: [“アレクサンドル1世”, “ピョートル1世”, “イヴァン4世”],
correct: 1
},
{
question: “ナポレオンを打ち破ったロシア帝国の皇帝は?”,
options: [“エカテリーナ2世”, “アレクサンドル1世”, “ニコライ1世”],
correct: 1
},
{
question: “ロシア革命後のロシア臨時政府の初代最高指導者は誰?”,
options: [“レーニン”, “ドストエフスキー”, “ケレンスキー”],
correct: 2
},
{
question: “ソ連五か年計画の際にウクライナで起きた飢饉の名は?”,
options: [“ホロコースト”, “ホロドモール”, “ホロモドーロ”],
correct: 1
},
{
question: “ブレジネフのあとに最高指導者となったのは誰?”,
options: [“チェルネンコ”, “フルシチョフ”, “アンドロポフ”],
correct: 2
}
];

const QuizApp = () => {
const [currentQuestion, setCurrentQuestion] = useState(-1);
const [score, setScore] = useState(0);
const [showFeedback, setShowFeedback] = useState(false);
const [isCorrect, setIsCorrect] = useState(false);

const startQuiz = () => {
setCurrentQuestion(0);
setScore(0);
setShowFeedback(false);
};

const handleAnswer = (selectedIndex) => {
const correct = selectedIndex === questions[currentQuestion].correct;
setIsCorrect(correct);
setShowFeedback(true);
if (correct) setScore(score + 1);

setTimeout(() => {
setShowFeedback(false);
setCurrentQuestion(current => current + 1);
}, 1500);
};

const renderFeedback = () => (

{isCorrect ? (

) : (

)}{isCorrect ? “正解!” : “不正解”}

);

const renderResult = () => {
const percentage = (score / questions.length) * 100;
return (

クイズ終了!

正解率: {percentage}%
{questions.length}問中{score}問正解

);
};

const renderQuestion = () => {
const question = questions[currentQuestion];
return (

{currentQuestion + 1}. {question.question}

{question.options.map((option, index) => (

))}

);
};

const renderStart = () => (

);

return (

ロシア歴史クイズ

{currentQuestion === -1 && renderStart()}
{currentQuestion >= 0 && currentQuestion < questions.length && !showFeedback && renderQuestion()} {showFeedback && renderFeedback()} {currentQuestion >= questions.length && !showFeedback && renderResult()}

);
};

export default QuizApp;

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA