diff --git a/school/lms/doctype/cohort/__init__.py b/school/lms/doctype/cohort/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/school/lms/doctype/cohort/cohort.js b/school/lms/doctype/cohort/cohort.js new file mode 100644 index 00000000..002b8b3c --- /dev/null +++ b/school/lms/doctype/cohort/cohort.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, FOSS United and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Cohort', { + // refresh: function(frm) { + + // } +}); diff --git a/school/lms/doctype/cohort/cohort.json b/school/lms/doctype/cohort/cohort.json new file mode 100644 index 00000000..6c98c101 --- /dev/null +++ b/school/lms/doctype/cohort/cohort.json @@ -0,0 +1,135 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "format:{course}/{slug}", + "creation": "2021-11-19 11:45:31.016097", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "course", + "slug", + "title", + "section_break_2", + "instructor", + "status", + "column_break_4", + "begin_date", + "end_date", + "duration", + "section_break_8", + "description" + ], + "fields": [ + { + "fieldname": "description", + "fieldtype": "Markdown Editor", + "label": "Description" + }, + { + "fieldname": "instructor", + "fieldtype": "Link", + "label": "Instructor", + "options": "User", + "reqd": 1 + }, + { + "fieldname": "status", + "fieldtype": "Select", + "label": "Status", + "options": "Upcoming\nLive\nCompleted\nCancelled", + "reqd": 1 + }, + { + "fieldname": "begin_date", + "fieldtype": "Date", + "label": "Begin Date" + }, + { + "fieldname": "end_date", + "fieldtype": "Date", + "label": "End Date" + }, + { + "fieldname": "duration", + "fieldtype": "Data", + "label": "Duration" + }, + { + "fieldname": "slug", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Slug", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_8", + "fieldtype": "Section Break" + }, + { + "fieldname": "section_break_2", + "fieldtype": "Section Break" + }, + { + "fieldname": "title", + "fieldtype": "Data", + "in_list_view": 1, + "label": "title", + "reqd": 1 + }, + { + "fieldname": "course", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Course", + "options": "LMS Course", + "reqd": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [ + { + "group": "Links", + "link_doctype": "Cohort Subgroup", + "link_fieldname": "cohort" + }, + { + "group": "Links", + "link_doctype": "Cohort Student", + "link_fieldname": "cohort" + }, + { + "group": "Links", + "link_doctype": "Cohort Page", + "link_fieldname": "cohort" + } + ], + "modified": "2021-11-29 15:13:41.296384", + "modified_by": "Administrator", + "module": "LMS", + "name": "Cohort", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/school/lms/doctype/cohort/cohort.py b/school/lms/doctype/cohort/cohort.py new file mode 100644 index 00000000..bad383e3 --- /dev/null +++ b/school/lms/doctype/cohort/cohort.py @@ -0,0 +1,15 @@ +# Copyright (c) 2021, FOSS United and contributors +# For license information, please see license.txt + +import frappe +from frappe.model.document import Document + +class Cohort(Document): + def get_subgroups(self): + names = frappe.get_all("Cohort Subgroup", filters={"cohort": self.name}, pluck="name") + return [frappe.get_doc("Cohort Subgroup", name) for name in names] + + def get_subgroup(self, slug): + q = dict(cohort=self.name, slug=slug) + name = frappe.db.get_value("Cohort Subgroup", q, "name") + return name and frappe.get_doc("Cohort Subgroup", name) diff --git a/school/lms/doctype/cohort/test_cohort.py b/school/lms/doctype/cohort/test_cohort.py new file mode 100644 index 00000000..a7cf10ba --- /dev/null +++ b/school/lms/doctype/cohort/test_cohort.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and Contributors +# See license.txt + +# import frappe +import unittest + +class TestCohort(unittest.TestCase): + pass diff --git a/school/lms/doctype/cohort_join_request/__init__.py b/school/lms/doctype/cohort_join_request/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/school/lms/doctype/cohort_join_request/cohort_join_request.js b/school/lms/doctype/cohort_join_request/cohort_join_request.js new file mode 100644 index 00000000..8f6cec18 --- /dev/null +++ b/school/lms/doctype/cohort_join_request/cohort_join_request.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, FOSS United and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Cohort Join Request', { + // refresh: function(frm) { + + // } +}); diff --git a/school/lms/doctype/cohort_join_request/cohort_join_request.json b/school/lms/doctype/cohort_join_request/cohort_join_request.json new file mode 100644 index 00000000..476d05ed --- /dev/null +++ b/school/lms/doctype/cohort_join_request/cohort_join_request.json @@ -0,0 +1,71 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2021-11-19 16:27:41.716509", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "cohort", + "subgroup", + "email", + "status" + ], + "fields": [ + { + "fieldname": "cohort", + "fieldtype": "Link", + "label": "Cohort", + "options": "Cohort", + "reqd": 1 + }, + { + "fieldname": "subgroup", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Subgroup", + "options": "Cohort Subgroup", + "reqd": 1 + }, + { + "fieldname": "email", + "fieldtype": "Link", + "in_list_view": 1, + "label": "E-Mail", + "options": "User", + "reqd": 1 + }, + { + "default": "Pending", + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Status", + "options": "Pending\nAccepted\nRejected" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2021-11-29 12:18:15.947544", + "modified_by": "Administrator", + "module": "LMS", + "name": "Cohort Join Request", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/school/lms/doctype/cohort_join_request/cohort_join_request.py b/school/lms/doctype/cohort_join_request/cohort_join_request.py new file mode 100644 index 00000000..984096ab --- /dev/null +++ b/school/lms/doctype/cohort_join_request/cohort_join_request.py @@ -0,0 +1,13 @@ +# Copyright (c) 2021, FOSS United and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class CohortJoinRequest(Document): + def on_update(self): + if self.status == "Accepted": + self.ensure_student() + + def ensure_student(self): + pass diff --git a/school/lms/doctype/cohort_join_request/test_cohort_join_request.py b/school/lms/doctype/cohort_join_request/test_cohort_join_request.py new file mode 100644 index 00000000..dd386401 --- /dev/null +++ b/school/lms/doctype/cohort_join_request/test_cohort_join_request.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and Contributors +# See license.txt + +# import frappe +import unittest + +class TestCohortJoinRequest(unittest.TestCase): + pass diff --git a/school/lms/doctype/cohort_mentor/__init__.py b/school/lms/doctype/cohort_mentor/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/school/lms/doctype/cohort_mentor/cohort_mentor.js b/school/lms/doctype/cohort_mentor/cohort_mentor.js new file mode 100644 index 00000000..81f90950 --- /dev/null +++ b/school/lms/doctype/cohort_mentor/cohort_mentor.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, FOSS United and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Cohort Mentor', { + // refresh: function(frm) { + + // } +}); diff --git a/school/lms/doctype/cohort_mentor/cohort_mentor.json b/school/lms/doctype/cohort_mentor/cohort_mentor.json new file mode 100644 index 00000000..42aade7a --- /dev/null +++ b/school/lms/doctype/cohort_mentor/cohort_mentor.json @@ -0,0 +1,73 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2021-11-19 15:31:47.129156", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "cohort", + "email", + "subgroup", + "course" + ], + "fields": [ + { + "fieldname": "cohort", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Cohort", + "options": "Cohort", + "reqd": 1 + }, + { + "fieldname": "email", + "fieldtype": "Link", + "in_list_view": 1, + "label": "E-mail", + "options": "User", + "reqd": 1 + }, + { + "fieldname": "subgroup", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Primary Subgroup", + "options": "Cohort Subgroup", + "reqd": 1 + }, + { + "fetch_from": "cohort.course", + "fieldname": "course", + "fieldtype": "Link", + "label": "Course", + "options": "LMS Course", + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2021-11-29 16:32:33.235281", + "modified_by": "Administrator", + "module": "LMS", + "name": "Cohort Mentor", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/school/lms/doctype/cohort_mentor/cohort_mentor.py b/school/lms/doctype/cohort_mentor/cohort_mentor.py new file mode 100644 index 00000000..a385819c --- /dev/null +++ b/school/lms/doctype/cohort_mentor/cohort_mentor.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class CohortMentor(Document): + pass diff --git a/school/lms/doctype/cohort_mentor/test_cohort_mentor.py b/school/lms/doctype/cohort_mentor/test_cohort_mentor.py new file mode 100644 index 00000000..06be484e --- /dev/null +++ b/school/lms/doctype/cohort_mentor/test_cohort_mentor.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and Contributors +# See license.txt + +# import frappe +import unittest + +class TestCohortMentor(unittest.TestCase): + pass diff --git a/school/lms/doctype/cohort_staff/__init__.py b/school/lms/doctype/cohort_staff/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/school/lms/doctype/cohort_staff/cohort_staff.js b/school/lms/doctype/cohort_staff/cohort_staff.js new file mode 100644 index 00000000..8deaab23 --- /dev/null +++ b/school/lms/doctype/cohort_staff/cohort_staff.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, FOSS United and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Cohort Staff', { + // refresh: function(frm) { + + // } +}); diff --git a/school/lms/doctype/cohort_staff/cohort_staff.json b/school/lms/doctype/cohort_staff/cohort_staff.json new file mode 100644 index 00000000..1fd207d7 --- /dev/null +++ b/school/lms/doctype/cohort_staff/cohort_staff.json @@ -0,0 +1,72 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2021-11-19 15:35:00.551949", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "cohort", + "course", + "email", + "role" + ], + "fields": [ + { + "fieldname": "cohort", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Cohort", + "options": "Cohort", + "reqd": 1 + }, + { + "fieldname": "email", + "fieldtype": "Link", + "in_list_view": 1, + "label": "E-mail", + "options": "User", + "reqd": 1 + }, + { + "fieldname": "role", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Role", + "options": "Admin\nManager\nStaff", + "reqd": 1 + }, + { + "fetch_from": "cohort.course", + "fieldname": "course", + "fieldtype": "Link", + "label": "Course", + "options": "LMS Course", + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2021-11-29 16:31:57.214875", + "modified_by": "Administrator", + "module": "LMS", + "name": "Cohort Staff", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/school/lms/doctype/cohort_staff/cohort_staff.py b/school/lms/doctype/cohort_staff/cohort_staff.py new file mode 100644 index 00000000..6febbcc4 --- /dev/null +++ b/school/lms/doctype/cohort_staff/cohort_staff.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class CohortStaff(Document): + pass diff --git a/school/lms/doctype/cohort_staff/test_cohort_staff.py b/school/lms/doctype/cohort_staff/test_cohort_staff.py new file mode 100644 index 00000000..c27f423e --- /dev/null +++ b/school/lms/doctype/cohort_staff/test_cohort_staff.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and Contributors +# See license.txt + +# import frappe +import unittest + +class TestCohortStaff(unittest.TestCase): + pass diff --git a/school/lms/doctype/cohort_subgroup/__init__.py b/school/lms/doctype/cohort_subgroup/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/school/lms/doctype/cohort_subgroup/cohort_subgroup.js b/school/lms/doctype/cohort_subgroup/cohort_subgroup.js new file mode 100644 index 00000000..9c851cf0 --- /dev/null +++ b/school/lms/doctype/cohort_subgroup/cohort_subgroup.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, FOSS United and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Cohort Subgroup', { + // refresh: function(frm) { + + // } +}); diff --git a/school/lms/doctype/cohort_subgroup/cohort_subgroup.json b/school/lms/doctype/cohort_subgroup/cohort_subgroup.json new file mode 100644 index 00000000..2b31c98e --- /dev/null +++ b/school/lms/doctype/cohort_subgroup/cohort_subgroup.json @@ -0,0 +1,76 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "format:{title} ({cohort})", + "creation": "2021-11-19 11:50:27.312434", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "cohort", + "title", + "description", + "invite_code" + ], + "fields": [ + { + "fieldname": "cohort", + "fieldtype": "Link", + "in_list_view": 1, + "in_preview": 1, + "in_standard_filter": 1, + "label": "Cohort", + "options": "Cohort" + }, + { + "fieldname": "title", + "fieldtype": "Data", + "in_list_view": 1, + "in_preview": 1, + "in_standard_filter": 1, + "label": "title" + }, + { + "fieldname": "description", + "fieldtype": "Markdown Editor", + "label": "description" + }, + { + "fieldname": "invite_code", + "fieldtype": "Data", + "label": "invite_code", + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [ + { + "group": "Links", + "link_doctype": "Cohort Student", + "link_fieldname": "subgroup" + } + ], + "modified": "2021-11-29 16:57:51.660847", + "modified_by": "Administrator", + "module": "LMS", + "name": "Cohort Subgroup", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/school/lms/doctype/cohort_subgroup/cohort_subgroup.py b/school/lms/doctype/cohort_subgroup/cohort_subgroup.py new file mode 100644 index 00000000..2f11e079 --- /dev/null +++ b/school/lms/doctype/cohort_subgroup/cohort_subgroup.py @@ -0,0 +1,45 @@ +# Copyright (c) 2021, FOSS United and contributors +# For license information, please see license.txt + +import frappe +from frappe.model.document import Document +from frappe.utils import random_string + +class CohortSubgroup(Document): + def before_save(self): + if not self.invite_code: + self.invite_code = random_string(8) + + def get_invite_link(self): + return f"{frappe.utils.get_url()}/cohorts/{self.cohort}/join/{self.slug}/{self.invite_code}" + + def has_student(self, email): + """Check if given user is a student of this subgroup. + """ + q = { + "doctype": "Cohort Student", + "subgroup": self.name, + "email": email + } + return frappe.db.exists(q) + + def has_join_request(self, email): + """Check if given user is a student of this subgroup. + """ + q = { + "doctype": "Cohort Join Request", + "subgroup": self.name, + "email": email + } + return frappe.db.exists(q) + + def get_join_requests(self, status="Pending"): + q = { + "subgroup": self.name, + "status": status + } + return frappe.get_all("Cohort Join Request", filters=q, fields=["*"], order_by="creation") + + +#def after_doctype_insert(): +# frappe.db.add_unique("Cohort Subgroup", ("cohort", "slug")) diff --git a/school/lms/doctype/cohort_subgroup/test_cohort_subgroup.py b/school/lms/doctype/cohort_subgroup/test_cohort_subgroup.py new file mode 100644 index 00000000..8715a234 --- /dev/null +++ b/school/lms/doctype/cohort_subgroup/test_cohort_subgroup.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and Contributors +# See license.txt + +# import frappe +import unittest + +class TestCohortSubgroup(unittest.TestCase): + pass diff --git a/school/lms/doctype/lms_batch_membership/lms_batch_membership.json b/school/lms/doctype/lms_batch_membership/lms_batch_membership.json index 69720d29..8514100f 100644 --- a/school/lms/doctype/lms_batch_membership/lms_batch_membership.json +++ b/school/lms/doctype/lms_batch_membership/lms_batch_membership.json @@ -14,7 +14,9 @@ "member_type", "progress", "current_lesson", - "role" + "role", + "cohort", + "subgroup" ], "fields": [ { @@ -88,12 +90,23 @@ "fieldtype": "Data", "label": "Progress", "read_only": 1 + }, + { + "fieldname": "cohort", + "fieldtype": "Link", + "label": "Cohort", + "options": "Cohort" + }, + { + "fieldname": "subgroup", + "fieldtype": "Link", + "label": "Subgroup", + "options": "Cohort Subgroup" } ], "index_web_pages_for_search": 1, "links": [], - "migration_hash": "fe10c462acf5e727d864305d7ce90e73", - "modified": "2021-10-20 15:10:33.767419", + "modified": "2021-11-29 15:22:31.609216", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch Membership",