Spaces:
Sleeping
Sleeping
<html> | |
<head> | |
<title>MCQ Generator</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<style> | |
:root { | |
--primary: #4a6fa5; | |
--secondary: #6a98d8; | |
--accent: #ff6b6b; | |
--light: #f8f9fa; | |
--dark: #343a40; | |
--success: #28a745; | |
--danger: #dc3545; | |
} | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
transition: all 0.3s ease; | |
} | |
body { | |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
line-height: 1.6; | |
color: var(--dark); | |
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); | |
min-height: 100vh; | |
padding: 0; | |
} | |
.container { | |
max-width: 800px; | |
margin: 0 auto; | |
padding: 20px; | |
} | |
header { | |
background-color: var(--primary); | |
color: white; | |
padding: 20px 0; | |
border-radius: 0 0 10px 10px; | |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); | |
text-align: center; | |
margin-bottom: 30px; | |
} | |
header h1 { | |
margin: 0; | |
font-size: 2.5rem; | |
font-weight: 700; | |
} | |
header p { | |
margin-top: 10px; | |
font-size: 1.2rem; | |
opacity: 0.9; | |
} | |
.card { | |
background: white; | |
border-radius: 12px; | |
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1); | |
padding: 30px; | |
margin-bottom: 30px; | |
position: relative; | |
overflow: hidden; | |
} | |
.card::before { | |
content: ''; | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 5px; | |
background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent)); | |
} | |
.form-group { | |
margin-bottom: 20px; | |
} | |
label { | |
display: block; | |
margin-bottom: 8px; | |
font-weight: 600; | |
color: var(--dark); | |
} | |
input, | |
select { | |
width: 100%; | |
padding: 12px 15px; | |
border: 2px solid #dee2e6; | |
border-radius: 8px; | |
font-size: 16px; | |
color: var(--dark); | |
} | |
input:focus, | |
select:focus { | |
border-color: var(--secondary); | |
box-shadow: 0 0 0 3px rgba(106, 152, 216, 0.25); | |
outline: none; | |
} | |
.btn { | |
display: inline-block; | |
font-weight: 600; | |
text-align: center; | |
white-space: nowrap; | |
vertical-align: middle; | |
user-select: none; | |
border: none; | |
padding: 12px 24px; | |
font-size: 16px; | |
line-height: 1.5; | |
border-radius: 8px; | |
cursor: pointer; | |
transition: all 0.3s ease; | |
} | |
.btn-primary { | |
color: white; | |
background: linear-gradient(45deg, var(--primary), var(--secondary)); | |
box-shadow: 0 4px 6px rgba(74, 111, 165, 0.2); | |
} | |
.btn-primary:hover { | |
transform: translateY(-2px); | |
box-shadow: 0 6px 8px rgba(74, 111, 165, 0.3); | |
} | |
.btn-block { | |
display: block; | |
width: 100%; | |
} | |
.question { | |
background: white; | |
border-radius: 12px; | |
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1); | |
padding: 25px; | |
margin-top: 30px; | |
position: relative; | |
border-left: 5px solid var(--primary); | |
} | |
.question strong { | |
color: var(--primary); | |
font-size: 1.2rem; | |
margin-bottom: 15px; | |
display: block; | |
} | |
.question ul { | |
list-style-type: none; | |
padding: 0; | |
margin: 20px 0; | |
} | |
.question li { | |
padding: 10px 15px; | |
border: 1px solid #dee2e6; | |
border-radius: 8px; | |
margin-bottom: 10px; | |
transition: all 0.2s ease; | |
cursor: pointer; | |
} | |
.question li:hover { | |
background-color: #f8f9fa; | |
transform: translateX(5px); | |
} | |
.correct-answer { | |
margin-top: 20px; | |
padding: 15px; | |
background-color: rgba(40, 167, 69, 0.1); | |
border-left: 3px solid var(--success); | |
border-radius: 8px; | |
display: none; | |
} | |
.correct-answer strong { | |
color: var(--success); | |
font-size: 1.1rem; | |
margin-bottom: 5px; | |
display: block; | |
} | |
.action-buttons { | |
margin-top: 15px; | |
display: none; | |
} | |
.btn-retry { | |
background-color: var(--primary); | |
color: white; | |
margin-right: 10px; | |
} | |
.btn-show-answer { | |
background-color: var(--secondary); | |
color: white; | |
} | |
footer { | |
text-align: center; | |
padding: 20px; | |
margin-top: 30px; | |
color: var(--dark); | |
font-size: 0.9rem; | |
} | |
/* Responsive design */ | |
@media (max-width: 768px) { | |
.container { | |
padding: 10px; | |
} | |
header h1 { | |
font-size: 2rem; | |
} | |
.card { | |
padding: 20px; | |
} | |
.btn { | |
padding: 10px 20px; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<header> | |
<h1>MCQ Generator</h1> | |
<p>Create custom multiple-choice questions </p> | |
</header> | |
<div class="card"> | |
<form method="get" action="/generate_mcq"> | |
<div class="form-group"> | |
<label for="topic">Topic:</label> | |
<input type="text" id="topic" name="topic" placeholder="Enter a subject or topic" required> | |
</div> | |
<div class="form-group"> | |
<label for="solo_level">SOLO Level:</label> | |
<select id="solo_level" name="solo_level" required> | |
<option value="" disabled selected>Select a level</option> | |
<option value="unistructural">Unistructural (Basic facts)</option> | |
<option value="multistructural">Multistructural (Multiple concepts)</option> | |
</select> | |
</div> | |
<button type="submit" class="btn btn-primary btn-block">Generate Question</button> | |
</form> | |
</div> | |
{% if mcq %} | |
<div class="question"> | |
<strong>Question:</strong> {{ mcq.question_text }} | |
<ul id="options-list"> | |
{% for option in mcq.options %} | |
<li data-correct="{{ 'true' if option == mcq.correct_answer else 'false' }}" | |
onclick="checkAnswer(this)">{{ option }}</li> | |
{% endfor %} | |
</ul> | |
<div class="action-buttons" id="action-buttons"> | |
<button class="btn btn-retry" onclick="resetQuiz()">Try Again</button> | |
<button class="btn btn-show-answer" onclick="showAnswer()">Show Answer</button> | |
</div> | |
<div class="correct-answer" id="feedback"> | |
<strong>✅ Correct Answer:</strong> {{ mcq.correct_answer }} | |
</div> | |
</div> | |
{% endif %} | |
<footer> | |
<p>MCQ Generator</p> | |
</footer> | |
</div> | |
<script> | |
// Add some simple interactivity | |
document.addEventListener('DOMContentLoaded', function () { | |
// Highlight form fields on focus | |
const formElements = document.querySelectorAll('input, select'); | |
formElements.forEach(element => { | |
element.addEventListener('focus', function () { | |
this.style.transform = 'translateY(-2px)'; | |
}); | |
element.addEventListener('blur', function () { | |
this.style.transform = 'translateY(0)'; | |
}); | |
}); | |
}); | |
// MCQ interaction functions | |
function checkAnswer(selectedLi) { | |
const isCorrect = selectedLi.dataset.correct === 'true'; | |
const options = document.querySelectorAll('#options-list li'); | |
// Disable all options | |
options.forEach(opt => { | |
opt.onclick = null; | |
opt.style.cursor = 'default'; | |
}); | |
if (isCorrect) { | |
selectedLi.style.backgroundColor = 'rgba(40, 167, 69, 0.1)'; | |
selectedLi.style.borderColor = 'var(--success)'; | |
document.getElementById('feedback').style.display = 'block'; | |
} else { | |
selectedLi.style.backgroundColor = 'rgba(220, 53, 69, 0.1)'; | |
selectedLi.style.borderColor = 'var(--danger)'; | |
document.getElementById('action-buttons').style.display = 'block'; | |
} | |
} | |
function resetQuiz() { | |
const options = document.querySelectorAll('#options-list li'); | |
options.forEach(opt => { | |
opt.style.backgroundColor = ''; | |
opt.style.borderColor = '#dee2e6'; | |
opt.onclick = function () { checkAnswer(this); }; | |
opt.style.cursor = 'pointer'; | |
}); | |
document.getElementById('action-buttons').style.display = 'none'; | |
document.getElementById('feedback').style.display = 'none'; | |
} | |
function showAnswer() { | |
const options = document.querySelectorAll('#options-list li'); | |
options.forEach(opt => { | |
if (opt.dataset.correct === 'true') { | |
opt.style.backgroundColor = 'rgba(40, 167, 69, 0.1)'; | |
opt.style.borderColor = 'var(--success)'; | |
} | |
}); | |
document.getElementById('feedback').style.display = 'block'; | |
document.getElementById('action-buttons').style.display = 'none'; | |
} | |
</script> | |
</body> | |
</html> |