File size: 10,458 Bytes
775ba42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<!DOCTYPE html>
<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>