Untitled
unknown
plain_text
a year ago
6.0 kB
7
Indexable
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pharmacology Practice Quiz</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f4f4f9;
color: #333;
}
.quiz-container {
max-width: 600px;
margin: 0 auto;
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.question {
font-size: 18px;
margin-bottom: 15px;
}
.options button {
display: block;
margin: 10px 0;
padding: 10px;
width: 100%;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.options button:hover {
background-color: #0056b3;
}
.feedback {
margin-top: 15px;
padding: 10px;
border-radius: 5px;
font-weight: bold;
}
.correct {
background-color: #d4edda;
color: #155724;
}
.incorrect {
background-color: #f8d7da;
color: #721c24;
}
.next-button {
margin-top: 20px;
display: block;
background-color: #28a745;
color: white;
border: none;
padding: 10px 20px;
text-align: center;
text-decoration: none;
border-radius: 5px;
cursor: pointer;
}
.next-button:hover {
background-color: #218838;
}
</style>
</head>
<body>
<div class="quiz-container">
<div id="quiz">
<p class="question" id="question"></p>
<div class="options" id="options"></div>
<div id="feedback" class="feedback"></div>
<button id="next" class="next-button" style="display: none;">Next Question</button>
</div>
<div id="results" style="display: none;">
<h2>Quiz Completed!</h2>
<p>Your Score: <span id="score"></span></p>
</div>
</div>
<script>
// Question Data
const quizData = [
{
question: "What is the duration of insulin glargine?",
options: ["15 minutes", "2 to 4 hours", "6 to 14 hours", "18 to 24 hours"],
correct: 3,
rationale: "Insulin glargine has a long-acting duration of 18 to 24 hours, providing basal insulin coverage."
},
{
question: "What should a client on spironolactone avoid?",
options: ["Salt substitutes", "Dairy products", "Leafy greens", "Alcohol"],
correct: 0,
rationale: "Spironolactone is a potassium-sparing diuretic, and salt substitutes can increase potassium levels dangerously."
},
{
question: "How should levothyroxine be taken?",
options: ["With an antacid", "At bedtime", "30 to 60 minutes before breakfast", "When feeling fatigued"],
correct: 2,
rationale: "Levothyroxine is best absorbed when taken on an empty stomach, 30 to 60 minutes before breakfast."
}
];
let currentQuestion = 0;
let score = 0;
// Load a question
function loadQuestion() {
const questionElement = document.getElementById('question');
const optionsElement = document.getElementById('options');
const feedbackElement = document.getElementById('feedback');
const nextButton = document.getElementById('next');
feedbackElement.style.display = "none";
nextButton.style.display = "none";
const questionData = quizData[currentQuestion];
questionElement.textContent = questionData.question;
optionsElement.innerHTML = "";
questionData.options.forEach((option, index) => {
const button = document.createElement("button");
button.textContent = option;
button.onclick = () => checkAnswer(index);
optionsElement.appendChild(button);
});
}
// Check the answer
function checkAnswer(selected) {
const feedbackElement = document.getElementById('feedback');
const nextButton = document.getElementById('next');
const questionData = quizData[currentQuestion];
if (selected === questionData.correct) {
feedbackElement.textContent = "Correct! " + questionData.rationale;
feedbackElement.className = "feedback correct";
score++;
} else {
feedbackElement.textContent = "Incorrect. " + questionData.rationale;
feedbackElement.className = "feedback incorrect";
}
feedbackElement.style.display = "block";
nextButton.style.display = "block";
}
document.getElementById('next').onclick = () => {
currentQuestion++;
if (currentQuestion < quizData.length) {
loadQuestion();
} else {
showResults();
}
};
// Show results
function showResults() {
document.getElementById('quiz').style.display = "none";
const resultsElement = document.getElementById('results');
resultsElement.style.display = "block";
document.getElementById('score').textContent = `${score} out of ${quizData.length}`;
}
// Initialize quiz
loadQuestion();
</script>
</body>
</html>
Editor is loading...
Leave a Comment