feat: course settings from website
This commit is contained in:
@@ -194,7 +194,7 @@ def submit_for_review(course):
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def save_course(tags, title, short_introduction, video_link, description, course, image=None):
|
||||
def save_course(tags, title, short_introduction, video_link, description, course, published, upcoming, image=None):
|
||||
if course:
|
||||
doc = frappe.get_doc("LMS Course", course)
|
||||
else:
|
||||
@@ -208,7 +208,9 @@ def save_course(tags, title, short_introduction, video_link, description, course
|
||||
"video_link": video_link,
|
||||
"image": image,
|
||||
"description": description,
|
||||
"tags": tags
|
||||
"tags": tags,
|
||||
"published": published,
|
||||
"upcoming": upcoming
|
||||
})
|
||||
doc.save(ignore_permissions=True)
|
||||
return doc.name
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
{% set active = membership.current_lesson == lesson.name %}
|
||||
<div class="lesson-info {% if active and not course.edit_mode %} active-lesson {% endif %}">
|
||||
|
||||
{% if membership or lesson.include_in_preview or is_instructor %}
|
||||
{% if membership or lesson.include_in_preview or is_instructor or has_course_moderator_role() %}
|
||||
<a class="lesson-links" data-course="{{ course.name }}"
|
||||
{% if is_instructor and not lesson.include_in_preview %}
|
||||
title="{{ _('This lesson is not available for preview. As you are the Instructor of the course only you can see it.') }}"
|
||||
@@ -185,6 +185,4 @@ const show_no_preview_dialog = (e) => {
|
||||
};
|
||||
|
||||
</script>
|
||||
dahanukar
|
||||
sandesh
|
||||
chetna
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ input[type=checkbox] {
|
||||
|
||||
.common-page-style {
|
||||
padding: 2rem 0 5rem;
|
||||
min-height: 60vh;
|
||||
padding-top: 3rem;
|
||||
background-color: var(--bg-color);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
{% macro LessonContent(lesson) %}
|
||||
{% set instructors = get_instructors(course.name) %}
|
||||
{% set is_instructor = is_instructor(course.name) %}
|
||||
|
||||
<div class="common-card-style lesson-content">
|
||||
<div class="lesson-title">
|
||||
|
||||
@@ -70,7 +71,7 @@
|
||||
<span class="indicator-pill green {{ hide if get_progress(course.name, lesson.name) != 'Complete' else ''}}">{{ _("COMPLETED") }}</span>
|
||||
|
||||
<!-- Edit Button -->
|
||||
{% if is_instructor and not lesson.edit_mode %}
|
||||
{% if (is_instructor or has_course_moderator_role()) and not lesson.edit_mode %}
|
||||
<button class="button is-default button-links ml-auto btn-edit"> {{ _("Edit") }} </button>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -105,7 +106,7 @@
|
||||
|
||||
<!-- Lesson Content -->
|
||||
<div class="markdown-source lesson-content-card {% if lesson.edit_mode %} mb-0 mt-2 {% endif %} ">
|
||||
{% if membership or lesson.include_in_preview or is_instructor %}
|
||||
{% if show_lesson %}
|
||||
|
||||
{% if is_instructor and not lesson.include_in_preview and not lesson.edit_mode %}
|
||||
<div class="small alert alert-secondary alert-dismissible mb-4">
|
||||
@@ -190,9 +191,9 @@
|
||||
<div class="medium mb-4" contenteditable="true" data-placeholder="{{ _('Quiz ID') }}"
|
||||
id="quiz-id">{% if lesson.quiz_id %}{{ lesson.quiz_id }}{% endif %}</div>
|
||||
|
||||
<label class="preview">
|
||||
<input {% if lesson.include_in_preview %} checked {% endif %} type="checkbox"
|
||||
id="preview"> {{ _("Show preview of this lesson to Guest users.") }}
|
||||
<label class="preview" for="preview">
|
||||
<input {% if lesson.include_in_preview %} checked {% endif %} type="checkbox" id="preview">
|
||||
{{ _("Show preview of this lesson to Guest users.") }}
|
||||
</label>
|
||||
|
||||
<div class="mt-4">
|
||||
|
||||
@@ -23,11 +23,14 @@ 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.show_lesson = context.membership or context.lesson.include_in_preview or instructor or has_course_moderator_role()
|
||||
|
||||
if not context.lesson:
|
||||
context.lesson = frappe._dict()
|
||||
|
||||
if frappe.form_dict.get("edit"):
|
||||
if not is_instructor(context.course.name) and not has_course_moderator_role():
|
||||
if not instructor and not has_course_moderator_role():
|
||||
redirect_to_courses_list()
|
||||
context.lesson.edit_mode = True
|
||||
else:
|
||||
|
||||
@@ -55,8 +55,10 @@
|
||||
<div contenteditable="true" data-placeholder="{{ _('Explain the option') }}"
|
||||
class="option-input">{% if explanation %}{{ explanation }}{% endif %}</div>
|
||||
<div class="option-checkbox">
|
||||
<input type="checkbox" {% if question['is_correct_' + num] %} checked {% endif %}>
|
||||
<label class="mb-0"> {{ _("Is Correct") }} </label>
|
||||
<label class="mb-0">
|
||||
<input type="checkbox" {% if question['is_correct_' + num] %} checked {% endif %}>
|
||||
{{ _("Is Correct") }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<div class="container">
|
||||
<div class="course-body-container">
|
||||
{{ CourseHeaderOverlay(course) }}
|
||||
{{ CourseSettings(course) }}
|
||||
{{ Description(course) }}
|
||||
{{ Save(course) }}
|
||||
{{ widgets.CourseOutline(course=course, membership=membership, is_user_interested=is_user_interested) }}
|
||||
@@ -210,6 +211,25 @@
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
<!-- Course Settings -->
|
||||
{% macro CourseSettings(course) %}
|
||||
|
||||
{% if has_course_moderator_role() %}
|
||||
<div class="mb-4">
|
||||
<label for="published" class="mb-0">
|
||||
<input type="checkbox" id="published" {% if course.published %} checked {% endif %}>
|
||||
{{ _("Published") }}
|
||||
</label>
|
||||
<label for="upcoming" class="mb-0 ml-20">
|
||||
<input type="checkbox" id="upcoming" {% if course.upcoming %} checked {% endif %}>
|
||||
{{ _("Upcoming") }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
<!-- Save -->
|
||||
{% macro Save(course) %}
|
||||
{% if course.edit_mode %}
|
||||
|
||||
@@ -339,7 +339,9 @@ const save_course = (e) => {
|
||||
"video_link": $("#video-link").text(),
|
||||
"image": $("#image").attr("href"),
|
||||
"description": $("#description").text(),
|
||||
"course": $("#title").data("course") ? $("#title").data("course") : ""
|
||||
"course": $("#title").data("course") ? $("#title").data("course") : "",
|
||||
"published": $("#published").prop("checked") ? 1 : 0,
|
||||
"upcoming": $("#upcoming").prop("checked") ? 1 : 0
|
||||
},
|
||||
callback: (data) => {
|
||||
frappe.show_alert({
|
||||
|
||||
Reference in New Issue
Block a user