feat: added a page to list cohorts of a course

- added a page /courses/<course>/manage that lists the active cohorts
- only accessible to mentors and staff
- also added a "manage the course" button on course page for mentors/staff

Issue #271
This commit is contained in:
Anand Chitipothu
2021-11-29 17:33:45 +05:30
parent 7cd57cadb2
commit 102fa9c0a8
7 changed files with 141 additions and 0 deletions

View File

@@ -210,6 +210,24 @@ class LMSCourse(Document):
visibility="Public")
return batches
def get_cohorts(self):
return find_all("Cohort", course=self.name, order_by="creation")
def is_cohort_staff(self, user_email):
"""Returns True if the user is either a mentor or a staff for one or more active cohorts of this course.
"""
q1 = {
"doctype": "Cohort Staff",
"course": self.name,
"email": user_email
}
q2 = {
"doctype": "Cohort Mentor",
"course": self.name,
"email": user_email
}
return frappe.db.exists(q1) or frappe.db.exists(q2)
def get_lesson_index(self, lesson_name):
"""Returns the {chapter_index}.{lesson_index} for the lesson.
"""