fix: progress

This commit is contained in:
Jannat Patel
2024-04-03 12:11:34 +05:30
parent c7bdf68bc6
commit 5de7f5e283
9 changed files with 68 additions and 35 deletions
@@ -66,7 +66,8 @@
},
{
"fieldname": "section_break_6",
"fieldtype": "Section Break"
"fieldtype": "Section Break",
"hidden": 1
},
{
"fieldname": "body",
@@ -78,6 +79,7 @@
{
"fieldname": "help_section",
"fieldtype": "Section Break",
"hidden": 1,
"label": "Help"
},
{
@@ -117,6 +119,7 @@
{
"fieldname": "section_break_16",
"fieldtype": "Section Break",
"hidden": 1,
"label": "Assignment"
},
{
@@ -158,7 +161,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-03-14 14:25:22.464111",
"modified": "2024-04-03 10:48:17.525859",
"modified_by": "Administrator",
"module": "LMS",
"name": "Course Lesson",
@@ -98,6 +98,11 @@ def save_progress(lesson, course):
if not quiz_completed:
return 0
if frappe.db.exists(
"LMS Course Progress", {"lesson": lesson, "member": frappe.session.user}
):
return 0
frappe.get_doc(
{
"doctype": "LMS Course Progress",
@@ -116,7 +121,6 @@ def get_quiz_progress(lesson):
body = frappe.db.get_value("Course Lesson", lesson, "body")
macros = find_macros(body)
quizzes = [value for name, value in macros if name == "Quiz"]
for quiz in quizzes:
passing_percentage = frappe.db.get_value("LMS Quiz", quiz, "passing_percentage")
if not frappe.db.exists(
@@ -128,7 +132,6 @@ def get_quiz_progress(lesson):
},
):
return False
return True
+12 -2
View File
@@ -6,7 +6,7 @@ import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import cstr, comma_and
from lms.lms.doctype.lms_question.lms_question import validate_correct_answers
from lms.lms.doctype.course_lesson.course_lesson import save_progress
from lms.lms.utils import (
generate_slug,
has_course_moderator_role,
@@ -86,7 +86,7 @@ def quiz_summary(quiz, results):
del result["question_index"]
quiz_details = frappe.db.get_value(
"LMS Quiz", quiz, ["total_marks", "passing_percentage"], as_dict=1
"LMS Quiz", quiz, ["total_marks", "passing_percentage", "lesson", "course"], as_dict=1
)
score_out_of = quiz_details.total_marks
percentage = (score / score_out_of) * 100
@@ -103,6 +103,16 @@ def quiz_summary(quiz, results):
"passing_percentage": quiz_details.passing_percentage,
}
)
print(
percentage, quiz_details.passing_percentage, quiz_details.lesson, quiz_details.course
)
if (
percentage >= quiz_details.passing_percentage
and quiz_details.lesson
and quiz_details.course
):
save_progress(quiz_details.lesson, quiz_details.course)
submission.save(ignore_permissions=True)
return {
+3 -1
View File
@@ -155,11 +155,13 @@ def get_lesson_details(chapter):
"question",
"file_type",
"instructor_notes",
"course",
],
as_dict=True,
)
lesson_details.number = f"{chapter.idx}.{row.idx}"
lesson_details.icon = get_lesson_icon(lesson_details.body)
lesson_details.is_complete = get_progress(lesson_details.course, lesson_details.name)
lessons.append(lesson_details)
return lessons
@@ -307,7 +309,7 @@ def get_progress(course, lesson, member=None):
return frappe.db.get_value(
"LMS Course Progress",
{"course": course, "owner": member, "lesson": lesson},
{"course": course, "member": member, "lesson": lesson},
["status"],
)