current affairs


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MCQ Test</title>
    <style>
        body { font-family: Arial, sans-serif; padding: 20px; }
        .question { margin-bottom: 15px; }
        .question h3 { margin: 0; }
        .options label { display: block; margin: 5px 0; }
        .btn { margin-top: 20px; padding: 10px 15px; background-color: #4CAF50; color: white; border: none; cursor: pointer; }
        .result { margin-top: 20px; font-size: 18px; }
    </style>
</head>
<body>
    <h1>MCQ Test</h1>
    <form id="quizForm">
        <div class="question">
            <h3>1. What is the main function of the heart?</h3>
            <div class="options">
                <label><input type="radio" name="q1" value="A"> Pump blood</label>
                <label><input type="radio" name="q1" value="B"> Filter toxins</label>
                <label><input type="radio" name="q1" value="C"> Store oxygen</label>
                <label><input type="radio" name="q1" value="D"> Produce energy</label>
            </div>
        </div>

        <div class="question">
            <h3>2. What is the average resting heart rate for an adult?</h3>
            <div class="options">
                <label><input type="radio" name="q2" value="A"> 30-50 bpm</label>
                <label><input type="radio" name="q2" value="B"> 60-100 bpm</label>
                <label><input type="radio" name="q2" value="C"> 120-150 bpm</label>
                <label><input type="radio" name="q2" value="D"> 150-200 bpm</label>
            </div>
        </div>

        <button type="button" class="btn" onclick="checkAnswers()">Submit</button>
    </form>

    <div class="result" id="result"></div>

    <script>
        function checkAnswers() {
            const answers = {
                q1: "A",
                q2: "B"
            };

            let score = 0;
            let total = Object.keys(answers).length;

            for (let question in answers) {
                const userAnswer = document.querySelector(`input[name="${question}"]:checked`);
                if (userAnswer && userAnswer.value === answers[question]) {
                    score++;
                }
            }

            document.getElementById("result").innerText = `You scored ${score} out of ${total}!`;
        }
    </script>
</body>
</html>

Comments