1+ {% extends "base.html" %}
2+ {% block title %}{{ assignment.title }} - {{ course.title }}{% endblock title %}
3+ {% block content %}
4+ < div class ="container mx-auto px-4 py-8 ">
5+ < nav class ="text-sm mb-4 ">
6+ < a href ="{% url 'course_detail' course.slug %} " class ="text-blue-600 hover:text-blue-800 dark:text-blue-400 "> {{ course.title }}</ a >
7+ < span class ="mx-2 text-gray-400 "> /</ span >
8+ < a href ="{% url 'course_assignments' course.slug %} " class ="text-blue-600 hover:text-blue-800 dark:text-blue-400 "> Assignments</ a >
9+ < span class ="mx-2 text-gray-400 "> /</ span >
10+ < span class ="text-gray-600 dark:text-gray-400 "> {{ assignment.title }}</ span >
11+ </ nav >
12+ < div class ="grid grid-cols-1 lg:grid-cols-3 gap-8 ">
13+ < div class ="lg:col-span-2 space-y-6 ">
14+ < div class ="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 ">
15+ < div class ="flex items-start justify-between mb-4 ">
16+ < h1 class ="text-2xl font-bold text-gray-900 dark:text-white "> {{ assignment.title }}</ h1 >
17+ {% if is_teacher %}
18+ < div class ="flex space-x-2 ">
19+ < a href ="{% url 'edit_assignment' course.slug assignment.id %} " class ="text-teal-600 hover:text-teal-800 dark:text-teal-400 text-sm font-medium "> Edit</ a >
20+ < a href ="{% url 'delete_assignment' course.slug assignment.id %} " class ="text-red-500 hover:text-red-700 dark:text-red-400 text-sm font-medium "> Delete</ a >
21+ </ div >
22+ {% endif %}
23+ </ div >
24+ < div class ="prose dark:prose-invert max-w-none text-gray-700 dark:text-gray-300 text-sm mb-4 ">
25+ {{ assignment.description|linebreaks }}
26+ </ div >
27+ < div class ="flex flex-wrap gap-4 text-sm text-gray-500 dark:text-gray-400 border-t border-gray-200 dark:border-gray-700 pt-4 ">
28+ < span > < i class ="fas fa-star mr-1 " aria-hidden ="true "> </ i > Max Score: {{ assignment.max_score }}</ span >
29+ {% if assignment.due_date %}
30+ < span class ="{% if assignment.is_past_due %}text-red-500 dark:text-red-400{% endif %} ">
31+ < i class ="fas fa-calendar mr-1 " aria-hidden ="true "> </ i > Due: {{ assignment.due_date|date:"M d, Y H:i" }}
32+ {% if assignment.is_past_due %} (Past Due){% endif %}
33+ </ span >
34+ {% endif %}
35+ {% if assignment.allow_late_submissions %}
36+ < span class ="text-green-600 dark:text-green-400 "> < i class ="fas fa-check mr-1 " aria-hidden ="true "> </ i > Late submissions allowed</ span >
37+ {% endif %}
38+ </ div >
39+ </ div >
40+ {% if not is_teacher %}
41+ < div class ="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 ">
42+ < h2 class ="text-xl font-semibold text-gray-800 dark:text-white mb-4 ">
43+ {% if submission %}Your Submission{% else %}Submit Your Work{% endif %}
44+ </ h2 >
45+ {% if submission %}
46+ < div class ="space-y-3 ">
47+ < div class ="flex items-center space-x-2 ">
48+ < span class ="px-2 py-1 text-xs rounded-full {% if submission.status == 'graded' %}bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300{% else %}bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300{% endif %} ">
49+ {{ submission.get_status_display }}
50+ </ span >
51+ < span class ="text-sm text-gray-500 dark:text-gray-400 "> Submitted {{ submission.submitted_at|date:"M d, Y H:i" }}</ span >
52+ </ div >
53+ {% if submission.text_response %}
54+ < div class ="bg-gray-50 dark:bg-gray-700 rounded-lg p-4 text-sm text-gray-800 dark:text-gray-200 ">
55+ {{ submission.text_response|linebreaks }}
56+ </ div >
57+ {% endif %}
58+ {% if submission.file_submission %}
59+ < a href ="{{ submission.file_submission.url }} " class ="text-blue-600 hover:text-blue-800 dark:text-blue-400 text-sm ">
60+ < i class ="fas fa-paperclip mr-1 " aria-hidden ="true "> </ i > Download submitted file
61+ </ a >
62+ {% endif %}
63+ {% if submission.status == 'graded' %}
64+ < div class ="bg-teal-50 dark:bg-teal-900 rounded-lg p-4 border-l-4 border-teal-400 ">
65+ < p class ="font-semibold text-gray-900 dark:text-white "> Score: {{ submission.score }}/{{ assignment.max_score }} ({{ submission.percentage }}%)</ p >
66+ {% if submission.feedback %}
67+ < p class ="text-sm text-gray-700 dark:text-gray-300 mt-2 "> {{ submission.feedback }}</ p >
68+ {% endif %}
69+ </ div >
70+ {% endif %}
71+ </ div >
72+ {% else %}
73+ {% if assignment.is_past_due and not assignment.allow_late_submissions %}
74+ < p class ="text-red-500 dark:text-red-400 text-sm "> This assignment is past due and does not accept late submissions.</ p >
75+ {% else %}
76+ < form method ="post " enctype ="multipart/form-data " class ="space-y-4 ">
77+ {% csrf_token %}
78+ < div >
79+ < label for ="text_response " class ="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1 "> Text Response</ label >
80+ < textarea id ="text_response " name ="text_response " rows ="6 "
81+ class ="w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 "
82+ placeholder ="Write your response here... "> </ textarea >
83+ </ div >
84+ < div >
85+ < label for ="file_submission " class ="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1 "> Upload File (optional)</ label >
86+ < input type ="file " id ="file_submission " name ="file_submission "
87+ class ="w-full text-sm text-gray-500 dark:text-gray-400 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-semibold file:bg-teal-100 file:text-teal-700 hover:file:bg-teal-200 ">
88+ < p class ="text-xs text-gray-400 mt-1 "> Allowed: PDF, JPEG, PNG, TXT, DOC, DOCX. Max 10MB.</ p >
89+ </ div >
90+ < button type ="submit "
91+ class ="bg-teal-300 hover:bg-teal-400 dark:bg-teal-600 dark:hover:bg-teal-500 text-white font-semibold px-6 py-2 rounded-lg transition duration-200 focus:outline-none focus:ring-2 focus:ring-teal-300 ">
92+ Submit Assignment
93+ </ button >
94+ </ form >
95+ {% endif %}
96+ {% endif %}
97+ </ div >
98+ {% endif %}
99+ {% if is_teacher %}
100+ < div class ="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 ">
101+ < h2 class ="text-xl font-semibold text-gray-800 dark:text-white mb-4 ">
102+ < i class ="fas fa-users mr-2 text-teal-500 dark:text-teal-300 " aria-hidden ="true "> </ i >
103+ Submissions ({{ submissions.count }})
104+ </ h2 >
105+ {% if submissions %}
106+ < div class ="space-y-3 ">
107+ {% for sub in submissions %}
108+ < div class ="flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700 rounded-lg ">
109+ < div >
110+ < p class ="font-medium text-gray-900 dark:text-white text-sm "> {{ sub.student.get_full_name|default:sub.student.username }}</ p >
111+ < p class ="text-xs text-gray-500 dark:text-gray-400 "> {{ sub.submitted_at|date:"M d, Y H:i" }}</ p >
112+ </ div >
113+ < div class ="flex items-center space-x-3 ">
114+ {% if sub.status == 'graded' %}
115+ < span class ="text-sm font-semibold text-green-600 dark:text-green-400 "> {{ sub.score }}/{{ assignment.max_score }}</ span >
116+ {% else %}
117+ < span class ="px-2 py-0.5 text-xs rounded-full bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 "> Pending</ span >
118+ {% endif %}
119+ < a href ="{% url 'grade_submission' course.slug sub.id %} " class ="text-blue-600 hover:text-blue-800 dark:text-blue-400 text-sm font-medium ">
120+ {% if sub.status == 'graded' %}Re-grade{% else %}Grade{% endif %}
121+ </ a >
122+ </ div >
123+ </ div >
124+ {% endfor %}
125+ </ div >
126+ {% else %}
127+ < p class ="text-gray-500 dark:text-gray-400 text-sm "> No submissions yet.</ p >
128+ {% endif %}
129+ </ div >
130+ {% endif %}
131+ </ div >
132+ < div class ="space-y-4 ">
133+ < div class ="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 ">
134+ < h3 class ="text-lg font-semibold text-gray-800 dark:text-white mb-3 "> Details</ h3 >
135+ < dl class ="space-y-2 text-sm ">
136+ < div class ="flex justify-between ">
137+ < dt class ="text-gray-500 dark:text-gray-400 "> Status</ dt >
138+ < dd class ="font-medium text-gray-900 dark:text-white "> {{ assignment.get_status_display }}</ dd >
139+ </ div >
140+ < div class ="flex justify-between ">
141+ < dt class ="text-gray-500 dark:text-gray-400 "> Max Score</ dt >
142+ < dd class ="font-medium text-gray-900 dark:text-white "> {{ assignment.max_score }}</ dd >
143+ </ div >
144+ {% if assignment.due_date %}
145+ < div class ="flex justify-between ">
146+ < dt class ="text-gray-500 dark:text-gray-400 "> Due</ dt >
147+ < dd class ="font-medium {% if assignment.is_past_due %}text-red-500 dark:text-red-400{% else %}text-gray-900 dark:text-white{% endif %} ">
148+ {{ assignment.due_date|date:"M d, Y" }}
149+ </ dd >
150+ </ div >
151+ {% endif %}
152+ {% if is_teacher %}
153+ < div class ="flex justify-between ">
154+ < dt class ="text-gray-500 dark:text-gray-400 "> Submissions</ dt >
155+ < dd class ="font-medium text-gray-900 dark:text-white "> {{ assignment.submission_count }}</ dd >
156+ </ div >
157+ {% endif %}
158+ </ dl >
159+ </ div >
160+ </ div >
161+ </ div >
162+ </ div >
163+ {% endblock content %}
0 commit comments