fix: misc issues

This commit is contained in:
Jannat Patel
2024-06-06 21:57:24 +05:30
parent 631f69bd75
commit fd26d2bcd1
7 changed files with 102 additions and 66 deletions

View File

@@ -6,6 +6,7 @@ import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import cstr, comma_and
from fuzzywuzzy import fuzz
from lms.lms.doctype.course_lesson.course_lesson import save_progress
from lms.lms.utils import (
generate_slug,
@@ -304,7 +305,7 @@ def check_input_answers(question, answer):
question_details = frappe.db.get_value("LMS Question", question, fields, as_dict=1)
for num in range(1, 5):
current_possibility = question_details[f"possibility_{num}"]
if current_possibility and current_possibility.lower() == answer.lower():
if current_possibility and fuzz.token_sort_ratio(current_possibility, answer) > 85:
return 1
return 0

View File

@@ -1213,6 +1213,7 @@ def create_membership(course, payment):
def add_student_to_batch(batchname, payment):
student = frappe.new_doc("Batch Student")
current_count = frappe.db.count("Batch Student", {"parent": batchname})
student.update(
{
"student": frappe.session.user,
@@ -1221,6 +1222,7 @@ def add_student_to_batch(batchname, payment):
"parent": batchname,
"parenttype": "LMS Batch",
"parentfield": "students",
"idx": current_count + 1,
}
)
student.save(ignore_permissions=True)