feat: course moderator
This commit is contained in:
@@ -192,6 +192,7 @@ jinja = {
|
||||
"lms.lms.utils.get_popular_courses",
|
||||
"lms.lms.utils.format_amount",
|
||||
"lms.lms.utils.first_lesson_exists",
|
||||
"lms.lms.utils.get_courses_under_review",
|
||||
"lms.lms.utils.has_course_instructor_role"
|
||||
],
|
||||
"filters": []
|
||||
|
||||
@@ -440,3 +440,15 @@ def has_course_instructor_role():
|
||||
"parent": frappe.session.user,
|
||||
"role": "Course Instructor"
|
||||
}, "name")
|
||||
|
||||
|
||||
def has_course_moderator_role():
|
||||
return frappe.db.get_value("Has Role", {
|
||||
"parent": frappe.session.user,
|
||||
"role": "Course Moderator"
|
||||
}, "name")
|
||||
|
||||
|
||||
def get_courses_under_review():
|
||||
return "jan"
|
||||
|
||||
|
||||
@@ -31,3 +31,4 @@ lms.patches.v0_0.quiz_submission_member
|
||||
lms.patches.v0_0.delete_old_module_docs #08-07-2022
|
||||
lms.patches.v0_0.delete_course_web_forms #21-08-2022
|
||||
lms.patches.v0_0.create_course_instructor_role #29-08-2022
|
||||
lms.patches.v0_0.create_course_moderator_role
|
||||
|
||||
11
lms/patches/v0_0/create_course_moderator_role.py
Normal file
11
lms/patches/v0_0/create_course_moderator_role.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
if not frappe.db.exists("Role", "Course Moderator"):
|
||||
role = frappe.get_doc({
|
||||
"doctype": "Role",
|
||||
"role_name": "Course Moderator",
|
||||
"home_page": "/dashboard",
|
||||
"desk_access": 0
|
||||
})
|
||||
role.save(ignore_permissions=True)
|
||||
20
lms/templates/courses_under_review.html
Normal file
20
lms/templates/courses_under_review.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{% set courses = get_courses_under_review() %}
|
||||
|
||||
{% if courses | length %}
|
||||
<div class="cards-parent">
|
||||
{% for course in courses %}
|
||||
{{ widgets.CourseCard(course=course) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div>
|
||||
<img class="icon icon-xl" src="/assets/lms/icons/comment.svg">
|
||||
</div>
|
||||
<div class="empty-state-text">
|
||||
<div class="empty-state-heading">{{ _("No courses created") }}</div>
|
||||
<div class="course-meta">{{ _("Help others learn something new.") }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -1,6 +1,6 @@
|
||||
import frappe
|
||||
from lms.www.utils import get_common_context, redirect_to_lesson
|
||||
from lms.lms.utils import get_lesson_url, is_instructor, redirect_to_courses_list
|
||||
from lms.lms.utils import get_lesson_url, has_course_moderator_role, is_instructor, redirect_to_courses_list
|
||||
from frappe.utils import cstr, flt
|
||||
|
||||
def get_context(context):
|
||||
@@ -27,7 +27,7 @@ def get_context(context):
|
||||
context.lesson = frappe._dict()
|
||||
|
||||
if frappe.form_dict.get("edit"):
|
||||
if not is_instructor(context.course.name):
|
||||
if not is_instructor(context.course.name) or has_course_moderator_role():
|
||||
redirect_to_courses_list()
|
||||
context.lesson.edit_mode = True
|
||||
else:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import frappe
|
||||
from lms.lms.doctype.lms_settings.lms_settings import check_profile_restriction
|
||||
from lms.lms.utils import get_membership, is_instructor, is_certified, get_evaluation_details, redirect_to_courses_list
|
||||
from lms.lms.utils import get_membership, has_course_moderator_role, is_instructor, is_certified, get_evaluation_details, redirect_to_courses_list
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
@@ -28,7 +28,7 @@ def set_course_context(context, course_name):
|
||||
as_dict=True)
|
||||
|
||||
if frappe.form_dict.get("edit"):
|
||||
if not is_instructor(course.name):
|
||||
if not is_instructor(course.name) or not has_course_moderator_role():
|
||||
redirect_to_courses_list()
|
||||
course.edit_mode = True
|
||||
|
||||
|
||||
@@ -16,12 +16,23 @@
|
||||
|
||||
<ul class="nav" id="courses-tab">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#courses-enrolled"> {{ _("Courses Enrolled") }} </a>
|
||||
<a class="nav-link active" data-toggle="tab" href="#courses-enrolled">
|
||||
{{ _("Courses Enrolled") }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if show_creators_section %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-created">{{ _("Courses Created") }}
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-created">
|
||||
{{ _("Courses Created") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if show_review_section %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-under-review">
|
||||
{{ _("Courses Under Review") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
@@ -39,8 +50,14 @@
|
||||
{% include "lms/templates/courses_created.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if show_review_section %}
|
||||
<div class="tab-pane fade" id="courses-under-review" role="tabpanel" aria-labelledby="courses-under-review">
|
||||
{% include "lms/templates/courses_under_review.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import frappe
|
||||
from lms.lms.utils import has_course_instructor_role
|
||||
from lms.lms.utils import has_course_instructor_role, has_course_moderator_role
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation")
|
||||
context.show_creators_section = portal_course_creation == "Anyone" or has_course_instructor_role()
|
||||
context.show_review_section = has_course_moderator_role()
|
||||
|
||||
Reference in New Issue
Block a user