Added preview and sections fields to LMS Topic
- The preview is used to show the details of the topic in the course page - the sections are used to show the different part of the topic, each could be of a different type Issue #8
This commit is contained in:
@@ -7,10 +7,12 @@
|
|||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
|
"course",
|
||||||
|
"preview",
|
||||||
"title",
|
"title",
|
||||||
"description",
|
"description",
|
||||||
"course",
|
"order",
|
||||||
"order"
|
"sections"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -37,11 +39,22 @@
|
|||||||
"fieldname": "order",
|
"fieldname": "order",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Order"
|
"label": "Order"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "preview",
|
||||||
|
"fieldtype": "Markdown Editor",
|
||||||
|
"label": "Preview"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "sections",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Sections",
|
||||||
|
"options": "LMS Section"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-03-05 12:59:22.817471",
|
"modified": "2021-03-05 17:08:55.580189",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Topic",
|
"name": "LMS Topic",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
{% for topic in course.topics %}
|
{% for topic in course.topics %}
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<h5><a href="/courses/topic?course={{course.name}}&topic={{topic.name}}">{{topic.title}}</a></h5>
|
<h5><a href="/courses/topic?course={{course.name}}&topic={{topic.name}}">{{topic.title}}</a></h5>
|
||||||
<div>{{topic.description}}</div>
|
<div>{{topic.preview | markdown }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def get_course(name):
|
|||||||
filters={
|
filters={
|
||||||
'course': name
|
'course': name
|
||||||
},
|
},
|
||||||
fields=['name', 'title', 'description'],
|
fields=['name', 'title', 'preview'],
|
||||||
order_by='creation'
|
order_by='creation'
|
||||||
)
|
)
|
||||||
return course
|
return course
|
||||||
|
|||||||
@@ -19,7 +19,30 @@
|
|||||||
|
|
||||||
<h1>{{ topic.title }}</h1>
|
<h1>{{ topic.title }}</h1>
|
||||||
|
|
||||||
<div>{{ topic.description }}</div>
|
{% for s in topic.sections %}
|
||||||
|
<div class="section section-{{ s.type }}">
|
||||||
|
{{ render_section(s) }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% macro render_section(s) %}
|
||||||
|
{% if s.type == "text" %}
|
||||||
|
{{ render_section_text(s) }}
|
||||||
|
{% elif s.type == "code" %}
|
||||||
|
{{ render_section_code(s) }}
|
||||||
|
{% else %}
|
||||||
|
<div>Unknown section type: {{s.type}}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro render_section_text(s) %}
|
||||||
|
{{ s.contents | markdown }}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro render_section_code(s) %}
|
||||||
|
<pre>{{s.code}}</pre>
|
||||||
|
{% endmacro %}
|
||||||
|
|||||||
Reference in New Issue
Block a user