File size: 6,492 Bytes
05dff9f
 
 
 
 
 
 
 
 
 
 
 
 
 
a88a491
05dff9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a88a491
05dff9f
 
 
 
 
 
 
 
 
 
a88a491
05dff9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a88a491
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
05dff9f
 
 
 
 
 
 
a88a491
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
05dff9f
a88a491
 
 
 
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
{% extends "base.html" %}

{% block content %}
<style>

    body {

        font-family: 'Open Sans', sans-serif;

        background: linear-gradient(to bottom, #a8dadc, #457b9d);

        color: #1d3557;

        margin: 0;

        padding: 0;

    }



    .header {

        background: #1d3557;

        color: white; /* Changed to white for better contrast */

        padding: 20px;

        text-align: center;

        border-bottom: 5px solid #457b9d;

        border-radius: 0 0 20px 20px;

        box-shadow: 0 4px 10px rgba(0,0,0,0.2);

    }



    .header h1 {

        margin: 0;

        font-size: 28px;

        letter-spacing: 1px;

    }



    .header a {

        color: #f1faee;

        text-decoration: none;

        font-size: 16px;

        background: #457b9d;

        padding: 6px 12px;

        border-radius: 12px;

        transition: background 0.3s;

    }



    .header a:hover {

        background: #1d3557;

    }



    .quiz-form, .quiz-results {

        background: rgba(255, 255, 255, 0.9);

        margin: 40px auto;

        padding: 30px;

        width: 80%;

        max-width: 700px;

        border-radius: 20px;

        box-shadow: 0 6px 15px rgba(0,0,0,0.2);

        border: 2px solid #457b9d;

    }



    .quiz-form h3, .quiz-results h3 {

        font-size: 20px;

        color: #1d3557;

        margin-bottom: 10px;

    }



    .quiz-form label {

        display: block;

        background: #e0f7fa;

        padding: 10px 15px;

        border-radius: 10px;

        margin-bottom: 8px;

        border: 1px solid #b2ebf2;

        cursor: pointer;

        transition: all 0.3s ease;

    }



    .quiz-form label:hover {

        background: #b2ebf2;

        transform: translateY(-2px);

    }



    .quiz-form input[type="radio"] {

        margin-right: 10px;

    }



    button[type="submit"] {

        background: linear-gradient(90deg, #219ebc, #023047);

        color: #f1faee;

        border: none;

        padding: 12px 25px;

        border-radius: 20px;

        font-size: 18px;

        font-weight: bold;

        cursor: pointer;

        margin-top: 20px;

        display: block;

        width: 100%;

        transition: transform 0.2s, background 0.3s;

    }



    button[type="submit"]:hover {

        transform: scale(1.05);

        background: linear-gradient(90deg, #48cae4, #023047);

    }



    /* Styles for quiz results */

    .quiz-results h2 {

        font-family: 'Montserrat', sans-serif;

        color: #1d3557;

        margin-bottom: 25px;

        font-size: 2.2em;

    }

    .quiz-results p.score {

        font-size: 1.5em;

        font-weight: bold;

        color: #023047;

        margin-bottom: 30px;

    }

    .quiz-question-feedback {

        margin-bottom: 30px;

        padding: 20px;

        border-radius: 15px;

        border: 1px solid #ddd;

        text-align: left;

    }

    .quiz-question-feedback.correct {

        background-color: #e6ffed; /* Light green */

        border-color: #28a745; /* Green */

    }

    .quiz-question-feedback.incorrect {

        background-color: #ffe6e6; /* Light red */

        border-color: #dc3545; /* Red */

    }

    .quiz-question-feedback h4 {

        margin-top: 0;

        color: #1d3557;

        font-size: 1.3em;

    }

    .quiz-question-feedback .user-answer, .quiz-question-feedback .correct-answer {

        font-size: 1.1em;

        margin-bottom: 8px;

    }

    .quiz-question-feedback .user-answer span, .quiz-question-feedback .correct-answer span {

        font-weight: bold;

    }

    .quiz-question-feedback .user-answer.correct-choice {

        color: #28a745;

    }

    .quiz-question-feedback .user-answer.incorrect-choice {

        color: #dc3545;

    }

    .quiz-question-feedback .correct-answer-text {

        color: #28a745;

    }

    .quiz-question-feedback .reason {

        font-style: italic;

        color: #555;

        margin-top: 15px;

        padding-top: 10px;

        border-top: 1px dashed #ccc;

    }

    .quiz-results .back-to-dashboard {

        display: inline-block;

        margin-top: 30px;

        background: #007bff;

        color: white;

        padding: 12px 25px;

        border-radius: 20px;

        text-decoration: none;

        font-weight: bold;

        transition: background 0.3s;

    }

    .quiz-results .back-to-dashboard:hover {

        background: #0056b3;

    }

</style>

<div class="header">
    <h1>Quiz for: {{ video.title }}</h1>
    <a href="{{ url_for('dashboard') }}">Back to Dashboard</a>
</div>

{% if quiz_submitted %}
    <div class="quiz-results">
        <h2>Quiz Results</h2>
        <p class="score">Your Score: {{ user_score }} / {{ total_quiz_points }} points</p>

        {% for feedback in quiz_feedback %}
            <div class="quiz-question-feedback {% if feedback.is_correct %}correct{% else %}incorrect{% endif %}">
                <h4>{{ loop.index }}. {{ feedback.question }}</h4>
                <p class="user-answer {% if feedback.is_correct %}correct-choice{% else %}incorrect-choice{% endif %}">
                    Your Answer: <span>{{ feedback.user_selected_option }}</span>
                    {% if feedback.is_correct %} (Correct! πŸŽ‰){% else %} (Incorrect πŸ˜”){% endif %}
                </p>
                {% if not feedback.is_correct %}
                    <p class="correct-answer">
                        Correct Answer: <span class="correct-answer-text">{{ feedback.correct_option }}</span>
                    </p>
                {% endif %}
                <p class="reason">
                    <strong>Reason:</strong> {{ feedback.reason }}
                </p>
            </div>
        {% endfor %}

        <a href="{{ url_for('dashboard') }}" class="back-to-dashboard">Return to Dashboard</a>
    </div>
{% else %}
    <form method="POST" class="quiz-form">
        {% for i, question_data in enumerate(quiz_questions) %}
            <h3>{{ i+1 }}. {{ question_data.question }}</h3>
            {% for j, option in enumerate(question_data.options) %}
                <label>
                    <input type="radio" name="question_{{ i }}" value="{{ j }}" required>
                    {{ option }}
                </label>
            {% endfor %}
            <br>
        {% endfor %}
        <button type="submit">Submit Quiz</button>
    </form>
{% endif %}
{% endblock %}