Skip to content

Commit

Permalink
enhance form to submit homework
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafanasser2000 committed Jul 25, 2024
1 parent 1b8868b commit 9c12ade
Showing 1 changed file with 116 additions and 8 deletions.
124 changes: 116 additions & 8 deletions courses/templates/homework/homework.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@
{% endblock %}

{% block breadcrumbs %}
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
{% endblock breadcrumbs %}
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
{% endblock %}

{% block content %}
<div class="homework-container">
<h2 class="homework-title text-center">
<h2 class="homework-title mb-3 text-center">
{{ homework.title }} for
<a href="{% url 'course' course.slug %}">{{ course.title }}</a>
</h2>
Expand Down Expand Up @@ -110,8 +111,8 @@ <h2 class="homework-title text-center">
{% endif %}

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

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

{% for question, answer in question_answers %}
<div class="question">
<div class="mb-3 question">
<p class="question-text">
Question {{ forloop.counter }}. {{ question.text }}
{% if question.scores_for_correct_answer != 0 %}
Expand Down Expand Up @@ -185,13 +186,120 @@ <h3 class="mb-3">Questions</h3>
</div>
{% endfor %}

{% if homework.homework_url_field %}
<div class="mb-3 question">
<label for="homework_url" class="question-text">
Homework URL
<i
class="fas fa-question-circle text-muted"
data-toggle="tooltip"
data-placement="top"
title="Link to GitHub or other public code-hosting website">
</i>
</label>
<input
type="url"
class="form-control"
id="homework_url"
name="homework_url"
value="{{ submission.homework_link|default:'' }}"
{% if disabled %} disabled {% endif %}
required
/>
<div class="invalid-feedback">Please provide a valid URL.</div>
</div>
{% endif %}

{% 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 %}
<script src="{% static 'learning_in_public.js' %}"></script>

{% if homework.time_spent_lectures_field %}
<div class="mb-3 question">
<label for="time_spent_lectures" class="question-text">
Time spent on lectures (hours) <span class="text-muted">(optional)</span>
<i
class="fas fa-question-circle text-muted"
data-toggle="tooltip"
data-placement="top"
title="How much time (in hours) did you spend on watching lectures and reading?">
</i>
</label>
<input
type="number"
class="form-control"
name="time_spent_lectures"
id="time_spent_lectures"
min="0"
value="{{ submission.time_spent_lectures|default:'' }}"
{% if disabled %} disabled {% endif %}
/>
</div>
{% endif %}

{% if homework.time_spent_homework_field %}
<div class="mb-3 question">
<label for="time_spent_homework" class="question-text">
Time spent on homework (hours) <span class="text-muted">(optional)</span>
<i
class="fas fa-question-circle text-muted"
data-toggle="tooltip"
data-placement="top"
title="How much time (in hours) did you spend on homework?">
</i>
</label>
<input
type="number"
class="form-control"
name="time_spent_homework"
id="time_spent_homework"
min="0"
value="{{ submission.time_spent_homework|default:'' }}"
{% if disabled %} disabled {% endif %}
/>
</div>
{% endif %}

{% if homework.problems_comments_field %}
<div class="mb-3 question">
<label for="problems_comments" class="question-text">
Problems or comments <span class="text-muted">(optional)</span>
</label>
<textarea
class="form-control"
name="problems_comments"
id="problems_comments"
{% if disabled %} disabled {% endif %}
>{{ submission.problems_comments|default:'' }}</textarea>
</div>
{% endif %}

{% if course.faq_document_url and homework.faq_contribution_field %}
<div class="mb-3 question">
<label for="faq_contribution" class="question-text">
FAQ contribution <span class="text-muted">(<a href="{{ course.faq_document_url }}" target="_blank">FAQ document</a>, optional)</span>
<i
class="fas fa-question-circle text-muted"
data-toggle="tooltip"
data-placement="top"
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?">
</i>
</label>
<textarea
class="form-control"
name="faq_contribution"
id="faq_contribution"
{% if disabled %} disabled {% endif %}
>{{ submission.faq_contribution|default:'' }}</textarea>
</div>
{% endif %}

{% if not homework.is_scored %}
<div class="mt-4 text-center">
{% if is_authenticated %}
<button
id="submit-button"
type="submit"
class="btn btn-primary btn-lg">
class="btn btn-primary">
{% if not submission %}
Submit
{% else %}
Expand All @@ -206,7 +314,7 @@ <h3 class="mb-3">Questions</h3>
</form>

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

<script>
Expand Down

0 comments on commit 9c12ade

Please sign in to comment.