feat: added next/prev links to learn pages
This commit is contained in:
@@ -23,15 +23,31 @@
|
||||
|
||||
{% block content %}
|
||||
{{ Sidebar(course.name, batch.name) }}
|
||||
<div class="container lesson">
|
||||
|
||||
<h1>{{ lesson.title }} - {{ lesson.name }}</h1>
|
||||
<div class="container">
|
||||
<div class="lesson-page">
|
||||
<div class="lesson-pagination">
|
||||
{% if prev_url %}
|
||||
<a href="{{prev_url}}" class="btn">← Prev</a>
|
||||
{% endif %}
|
||||
{% if next_url %}
|
||||
<a href="{{next_url}}" class="btn pull-right">Next →</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% for s in lesson.get_sections() %}
|
||||
<div class="section section-{{ s.type }}">
|
||||
{{ render_section(s) }}
|
||||
<h2>{{ lesson.title }}</h2>
|
||||
|
||||
{% for s in lesson.get_sections() %}
|
||||
<div class="section section-{{ s.type }}">
|
||||
{{ render_section(s) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="lesson-pagination">
|
||||
<a href="#" class="btn">← Prev</a>
|
||||
<a href="#" class="btn pull-right">Next →</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ def get_context(context):
|
||||
batch_name = frappe.form_dict["batch"]
|
||||
chapter_index = frappe.form_dict.get("chapter")
|
||||
lesson_index = frappe.form_dict.get("lesson")
|
||||
lesson_number = f"{chapter_index}.{lesson_index}"
|
||||
|
||||
course = Course.find(course_name)
|
||||
if not course:
|
||||
@@ -30,5 +31,16 @@ def get_context(context):
|
||||
context.chapter_index = chapter_index
|
||||
context.livecode_url = get_livecode_url()
|
||||
|
||||
outline = course.get_outline()
|
||||
next_ = outline.get_next(lesson_number)
|
||||
prev_ = outline.get_prev(lesson_number)
|
||||
context.next_url = get_learn_url(course_name, batch_name, next_)
|
||||
context.prev_url = get_learn_url(course_name, batch_name, prev_)
|
||||
|
||||
def get_learn_url(course_name, batch_name, lesson_number):
|
||||
if not lesson_number:
|
||||
return
|
||||
return f"/courses/{course_name}/{batch_name}/learn/{lesson_number}"
|
||||
|
||||
def get_livecode_url():
|
||||
return frappe.db.get_single_value("LMS Settings", "livecode_url")
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
{% if is_exercise %}
|
||||
<button class="submit pull-right btn-primary">Submit</button>
|
||||
{% if last_submitted %}
|
||||
<span class="pull-right" style="padding-right: 10px;">Last submitted {{last_submitted}}</span>
|
||||
<span class="pull-right" style="padding-right: 10px;">Submitted <span class="human-time" data-timestamp="{{last_submitted}}">on {{last_submitted}}</span></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user