diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 38fc5933b..3ed651e49 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -149,7 +149,7 @@ def get_lesson_details(chapter): ], as_dict=True, ) - lesson_details.number = flt(f"{chapter.idx}.{row.idx}") + lesson_details.number = f"{chapter.idx}.{row.idx}" lesson_details.icon = get_lesson_icon(lesson_details.body) lessons.append(lesson_details) return lessons diff --git a/lms/www/batch/learn.py b/lms/www/batch/learn.py index c77233b75..d51751ace 100644 --- a/lms/www/batch/learn.py +++ b/lms/www/batch/learn.py @@ -107,10 +107,13 @@ def get_page_extensions(context): def get_neighbours(current, lessons): - current = flt(current) - numbers = sorted(lesson.number for lesson in lessons) - index = numbers.index(current) + numbers = [lesson.number for lesson in lessons] + tuples_list = [tuple(int(x) for x in s.split(".")) for s in numbers] + sorted_tuples = sorted(tuples_list) + sorted_numbers = [".".join(str(num) for num in t) for t in sorted_tuples] + index = sorted_numbers.index(current) + return { - "prev": numbers[index - 1] if index - 1 >= 0 else None, - "next": numbers[index + 1] if index + 1 < len(numbers) else None, + "prev": sorted_numbers[index - 1] if index - 1 >= 0 else None, + "next": sorted_numbers[index + 1] if index + 1 < len(sorted_numbers) else None, }