fix: tabs and learn page
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from re import I
|
||||
import frappe
|
||||
from . import utils
|
||||
|
||||
@@ -20,8 +21,10 @@ def get_context(context):
|
||||
context.chapter_index = chapter_index
|
||||
print(context.lesson)
|
||||
outline = context.course.get_outline()
|
||||
next_ = outline.get_next(lesson_number)
|
||||
prev_ = outline.get_prev(lesson_number)
|
||||
next_ = outline.get_next(lesson_number)
|
||||
context.prev_chap = get_chapter_title(course_name, prev_)
|
||||
context.next_chap = get_chapter_title(course_name, next_)
|
||||
context.next_url = get_learn_url(course_name, batch_name, next_)
|
||||
context.prev_url = get_learn_url(course_name, batch_name, prev_)
|
||||
|
||||
@@ -29,3 +32,11 @@ 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_chapter_title(course_name, lesson_number):
|
||||
if not lesson_number:
|
||||
return
|
||||
chapter_index = lesson_number.split(".")[0]
|
||||
lesson_index = lesson_number.split(".")[1]
|
||||
chapter_name = frappe.db.get_value("Chapter", {"course": course_name, "index_": chapter_index}, "name")
|
||||
return frappe.db.get_value("Lesson", {"chapter": chapter_name, "index_": lesson_index}, "title")
|
||||
|
||||
Reference in New Issue
Block a user