fix: class issues

This commit is contained in:
Jannat Patel
2023-02-23 12:40:07 +05:30
parent 99a7c47798
commit d87fb81cf3
14 changed files with 173 additions and 83 deletions

View File

@@ -6,6 +6,8 @@ from frappe import _
def get_context(context):
context.no_cache = 1
class_name = frappe.form_dict["classname"]
session_user = []
remaining_students = []
context.class_info = frappe.db.get_value(
"LMS Class",
@@ -22,8 +24,19 @@ def get_context(context):
"Class Course", {"parent": class_name}, pluck="course"
)
context.class_students = frappe.get_all(
class_students = frappe.get_all(
"Class Student", {"parent": class_name}, ["student", "student_name", "username"]
)
for student in class_students:
if student.student == frappe.session.user:
session_user.append(student)
else:
remaining_students.append(student)
if len(session_user):
context.class_students = session_user + remaining_students
else:
context.class_students = class_students
context.is_moderator = has_course_moderator_role()