11{% extends "base.html" %}
22
3+ {% block styles %}
4+ < style >
5+ .container {
6+ max-width : 1200px ;
7+ margin : 0 auto;
8+ padding : 2rem ;
9+ }
10+
11+ h1 {
12+ font-weight : 700 ;
13+ color : # 4f46e5 ;
14+ }
15+
16+ .videos-grid {
17+ display : grid;
18+ grid-template-columns : repeat (auto-fit, minmax (280px , 1fr ));
19+ gap : 1.5rem ;
20+ margin-top : 1rem ;
21+ }
22+
23+ .video-card {
24+ background : # fff ;
25+ border-radius : 1rem ;
26+ padding : 1.5rem ;
27+ box-shadow : 0 4px 12px rgba (0 , 0 , 0 , 0.1 );
28+ display : flex;
29+ flex-direction : column;
30+ justify-content : space-between;
31+ transition : box-shadow 0.3s ease;
32+ }
33+ .video-card : hover {
34+ box-shadow : 0 8px 24px rgba (79 , 70 , 229 , 0.2 );
35+ }
36+
37+ .video-title {
38+ font-size : 1.25rem ;
39+ font-weight : 700 ;
40+ color : # 4f46e5 ;
41+ margin-bottom : 0.75rem ;
42+ }
43+
44+ .btn-watch {
45+ background : linear-gradient (135deg , # 4f46e5, # 7c3aed );
46+ color : white;
47+ padding : 0.5rem 1rem ;
48+ border : none;
49+ border-radius : 0.5rem ;
50+ font-weight : 600 ;
51+ text-decoration : none;
52+ cursor : pointer;
53+ display : inline-block;
54+ margin-bottom : 1rem ;
55+ transition : background-color 0.3s ease;
56+ }
57+ .btn-watch : hover {
58+ background : linear-gradient (135deg , # 4338ca, # 6b21a8 );
59+ }
60+
61+ .rating-stars {
62+ display : inline-flex;
63+ gap : 2px ;
64+ font-size : 1.2rem ;
65+ margin-bottom : 0.5rem ;
66+ }
67+ .star {
68+ color : # fbbf24 ;
69+ }
70+ .star .empty {
71+ color : # e5e7eb ;
72+ }
73+
74+ .rating-info {
75+ color : # 64748b ;
76+ font-size : 0.9rem ;
77+ margin-bottom : 1rem ;
78+ }
79+
80+ form .rate-form {
81+ display : flex;
82+ gap : 0.5rem ;
83+ align-items : center;
84+ }
85+
86+ select .form-select-sm {
87+ padding : 0.3rem 0.5rem ;
88+ border-radius : 0.5rem ;
89+ border : 1px solid # d1d5db ;
90+ font-size : 0.9rem ;
91+ background : white;
92+ cursor : pointer;
93+ }
94+
95+ button .btn-rate {
96+ background-color : # 10b981 ;
97+ color : white;
98+ border : none;
99+ padding : 0.4rem 1rem ;
100+ border-radius : 0.5rem ;
101+ font-weight : 600 ;
102+ cursor : pointer;
103+ transition : background-color 0.3s ease;
104+ }
105+ button .btn-rate : hover {
106+ background-color : # 059669 ;
107+ }
108+
109+ @media (max-width : 600px ) {
110+ .videos-grid {
111+ grid-template-columns : 1fr ;
112+ }
113+ }
114+ </ style >
115+ {% endblock %}
116+
3117{% block content %}
4- < h1 > Welcome, {{ current_user.username }}!</ h1 >
5- < p > This is your student dashboard.</ p >
6- {% endblock %}
118+ < div class ="container mt-4 ">
119+
120+ < h1 class ="mb-3 "> Welcome, {{ current_user.username }}!</ h1 >
121+ < p class ="text-muted "> Your student dashboard — here are your motivational videos:</ p >
122+
123+ < hr class ="my-4 ">
124+ < h2 class ="h4 mb-3 "> Motivational Videos</ h2 >
125+
126+ {% if videos %}
127+ < div class ="videos-grid ">
128+ {% for video in videos %}
129+ < div class ="video-card ">
130+ < div >
131+ < h3 class ="video-title "> {{ video.video.title }}</ h3 >
132+
133+ {% if video.video.video_link %}
134+ < a href ="{{ video.video.video_link }} " target ="_blank " rel ="noopener noreferrer " class ="btn-watch "> ▶️ Watch</ a >
135+ {% else %}
136+ < span class ="rating-info "> Video link not available</ span >
137+ {% endif %}
138+
139+ < div > < strong > Your Rating:</ strong >
140+ {% if video.my_rating %}
141+ {% for i in range(1, 6) %}
142+ {% if i < = video.my_rating %}
143+ < span style ="color:#fbbf24; font-size:1.2rem; "> ★</ span >
144+ {% else %}
145+ < span style ="color:#e5e7eb; font-size:1.2rem; "> ★</ span >
146+ {% endif %}
147+ {% endfor %}
148+ {% else %}
149+ < span > Not rated yet</ span >
150+ {% endif %}
151+ </ div >
152+
153+ < div >
154+ < strong > Average Rating:</ strong >
155+ {% if video.average_rating %}
156+ {% set avg = video.average_rating %}
157+ < span class ="rating-stars " aria-label ="Average rating: {{ "%.1f "|format(avg) }} out of 5 stars">
158+ {% for i in range(1, 6) %}
159+ {% if i < = avg %}
160+ < span class ="star " aria-hidden ="true "> ★</ span >
161+ {% elif i - avg < 1 %}
162+ < span class ="star " aria-hidden ="true "> ★</ span >
163+ {% else %}
164+ < span class ="star empty " aria-hidden ="true "> ★</ span >
165+ {% endif %}
166+ {% endfor %}
167+ </ span >
168+ < span class ="rating-info "> ({{ "%.1f"|format(avg) }})</ span >
169+ {% else %}
170+ < span class ="rating-info "> No ratings yet</ span >
171+ {% endif %}
172+ </ div >
173+ </ div >
174+
175+ < form method ="POST " action ="{{ url_for('student.rate_video') }} " class ="rate-form mt-3 ">
176+ < input type ="hidden " name ="video_id " value ="{{ video.video.id }} ">
177+ < select name ="rating " class ="form-select-sm " required >
178+ < option value ="" disabled selected > Rate</ option >
179+ {% for num in range(1, 6) %}
180+ < option value ="{{ num }} "> {{ num }} ⭐</ option >
181+ {% endfor %}
182+ </ select >
183+ < button class ="btn-rate " type ="submit "> Rate</ button >
184+ </ form >
185+ </ div >
186+ {% endfor %}
187+ </ div >
188+ {% else %}
189+ < p class ="text-muted "> No videos have been uploaded yet.</ p >
190+ {% endif %}
191+
192+ </ div >
193+ {% endblock %}
0 commit comments