Skip to content

Commit 9c12ade

Browse files
enhance form to submit homework
1 parent 1b8868b commit 9c12ade

File tree

1 file changed

+116
-8
lines changed

1 file changed

+116
-8
lines changed

courses/templates/homework/homework.html

Lines changed: 116 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@
7070
{% endblock %}
7171

7272
{% block breadcrumbs %}
73-
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
74-
{% endblock breadcrumbs %}
73+
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
74+
{% endblock %}
75+
7576
{% block content %}
7677
<div class="homework-container">
77-
<h2 class="homework-title text-center">
78+
<h2 class="homework-title mb-3 text-center">
7879
{{ homework.title }} for
7980
<a href="{% url 'course' course.slug %}">{{ course.title }}</a>
8081
</h2>
@@ -110,8 +111,8 @@ <h2 class="homework-title text-center">
110111
{% endif %}
111112

112113
<div class="homework-meta">
113-
<p class="text-muted mb-2">{{ homework.description }}</p>
114-
<p class="mb-0">Due date: <span class="local-date font-weight-bold">{{ homework.due_date |date:"c" }}</span> (local time)</p>
114+
<p class="text-muted">{{ homework.description }}</p>
115+
<p>Due date: <span class="local-date">{{ homework.due_date |date:"c" }}</span> (local time)</p>
115116
</div>
116117

117118
{% if not is_authenticated %}
@@ -128,7 +129,7 @@ <h3 class="mb-3">Questions</h3>
128129
{% endif %}
129130

130131
{% for question, answer in question_answers %}
131-
<div class="question">
132+
<div class="mb-3 question">
132133
<p class="question-text">
133134
Question {{ forloop.counter }}. {{ question.text }}
134135
{% if question.scores_for_correct_answer != 0 %}
@@ -185,13 +186,120 @@ <h3 class="mb-3">Questions</h3>
185186
</div>
186187
{% endfor %}
187188

189+
{% if homework.homework_url_field %}
190+
<div class="mb-3 question">
191+
<label for="homework_url" class="question-text">
192+
Homework URL
193+
<i
194+
class="fas fa-question-circle text-muted"
195+
data-toggle="tooltip"
196+
data-placement="top"
197+
title="Link to GitHub or other public code-hosting website">
198+
</i>
199+
</label>
200+
<input
201+
type="url"
202+
class="form-control"
203+
id="homework_url"
204+
name="homework_url"
205+
value="{{ submission.homework_link|default:'' }}"
206+
{% if disabled %} disabled {% endif %}
207+
required
208+
/>
209+
<div class="invalid-feedback">Please provide a valid URL.</div>
210+
</div>
211+
{% endif %}
212+
213+
{% include 'include/learning_in_public_links.html' with course=course learning_in_public_cap=homework.learning_in_public_cap learning_in_public_links=submission.learning_in_public_links disabled=disabled accepting_submissions=accepting_submissions %}
214+
<script src="{% static 'learning_in_public.js' %}"></script>
215+
216+
{% if homework.time_spent_lectures_field %}
217+
<div class="mb-3 question">
218+
<label for="time_spent_lectures" class="question-text">
219+
Time spent on lectures (hours) <span class="text-muted">(optional)</span>
220+
<i
221+
class="fas fa-question-circle text-muted"
222+
data-toggle="tooltip"
223+
data-placement="top"
224+
title="How much time (in hours) did you spend on watching lectures and reading?">
225+
</i>
226+
</label>
227+
<input
228+
type="number"
229+
class="form-control"
230+
name="time_spent_lectures"
231+
id="time_spent_lectures"
232+
min="0"
233+
value="{{ submission.time_spent_lectures|default:'' }}"
234+
{% if disabled %} disabled {% endif %}
235+
/>
236+
</div>
237+
{% endif %}
238+
239+
{% if homework.time_spent_homework_field %}
240+
<div class="mb-3 question">
241+
<label for="time_spent_homework" class="question-text">
242+
Time spent on homework (hours) <span class="text-muted">(optional)</span>
243+
<i
244+
class="fas fa-question-circle text-muted"
245+
data-toggle="tooltip"
246+
data-placement="top"
247+
title="How much time (in hours) did you spend on homework?">
248+
</i>
249+
</label>
250+
<input
251+
type="number"
252+
class="form-control"
253+
name="time_spent_homework"
254+
id="time_spent_homework"
255+
min="0"
256+
value="{{ submission.time_spent_homework|default:'' }}"
257+
{% if disabled %} disabled {% endif %}
258+
/>
259+
</div>
260+
{% endif %}
261+
262+
{% if homework.problems_comments_field %}
263+
<div class="mb-3 question">
264+
<label for="problems_comments" class="question-text">
265+
Problems or comments <span class="text-muted">(optional)</span>
266+
</label>
267+
<textarea
268+
class="form-control"
269+
name="problems_comments"
270+
id="problems_comments"
271+
{% if disabled %} disabled {% endif %}
272+
>{{ submission.problems_comments|default:'' }}</textarea>
273+
</div>
274+
{% endif %}
275+
276+
{% if course.faq_document_url and homework.faq_contribution_field %}
277+
<div class="mb-3 question">
278+
<label for="faq_contribution" class="question-text">
279+
FAQ contribution <span class="text-muted">(<a href="{{ course.faq_document_url }}" target="_blank">FAQ document</a>, optional)</span>
280+
<i
281+
class="fas fa-question-circle text-muted"
282+
data-toggle="tooltip"
283+
data-placement="top"
284+
title="If you had any problems and resolved it, or helped somebody in Slack, please put the solution to the FAQ. What is the problem you put in FAQ?">
285+
</i>
286+
</label>
287+
<textarea
288+
class="form-control"
289+
name="faq_contribution"
290+
id="faq_contribution"
291+
{% if disabled %} disabled {% endif %}
292+
>{{ submission.faq_contribution|default:'' }}</textarea>
293+
</div>
294+
{% endif %}
295+
188296
{% if not homework.is_scored %}
189297
<div class="mt-4 text-center">
190298
{% if is_authenticated %}
191299
<button
192300
id="submit-button"
193301
type="submit"
194-
class="btn btn-primary btn-lg">
302+
class="btn btn-primary">
195303
{% if not submission %}
196304
Submit
197305
{% else %}
@@ -206,7 +314,7 @@ <h3 class="mb-3">Questions</h3>
206314
</form>
207315

208316
{% if submission %}
209-
<p class="text-muted question-text m-0 mt-3">Last submission at: {{ submission.submitted_at|date:"F d, Y H:i" }}</p>
317+
<p class="text-muted question-text m-0">Last submission at: {{ submission.submitted_at|date:"F d, Y H:i" }}</p>
210318
{% endif %}
211319

212320
<script>

0 commit comments

Comments
 (0)