Compare commits

..

2 Commits

Author SHA1 Message Date
pateljannat
4079ed97b9 fix: quiz, course outline, and lesson indexing 2021-08-05 18:26:41 +05:30
Jannat Patel
ce86b5deda Merge pull request #167 from fossunited/issues
fix: cleanup
2021-08-04 19:18:45 +05:30
5 changed files with 24 additions and 5 deletions

View File

@@ -194,7 +194,13 @@ class LMSCourse(Document):
"""Returns the {chapter_index}.{lesson_index} for the lesson.
"""
lesson = frappe.db.get_value("Lessons", {"lesson": lesson_name}, ["idx", "parent"], as_dict=True)
if not lesson:
return None
chapter = frappe.db.get_value("Chapters", {"chapter": lesson.parent}, ["idx"], as_dict=True)
if not chapter:
return None
return f"{chapter.idx}.{lesson.idx}"
def reindex_exercises(self):

View File

@@ -27,7 +27,7 @@
{{ lesson.title }}
{% if membership %}
<img class="lesson-progress-tick {{ course.get_progress(lesson.name) != 'Complete' and 'hide' }}"
<img class="ml-1 lesson-progress-tick {{ course.get_progress(lesson.name) != 'Complete' and 'hide' }}"
src="/assets/community/icons/check.svg">
{% endif %}

View File

@@ -780,7 +780,7 @@ input[type=checkbox] {
}
.lesson-links {
display: flex;
display: block;
padding: 0 1rem;
margin-bottom: .25rem;
color: inherit;
@@ -794,6 +794,13 @@ input[type=checkbox] {
border-radius: .25rem;
}
.course-content-parent .lesson-links {
padding: 0 0 0 1rem;
margin-bottom: 0.75rem;
font-size: 0.85rem;
line-height: 200%;
}
.chapter-content {
margin: 0;
margin-left: .875rem;

View File

@@ -58,6 +58,7 @@ var mark_active_question = (e = undefined) => {
$(".current-question").text(`${next_index}`);
$("#check").removeClass("hide").attr("disabled", true);
$("#next").addClass("hide");
$(".explanation").addClass("hide");
}
var mark_progress = (e) => {

View File

@@ -17,10 +17,9 @@ def get_context(context):
index_ = get_lesson_index(context.course, context.batch, frappe.session.user) or "1.1"
else:
index_ = "1.1"
frappe.local.flags.redirect_location = context.course.get_learn_url(index_) + context.course.query_parameter
raise frappe.Redirect
utils.redirect_to_lesson(context.course, index_)
context.lesson = list(filter(lambda x: cstr(x.number) == lesson_number, context.lessons))[0]
context.lesson = get_current_lesson_details(lesson_number, context)
neighbours = context.course.get_neighbours(lesson_number, context.lessons)
context.next_url = get_learn_url(neighbours["next"], context.course)
context.prev_url = get_learn_url(neighbours["prev"], context.course)
@@ -40,6 +39,12 @@ def get_context(context):
"is_member": context.membership is not None
}
def get_current_lesson_details(lesson_number, context):
details_list = list(filter(lambda x: cstr(x.number) == lesson_number, context.lessons))
if not len(details_list):
utils.redirect_to_lesson(context.course)
return details_list[0]
def get_learn_url(lesson_number, course):
return course.get_learn_url(lesson_number) and course.get_learn_url(lesson_number) + course.query_parameter