Skip to content

Commit

Permalink
Merge pull request #645 from tundebabzy/644
Browse files Browse the repository at this point in the history
fix: 10th lesson access issue
  • Loading branch information
pateljannat authored Oct 27, 2023
2 parents 98536ce + 0528217 commit e56afba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lms/lms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions lms/www/batch/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

0 comments on commit e56afba

Please sign in to comment.