Compare commits

..

4 Commits

Author SHA1 Message Date
Anand Chitipothu
20b3ae7d76 fix: error in linking lessons on course page
The course was adding `{{ no such element: community.lms.doctype.lms_course.lms_course.LMSCourse object['query_parameter'] }}`
to the lesson links. Fixed it by setting query_parameter to "".
2021-06-23 10:27:01 +05:30
Anand Chitipothu
f303be4db5 fix: error in find_macros when the input is empty
Added a special case to handle this issue.
2021-06-22 18:12:31 +05:30
Anand Chitipothu
fc1c393f15 feat: allow a student to be mentor of another batch
This is a requirement for mon.school. The students are of the first
batch are now mentors of new batches.
2021-06-22 18:09:21 +05:30
Jannat Patel
5abfa35095 Merge pull request #132 from fossunited/learning-modes
feat: learning modes and batch switching
2021-06-22 12:23:46 +05:30
3 changed files with 24 additions and 13 deletions

View File

@@ -32,20 +32,28 @@ class LMSBatchMembership(Document):
frappe.throw(_("{0} is already a {1} of the course {2}").format(member_name, previous_membership.member_type, course_title)) frappe.throw(_("{0} is already a {1} of the course {2}").format(member_name, previous_membership.member_type, course_title))
def validate_membership_in_different_batch_same_course(self): def validate_membership_in_different_batch_same_course(self):
"""Ensures that a studnet is only part of one batch.
"""
# nothing to worry if the member is not a student
if self.member_type != "Student":
return
course = frappe.db.get_value("LMS Batch", self.batch, "course") course = frappe.db.get_value("LMS Batch", self.batch, "course")
previous_membership = frappe.get_all("LMS Batch Membership", memberships = frappe.get_all(
"LMS Batch Membership",
filters={ filters={
"member": self.member, "member": self.member,
"name": ["!=", self.name] "name": ["!=", self.name],
"member_type": "Student",
"course": self.course
}, },
fields=["batch", "member_type", "name"] fields=["batch", "member_type", "name"]
) )
for membership in previous_membership: if memberships:
batch_course = frappe.db.get_value("LMS Batch", membership.batch, "course") membership = memberships[0]
if batch_course == course and (membership.member_type == "Student" or self.member_type == "Student"):
member_name = frappe.db.get_value("User", self.member, "full_name") member_name = frappe.db.get_value("User", self.member, "full_name")
frappe.throw(_("{0} is already a {1} of {2} course through {3} batch").format(member_name, membership.member_type, course, membership.batch)) frappe.throw(_("{0} is already a Student of {1} course through {2} batch").format(member_name, course, membership.batch))
@frappe.whitelist() @frappe.whitelist()
def create_membership(course, batch=None, member=None, member_type="Student", role="Member"): def create_membership(course, batch=None, member=None, member_type="Student", role="Member"):

View File

@@ -36,6 +36,8 @@ def find_macros(text):
('Exercise', 'four-circles') ('Exercise', 'four-circles')
] ]
""" """
if not text:
return []
macros = re.findall(MACRO_RE, text) macros = re.findall(MACRO_RE, text)
# remove the quotes around the argument # remove the quotes around the argument
return [(name, _remove_quotes(arg)) for name, arg in macros] return [(name, _remove_quotes(arg)) for name, arg in macros]

View File

@@ -16,6 +16,7 @@ def get_context(context):
raise frappe.Redirect raise frappe.Redirect
context.course = course context.course = course
context.course.query_parameter = ""
if not course.is_mentor(frappe.session.user): if not course.is_mentor(frappe.session.user):
batch = course.get_membership(frappe.session.user) batch = course.get_membership(frappe.session.user)
if batch: if batch: