feat: allow moderators to edit course
This commit is contained in:
@@ -193,7 +193,8 @@ jinja = {
|
||||
"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"
|
||||
"lms.lms.utils.has_course_instructor_role",
|
||||
"lms.lms.utils.has_course_moderator_role"
|
||||
],
|
||||
"filters": []
|
||||
}
|
||||
|
||||
@@ -450,5 +450,8 @@ def has_course_moderator_role():
|
||||
|
||||
|
||||
def get_courses_under_review():
|
||||
return "jan"
|
||||
return frappe.get_all("LMS Course", {
|
||||
"status": "Under Review"
|
||||
}, ["name", "upcoming", "title", "image", "enable_certification", "status", "published"]
|
||||
)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="common-card-style course-card" data-course="{{ course.name }}">
|
||||
|
||||
<div class="course-image {% if not course.image %}default-image{% endif %}" {% if course.image %}
|
||||
style="background-image: url( {{ course.image }} );" {% endif %}>
|
||||
style="background-image: url( {{ course.image | urlencode }} );" {% endif %}>
|
||||
<div class="course-tags">
|
||||
{% for tag in get_tags(course.name) %}
|
||||
<div class="course-card-pills">{{ tag }}</div>
|
||||
|
||||
@@ -185,3 +185,6 @@ const show_no_preview_dialog = (e) => {
|
||||
};
|
||||
|
||||
</script>
|
||||
dahanukar
|
||||
sandesh
|
||||
chetna
|
||||
|
||||
@@ -542,10 +542,6 @@ const build_attachment_table = (file_doc) => {
|
||||
|
||||
|
||||
const make_editor = () => {
|
||||
let comment = `<!--
|
||||
{{ YouTubeVideo('Video Id') }}
|
||||
{{ Quiz('Quiz Id') }}
|
||||
-->`
|
||||
|
||||
this.code_field_group = new frappe.ui.FieldGroup({
|
||||
fields: [
|
||||
@@ -556,7 +552,7 @@ const make_editor = () => {
|
||||
wrap: true,
|
||||
max_lines: Infinity,
|
||||
min_lines: 20,
|
||||
default: $("#body").data("body") || comment,
|
||||
default: $("#body").data("body"),
|
||||
depends_on: 'eval:doc.type=="Markdown"',
|
||||
}
|
||||
],
|
||||
|
||||
@@ -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) or has_course_moderator_role():
|
||||
if not is_instructor(context.course.name) and not has_course_moderator_role():
|
||||
redirect_to_courses_list()
|
||||
context.lesson.edit_mode = True
|
||||
else:
|
||||
|
||||
@@ -270,7 +270,7 @@
|
||||
membership.current_lesson else "1.1" if first_lesson_exists(course.name) else None %}
|
||||
|
||||
{% if show_start_learing_cta %}
|
||||
<div class="btn btn-primary wide-button join-batch" data-course="{{ course.name | urlencode }}">
|
||||
<div class="btn btn-primary wide-button join-batch mb-2" data-course="{{ course.name | urlencode }}">
|
||||
{{ _("Start Learning") }}
|
||||
<img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
|
||||
</div>
|
||||
@@ -323,7 +323,7 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_instructor(course.name) %}
|
||||
{% if is_instructor(course.name) or has_course_moderator_role() %}
|
||||
<a class="btn btn-secondary wide-button" href="/courses/{{ course.name }}?edit=1"> {{ _("Edit Course") }} </a>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
@@ -341,9 +341,9 @@
|
||||
frappe.utils.format_time(certificate_request.start_time, "short")) }} </p>
|
||||
{% endif %}
|
||||
|
||||
{% if course.status == "Under Review" %}
|
||||
{% if course.status == "Under Review" and is_instructor(course.name) %}
|
||||
<div class="mb-4">
|
||||
{{ _("Your course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }}
|
||||
{{ _("This course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ const submit_for_review = (e) => {
|
||||
}, 3);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 3000);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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) or not has_course_moderator_role():
|
||||
if not is_instructor(course.name) and not has_course_moderator_role():
|
||||
redirect_to_courses_list()
|
||||
course.edit_mode = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user