@@ -50,21 +50,24 @@ <h5 style="margin-top: 20px;">
5050 {% endfor %}
5151 </ h5 >
5252
53+
54+ <!-- Table of contents -->
5355 < div class ="row " style ="margin-top: 20px; ">
5456 < div class ="col-md-4 ">
5557 < ol class ="list-group " style ="font-weight: bold; ">
5658 <!-- ToDo Show nested structure -->
5759 {% for entry in structure %}
5860 < li class ="list-group-item ">
5961 {% with forloop.counter as outer_index %}
60- {{ outer_index }}. {{ entry.topic.title }}
61- < span class ="badge badge-primary badge-pill badge-light "> {{ entry.topic.contents.count }}</ span >
62+ < a href ="#{{ entry.topic.title }} "> {{ outer_index }}. {{ entry.topic.title }}
63+ < span class ="badge badge-primary badge-pill badge-light "> {{ entry.topic.contents.count }}</ span > </ a >
64+ <!-- Show (up to one level of) subtopics in ToC -->
6265 {% if entry.subtopics %}
6366 < ol class ="list-group ">
6467 {% for subtopic in entry.subtopics %}
6568 < li class ="list-group-item " style ="border: none; ">
66- {{ outer_index }}.{{ forloop.counter }}. {{ subtopic.title }}
67- < span class ="badge badge-primary badge-pill badge-light "> {{ subtopic.contents.count }}</ span >
69+ {{ outer_index }}.{{ forloop.counter }}. {{ subtopic.topic. title }}
70+ < span class ="badge badge-primary badge-pill badge-light "> {{ subtopic.topic. contents.count }}</ span >
6871 </ li >
6972 {% endfor %}
7073 </ ol >
@@ -84,43 +87,42 @@ <h5 style="margin-top: 20px;">
8487 <!-- TODO Add image? -->
8588 </ div >
8689
90+ <!-- Display coursebook -->
8791 {% include 'frontend/course/coursebook.html' %}
8892
93+ <!-- Display course contents -->
8994 {% for entry in structure %}
9095 < div style ="margin-top: 30px; ">
9196 {% with forloop.counter as outer_index %}
97+ <!-- Filters, Ordering, Add contents -->
9298 < div class ="float-right text-right ">
9399 < form id ="filter+sort " class ="form-inline " method ="post "
94100 action ="{% url 'frontend:course' course.id %} ">
95101 {% csrf_token %}
96102 {% bootstrap_form form %}
103+ {% with entry.topic as entry_topic %}
104+ {% add_content_button user course.id entry_topic.id %}
105+ {% endwith %}
97106 </ form >
98107 </ div >
99- < h3 class ="text-info "> {{ outer_index }}. {{ entry.topic.title }} {% if sorting != "None" %}({{ sorting }}){% endif %}</ h3 >
100- {% with entry.topic as topic_replace %}
101- {% add_content_button user course.id topic_replace.id %}
102- {% endwith %}
103- < h3 class ="text-info "> {{ outer_index }}. {{ entry.topic.title }}</ h3 >
108+ < h3 class ="text-info "> {{ outer_index }}. {{ entry.topic.title }} {% if sorting != "None" %}({% trans "sort by:" %} {{ sorting }}){% endif %}</ h3 >
104109
105- {% with entry.topic.contents.all as topic_contents %}
110+ {% with entry.topic_contents as topic_contents %}
106111 {% include "frontend/course/topic_contents.html" %}
107112 {% endwith %}
113+
114+ <!-- Show subtopics -->
108115 {% if entry.subtopics %}
109116 {% for subtopic in entry.subtopics %}
110117 < div style ="margin-top: 15px; ">
111118 < div class ="float-right text-right ">
112- < form id ="filter+sort " class ="form-inline " method ="post "
113- action ="{% url 'frontend:course' course.id %} ">
114- {% csrf_token %}
115- {% bootstrap_form form %}
116- </ form >
119+ {% with subtopic.topic as subtopic_topic %}
120+ {% add_content_button user course.id subtopic_topic.id %}
121+ {% endwith %}
117122 </ div >
118- < h4 class ="text-info "> {{ outer_index }}.{{ forloop.counter }}. {{ subtopic.subtopic.title }} {% if sorting != "None" %}({{ sorting }}) {% endif %}</ h4 >
119- {% with subtopic as topic_replace %}
120- {% add_content_button user course.id topic_replace.id %}
121- {% endwith %}
122- < h4 class ="text-info "> {{ outer_index }}.{{ forloop.counter }}. {{ subtopic.title }}</ h4 >
123- {% with subtopic.contents.all as topic_contents %}
123+ < h4 class ="text-info "> {{ outer_index }}.{{ forloop.counter }}. {{ subtopic.topic.title }} {% if sorting != "None" %}({{ sorting }}) {% endif %}</ h4 >
124+
125+ {% with subtopic.topic_contents as topic_contents %}
124126 {% include "frontend/course/topic_contents.html" %}
125127 {% endwith %}
126128 </ div >
@@ -129,12 +131,7 @@ <h4 class="text-info">{{ outer_index }}.{{ forloop.counter }}. {{ subtopic.title
129131 {% endwith %}
130132 </ div >
131133 {% empty %}
132- < h3 > No Topics </ h3 >
133- < p > This course doesn't have topics at the moment.
134- {% if user in course.owner.all %}You can
135- < a href ="{% url 'edit_course_structure' course.id %} "> add topics here</ a >
136- {% endif %}
137- </ p >
134+ < h3 > {% trans "No Topics" %}</ h3 >
135+ < p > {% trans "This course doesn't have topics at the moment." %}</ p >
138136 {% endfor %}
139-
140- {% endblock %}
137+ {% endblock %}s
0 commit comments