Merge pull request #606 from pateljannat/instructor-notes
feat: instructor notes
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
"column_break_15",
|
||||
"file_type",
|
||||
"section_break_11",
|
||||
"instructor_notes",
|
||||
"body",
|
||||
"help_section",
|
||||
"help"
|
||||
@@ -131,11 +132,16 @@
|
||||
{
|
||||
"fieldname": "column_break_15",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "instructor_notes",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Instructor Notes"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-05-02 12:42:16.926753",
|
||||
"modified": "2023-08-31 11:11:22.034553",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Course Lesson",
|
||||
|
||||
@@ -281,6 +281,7 @@ def save_lesson(
|
||||
preview,
|
||||
idx,
|
||||
lesson,
|
||||
instructor_notes=None,
|
||||
youtube=None,
|
||||
quiz_id=None,
|
||||
question=None,
|
||||
@@ -296,6 +297,7 @@ def save_lesson(
|
||||
"chapter": chapter,
|
||||
"title": title,
|
||||
"body": body,
|
||||
"instructor_notes": instructor_notes,
|
||||
"include_in_preview": preview,
|
||||
"youtube": youtube,
|
||||
"quiz_id": quiz_id,
|
||||
|
||||
@@ -141,6 +141,7 @@ def get_lesson_details(chapter):
|
||||
"quiz_id",
|
||||
"question",
|
||||
"file_type",
|
||||
"instructor_notes",
|
||||
],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
@@ -66,13 +66,8 @@
|
||||
{% macro CreateLesson() %}
|
||||
<article class="field-parent">
|
||||
<div class="field-group">
|
||||
<div>
|
||||
<div class="field-label">
|
||||
{{ _("Title") }}
|
||||
</div>
|
||||
<div class="field-description">
|
||||
{{ _("Something Short and Concise") }}
|
||||
</div>
|
||||
<div class="field-label">
|
||||
{{ _("Title") }}
|
||||
</div>
|
||||
<div class="">
|
||||
<input id="lesson-title" type="text" class="field-input" data-index="{{ lesson_index }}" data-chapter="{{ chapter }}" data-course="{{ course.name }}" {% if lesson.name %} data-lesson="{{ lesson.name }}" value="{{ lesson.title }}" {% endif %}>
|
||||
@@ -86,6 +81,19 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="field-group">
|
||||
<div class="field-label">
|
||||
{{ _("Instructor Notes") }}
|
||||
</div>
|
||||
<div class="field-description">
|
||||
{{ _("These notes will only be visible to the Course Creator, Course Evaluaor and Moderator.") }}
|
||||
</div>
|
||||
<div id="instructor-notes"></div>
|
||||
{% if lesson.instructor_notes %}
|
||||
<div id="current-instructor-notes" class="hide">{{ lesson.instructor_notes }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="field-group">
|
||||
<div>
|
||||
<div class="field-label">
|
||||
@@ -117,7 +125,6 @@
|
||||
};
|
||||
</script>
|
||||
{% endif %}
|
||||
{{ include_script('controls.bundle.js') }}
|
||||
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@editorjs/paragraph@latest"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@editorjs/header@latest"></script>
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
frappe.ready(() => {
|
||||
frappe.telemetry.capture("on_lesson_creation_page", "lms");
|
||||
let self = this;
|
||||
this.quiz_in_lesson = [];
|
||||
|
||||
frappe.telemetry.capture("on_lesson_creation_page", "lms");
|
||||
|
||||
if ($("#instructor-notes").length) {
|
||||
frappe.require("controls.bundle.js", () => {
|
||||
make_instructor_notes_component();
|
||||
});
|
||||
}
|
||||
|
||||
if ($("#current-lesson-content").length) {
|
||||
parse_string_to_lesson();
|
||||
}
|
||||
@@ -149,6 +157,8 @@ const save = (lesson_content) => {
|
||||
preview: $("#preview").prop("checked") ? 1 : 0,
|
||||
idx: $("#lesson-title").data("index"),
|
||||
lesson: lesson ? lesson : "",
|
||||
instructor_notes:
|
||||
this.instructor_notes.get_values().instructor_notes,
|
||||
},
|
||||
callback: (data) => {
|
||||
frappe.show_alert({
|
||||
@@ -466,3 +476,20 @@ class Upload {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const make_instructor_notes_component = () => {
|
||||
this.instructor_notes = new frappe.ui.FieldGroup({
|
||||
fields: [
|
||||
{
|
||||
fieldname: "instructor_notes",
|
||||
fieldtype: "Text Editor",
|
||||
default: $("#current-instructor-notes").html(),
|
||||
},
|
||||
],
|
||||
body: $("#instructor-notes").get(0),
|
||||
});
|
||||
this.instructor_notes.make();
|
||||
$("#instructor-notes .form-section:last").removeClass("empty-section");
|
||||
$("#instructor-notes .frappe-control").removeClass("hide-control");
|
||||
$("#instructor-notes .form-column").addClass("p-0");
|
||||
};
|
||||
|
||||
@@ -149,17 +149,28 @@
|
||||
{% if show_lesson %}
|
||||
|
||||
{% if is_instructor and not lesson.include_in_preview %}
|
||||
<div class="medium alert alert-info alert-dismissible mb-4">
|
||||
<div class="alert alert-info alert-dismissible mb-4">
|
||||
{{ _("This lesson is not available for preview. As you are the Instructor of the course only you can see it.") }}
|
||||
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if lesson.instructor_notes and (is_moderator or instructor or is_evaluator) %}
|
||||
<div class="alert alert-info mb-4">
|
||||
<div class="bold-heading">
|
||||
{{ _("Instructor Notes") }}
|
||||
</div>
|
||||
<div>
|
||||
{{ lesson.instructor_notes }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{{ render_html(lesson) }}
|
||||
|
||||
{% else %}
|
||||
{% set course_link = "<a class='enroll-in-course' data-course=" + course.name | urlencode + " href=''>" + _('here') + "</a>" %}
|
||||
<div class="alert alert-info medium mb-0">
|
||||
<div class="alert alert-info mb-0">
|
||||
{{ _("There is no preview available for this lesson.
|
||||
Please join the course to access it.
|
||||
Click {0} to enroll.").format(course_link) }}
|
||||
|
||||
@@ -2,7 +2,12 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import cstr, flt
|
||||
|
||||
from lms.lms.utils import get_lesson_url, has_course_moderator_role, is_instructor
|
||||
from lms.lms.utils import (
|
||||
get_lesson_url,
|
||||
has_course_moderator_role,
|
||||
is_instructor,
|
||||
has_course_evaluator_role,
|
||||
)
|
||||
from lms.www.utils import (
|
||||
get_common_context,
|
||||
redirect_to_lesson,
|
||||
@@ -37,20 +42,23 @@ def get_context(context):
|
||||
redirect_to_lesson(context.course, index_)
|
||||
|
||||
context.lesson = get_current_lesson_details(lesson_number, context)
|
||||
instructor = is_instructor(context.course.name)
|
||||
context.instructor = is_instructor(context.course.name)
|
||||
context.is_moderator = has_course_moderator_role()
|
||||
context.is_evaluator = has_course_evaluator_role()
|
||||
|
||||
context.show_lesson = (
|
||||
context.membership
|
||||
or (context.lesson and context.lesson.include_in_preview)
|
||||
or instructor
|
||||
or has_course_moderator_role()
|
||||
or context.instructor
|
||||
or context.is_moderator
|
||||
or context.is_evaluator
|
||||
)
|
||||
|
||||
if not context.lesson:
|
||||
context.lesson = frappe._dict()
|
||||
|
||||
if frappe.form_dict.get("edit"):
|
||||
if not instructor and not has_course_moderator_role():
|
||||
if not context.instructor and not context.is_moderator:
|
||||
raise frappe.PermissionError(_("You do not have permission to access this page."))
|
||||
context.lesson.edit_mode = True
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user