fix: ux issues

This commit is contained in:
Jannat Patel
2022-08-26 16:35:02 +05:30
parent 4499b34b51
commit 7d697f068f
7 changed files with 380 additions and 270 deletions

View File

@@ -6,99 +6,124 @@ frappe.ui.form.on('Course Lesson', {
frm.trigger('setup_help'); frm.trigger('setup_help');
}, },
setup_help(frm) { setup_help(frm) {
let quiz_link = `<a href="/app/lms-quiz"> ${__("Quiz List")} </a>`;
let exercise_link = `<a href="/app/exercise"> ${__("Exercise List")} </a>`;
let file_link = `<a href="/app/file"> ${__("File DocType")} </a>`;
frm.get_field('help').html(` frm.get_field('help').html(`
<p>${__("You can add some more additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.")}</p> <p>${__("You can add some more additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.")}</p>
<div class="row font-weight-bold mb-3"> <table class="table">
<div class="col-sm-8"> <tr style="background-color: var(--fg-hover-color); font-weight: bold">
${__("Content Type")} <th style="width: 20%;">
</div> ${__("Content Type")}
<div class="col-sm-4"> </th>
${__("Syntax")} <th style="width: 40%;">
</div> ${__("Syntax")}
</div> </th>
<th>
<div class="row mb-3"> ${__("Description")}
<div class="col-sm-8"> </th>
${__("Video")} </tr>
</div> <tr>
<div class="col-sm-4"> <td>
{{ Video("url_of_source") }} ${__("YouTube Video")}
</div> </td>
</div> <td>
{{ YouTubeVideo("unique_embed_id") }}
<div class="row mb-3"> </td>
<div class="col-sm-8"> <td>
${__("YouTube Video")} <span>
</div> ${ __("Copy and paste the syntax in the editor. Replace 'embed_src' with the embed source that YouTube provides. To get the source, follow the steps mentioned below.") }
<div class="col-sm-4"> </span>
{{ YouTubeVideo("unique_embed_id") }} <ul class="p-4">
</div> <li>
</div> ${ __("Upload the video on youtube.") }
</li>
<div class="row mb-3"> <li>
<div class="col-sm-8"> ${ __("When you share a youtube video, it shows an option called Embed.") }
${"Exercise"} </li>
</div> <li>
<div class="col-sm-4"> ${ __("On clicking it, it provides an iframe. Copy the source (src) of the iframe and paste it here.") }
{{ Exercise("exercise_name") }} </li>
</div> </ul>
</div> </td>
</tr>
<div class="row mb-3"> <tr>
<div class="col-sm-8"> <td>
${__("Quiz")} ${__("Quiz")}
</div> </td>
<div class="col-sm-4"> <td>
{{ Quiz("lms_quiz_name") }} {{ Quiz("lms_quiz_id") }}
</div> </td>
</div> <td>
${ __("Copy and paste the syntax in the editor. Replace 'lms_quiz_id' with the ID of the Quiz you want to add. You can get the ID of the quiz from the {0}.", [quiz_link]) }
<div class="row mb-3"> </td>
<div class="col-sm-8"> </tr>
${__("Assignment")} <tr>
</div> <td>
<div class="col-sm-4"> ${__("Video")}
{{ Assignment("id-filetype") }} </td>
</div> <td>
</div> {{ Video("url_of_source") }}
</td>
<td>
${ __("Upload a video from your local machine to the {0}. Copy and paste this syntax in the editor. Replace 'url_of_source' with the File URL field of the document you created in the File DocType.", [file_link]) }
</td>
</tr>
<tr>
<td>
${"Exercise"}
</td>
<td>
{{ Exercise("exercise_id") }}
</td>
<td>
${ __("Copy and paste the syntax in the editor. Replace 'exercise_id' with the ID of the Exercise you want to add. You can get the ID of the exercise from the {0}.", [exercise_link]) }
</td>
</tr>
<tr>
<td>
${__("Assignment")}
</td>
<td>
{{ Assignment("id-filetype") }}
</td>
</tr>
</table>
<hr> <hr>
<table class="table">
<div class="row font-weight-bold mb-3"> <tr style="background-color: var(--fg-hover-color); font-weight: bold">
<div class="col-sm-8"> <th style="width: 90%">
${__("Supported File Types for Assignment")} ${__("Supported File Types for Assignment")}
</div> </th>
<div class="col-sm-4"> <th>
${__("Syntax")} ${__("Syntax")}
</div> </th>
</div> </tr>
<tr>
<div class="row mb-3"> <td>
<div class="col-sm-8"> .doc, .docx, .xml
.doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document <td>
</div> ${__("Document")}
<div class="col-sm-4"> </td>
${__("Document")} </tr>
</div> <tr>
</div> <td>
.pdf
<div class="row mb-3"> </td>
<div class="col-sm-8"> <td>
.pdf ${__("PDF")}
</div> </td>
<div class="col-sm-4"> </tr>
${__("PDF")} <tr>
</div> <td>
</div> .png, .jpg, .jpeg
</td>
<div class="row mb-3"> <td>
<div class="col-sm-8"> ${__("Image")}
.png, .jpg, .jpeg </td>
</div> </tr>
<div class="col-sm-4"> </table>
${__("Image")}
</div>
</div>
`); `);
} }
}); });

View File

@@ -1630,3 +1630,34 @@ li {
top: 0; top: 0;
right: -30px; right: -30px;
} }
.tool-tip {
position: relative;
display: inline-block;
}
.tool-tip .tooltiptext {
visibility: hidden;
width: 30rem;
background-color: var(--gray-800);
color: var(--fg-color);
padding: 1rem;
border-radius: var(--border-radius-md);
position: absolute;
z-index: 1;
opacity: 0;
transition: opacity 0.3s;
}
.tool-tip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
.tooltiptext ul {
padding: 1rem;
}
.help-article {
font-size: var(--text-base);
}

View File

@@ -133,6 +133,7 @@ const scroll_to_chapter_container = () => {
const save_chapter = (e) => { const save_chapter = (e) => {
let target = $(e.currentTarget); let target = $(e.currentTarget);
let parent = target.closest(".chapter-parent"); let parent = target.closest(".chapter-parent");
frappe.call({ frappe.call({
method: "lms.lms.doctype.lms_course.lms_course.save_chapter", method: "lms.lms.doctype.lms_course.lms_course.save_chapter",
args: { args: {
@@ -143,7 +144,13 @@ const save_chapter = (e) => {
"chapter": target.data("chapter") ? target.data("chapter") : "" "chapter": target.data("chapter") ? target.data("chapter") : ""
}, },
callback: (data) => { callback: (data) => {
window.location.reload(); frappe.show_alert({
message: __("Saved"),
indicator: "green",
});
setTimeout(() => {
window.location.reload();
}, 1000)
} }
}); });
}; };

View File

@@ -163,7 +163,7 @@
{% endif %} {% endif %}
<div> <div>
<a class="btn btn-primary next {% if membership.progress|int == 100 and not next_url %} hide {% endif %}" <a class="btn btn-primary next {% if not next_url and (membership.progress|int == 100 or is_instructor) %} hide {% endif %}"
{% if next_url %} data-href="{{ next_url }}" {% endif %} href=""> {% if next_url %} data-href="{{ next_url }}" {% endif %} href="">
{% if next_url %} {{ _("Next") }} {% else %} {{ _("Mark as Complete") }} {% endif %} {% if next_url %} {{ _("Next") }} {% else %} {{ _("Mark as Complete") }} {% endif %}
<img class="ml-2" src="/assets/lms/icons/side-arrow-white.svg"> <img class="ml-2" src="/assets/lms/icons/side-arrow-white.svg">
@@ -187,8 +187,8 @@
<button class="btn btn-primary btn-sm btn-lesson pull-right ml-2"> {{ _("Save") }} </button> <button class="btn btn-primary btn-sm btn-lesson pull-right ml-2"> {{ _("Save") }} </button>
{% if lesson.name %} {% if lesson.name %}
<button class="btn btn-secondary btn-sm pull-right btn-back ml-2"> {{ _("Back to Lesson") }} </button> <button class="btn btn-secondary btn-sm pull-right btn-back ml-2"> {{ _("Back to Lesson") }} </button>
<a class="btn btn-secondary btn-sm pull-right" href="/quizzes"> {{ _("Create Quiz") }} </a>
{% endif %} {% endif %}
<a class="btn btn-secondary btn-sm pull-right" href="/quizzes"> {{ _("Create a Quiz") }} </a>
<div class="attachments-parent"> <div class="attachments-parent">
<div class="attachment-controls"> <div class="attachment-controls">
@@ -217,32 +217,42 @@
<!-- Help Article --> <!-- Help Article -->
{% macro HelpArticle() %} {% macro HelpArticle() %}
<div> <div class="help-article">
<h3> {{ _("Help Article") }} </h3> <h3> {{ _("Help Article") }} </h3>
<p> <p>
{{ _("You can add additional content to the lesson using a special syntax.The table below {{ _("You can add additional content to the lesson using a special syntax. The table below mentions
mentions all types of dynamic content that you can add to the lessons and the syntax for the all types of dynamic content that you can add to the lessons and the syntax for the same.") }}
same.") }}
</p> </p>
<table class="table w-100"> <table class="table w-100">
<tr> <tr>
<th class="w-50"> {{ _("Content Type") }} </th> <th style="width: 20%;"> {{ _("Content Type") }} </th>
<th> {{ _("Syntax") }} </th> <th style="width: 40%;"> {{ _("Syntax") }} </th>
</tr> <th> {{ _("Description") }} </th>
<tr>
<td>
{{ _("Video") }}
</td>
<td>
{% raw %} {{ Video("url_of_source") }} {% endraw %}
</td>
</tr> </tr>
<tr> <tr>
<td> <td>
{{ _("YouTube Video") }} {{ _("YouTube Video") }}
</td> </td>
<td> <td>
{% raw %} {{ YouTubeVideo("unique_embed_id") }} {% endraw %} {% raw %} {{ YouTubeVideo("embed_src") }} {% endraw %}
</td>
<td>
<span>
{{ _("Copy and paste the syntax in the editor. Replace 'embed_src' with the embed source
that YouTube provides. To get the source, follow the steps mentioned below.") }}
</span>
<ul class="p-4">
<li>
{{ _("Upload the video on youtube.") }}
</li>
<li>
{{ _("When you share a youtube video, it shows an option called Embed.") }}
</li>
<li>
{{ _("On clicking it, it provides an iframe. Copy the source (src) of the iframe and
paste it here.") }}
</li>
</ul>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -250,7 +260,11 @@
{{ _("Quiz") }} {{ _("Quiz") }}
</td> </td>
<td> <td>
{% raw %} {{ Quiz("lms_quiz_name") }} {% endraw %} {% raw %} {{ Quiz("lms_quiz_id") }} {% endraw %}
</td>
<td>
{% set quiz_link = "<a href='/quizzes'> Quiz List </a>" %}
{{ _("Copy and paste the syntax in the editor. Replace 'lms_quiz_id' with the ID of the Quiz. You can get the ID of the quiz from the {0}.").format(quiz_link) }}
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -507,7 +507,7 @@ const show_upload_modal = () => {
new frappe.ui.FileUploader({ new frappe.ui.FileUploader({
folder: "Home/Attachments", folder: "Home/Attachments",
restrictions: { restrictions: {
allowed_file_types: ['image/*'] allowed_file_types: ['image/*', 'video/*']
}, },
on_success: (file_doc) => { on_success: (file_doc) => {
$(".attachments").append(build_attachment_table(file_doc)); $(".attachments").append(build_attachment_table(file_doc));
@@ -521,11 +521,19 @@ const show_upload_modal = () => {
const build_attachment_table = (file_doc) => { const build_attachment_table = (file_doc) => {
let video_types = ["mov", "mp4", "mkv"];
let video_extension = file_doc.file_url.split(".").pop();
let is_video = video_types.indexOf(video_extension) >= 0;
let link = is_video ? `{{ Video('${file_doc.file_url}') }}` : `![](${file_doc.file_url})`;
return $(` return $(`
<tr class="attachment-row"> <tr class="attachment-row">
<td>${file_doc.file_name}</td> <td>${file_doc.file_name}</td>
<td class=""><a class="button is-secondary button-links copy-link" data-link="![](${file_doc.file_url})" <td class="">
data-name="${file_doc.file_name}" > ${__("Copy Link")} </a></td> <a class="button is-secondary button-links copy-link" data-link="${link}"
data-name="${file_doc.file_name}" > ${__("Copy Link")}
</a>
</td>
</tr> </tr>
`); `);
}; };

View File

@@ -56,209 +56,226 @@
<!-- Course Card --> <!-- Course Card -->
{% macro CourseCardWide(course) %} {% macro CourseCardWide(course) %}
<div class="d-flex align-items-center mt-8">
<div class="d-flex align-items-center mt-8"> {% for tag in get_tags(course.name) %}
{% for tag in get_tags(course.name) %} <div class="course-card-pills" {% if course.edit_mode %} contenteditable="true" {% endif %}>{{ tag }}
<div class="course-card-pills" {% if course.edit_mode %} contenteditable="true" {% endif %}>{{ tag }} {% if course.edit_mode %}
<span class="btn-delete-tag">
<svg class="icon icon-sm">
<use class="" href="#icon-close"></use>
</svg>
</span>
{% endif %}
</div>
{% endfor %}
{% if course.edit_mode %} {% if course.edit_mode %}
<span class="btn-delete-tag"> <button class="btn btn-default btn-sm btn-tag"> {{ _("Add Tag") }} </button>
<svg class="icon icon-sm">
<use class="" href="#icon-close"></use>
</svg>
</span>
{% endif %} {% endif %}
</div> </div>
{% endfor %}
<div {% if course.edit_mode %} data-placeholder="{{ _('Title') }}" contenteditable="true" {% endif %}
id="title" {% if course.name %} data-course="{{ course.name | urlencode }}" {% endif %}
class="course-card-wide-title">{% if course.title %} {{ course.title }} {% endif %}</div>
<div {% if course.edit_mode %} contenteditable="true" data-placeholder="{{ _('Short Introduction') }}"
{% endif %} id="intro" >{% if course.short_introduction %} {{ course.short_introduction }} {% endif %}</div>
{% if course.edit_mode %} {% if course.edit_mode %}
<button class="btn btn-default btn-sm btn-tag"> {{ _("Add Tag") }} </button> <div class="preview-video-header">
<div class="d-block mt-1" contenteditable="true" id="video-link"
data-placeholder=" {{ _('Preview Video Link') }} ">{% if course.video_link %}{{ course.video_link }}{% endif %}</div>
<div class="preview-info">
<div class="tool-tip">
<div class="tooltiptext">
<span>
{{ _('If you have a video that provides a teaser or preview of the course, you can add it here.') }}
</span>
<span>
{{ _("Follow the steps mentioned below for the same.") }}
</span>
<ul>
<li>
{{ _("Upload the video on youtube.") }}
</li>
<li>
{{ _("When you share a youtube video, it shows an option called Embed.") }}
</li>
<li>
{{ _("On clicking it, it provides an iframe. Copy the source (src) of the iframe and paste it here.") }}
</li>
</ul>
</div>
<svg class="icon icon-md">
<use href="#icon-solid-info"></use>
</svg>
</div>
</div>
</div>
<div class="course-image-attachment {% if not course.image %} hide {% endif %} ">
<a href="{{ course.image }}" id="image" target="_blank"> {{ course.image }} </a>
<button class="btn btn-sm btn-default btn-clear ml-4"> {{ _("Clear") }} </button>
</div>
<a class="btn btn-default btn-sm btn-attach mt-1 {% if course.image %} hide {% endif %}"> {{ _("Attach Image") }} </a>
{% endif %} {% endif %}
</div>
<div {% if course.edit_mode %} data-placeholder="{{ _('Title') }}" contenteditable="true" {% endif %} {% if not course.edit_mode %}
id="title" {% if course.name %} data-course="{{ course.name | urlencode }}" {% endif %} <div class="mt-8">
class="course-card-wide-title">{% if course.title %} {{ course.title }} {% endif %}</div> <div class="bold-heading">{{ _("Instructors") }}:</div>
{% for instructor in get_instructors(course.name) %}
<div {% if course.edit_mode %} contenteditable="true" data-placeholder="{{ _('Short Introduction') }}" <div class="mt-1">
{% endif %} id="intro" >{% if course.short_introduction %} {{ course.short_introduction }} {% endif %}</div> {{ widgets.Avatar(member=instructor, avatar_class="avatar-small") }}
<a class="button-links" href="{{ get_profile_url(instructor.username) }}">
{% if course.edit_mode %} <span class="course-instructor"> {{ instructor.full_name }} </span>
<div class="preview-video-header"> </a>
<div class="d-block mt-1" contenteditable="true" id="video-link" </div>
data-placeholder=" {{ _('Preview Video Link') }} ">{% if course.video_link %}{{ course.video_link }}{% endif %}</div> {% endfor %}
<svg class="icon icon-md preview-info">
<title>{{ _("If you have a video that provides a teaser or preview of the course, you can add it here. Upload the video on youtube. When you share a youtube video, it shows an option called Embed. On clicking it, it provides an iframe. Copy the source of the iframe and paste it here.") }}</title>
<use href="#icon-solid-info"></use>
</svg>
</div> </div>
{% if course.image %}
<div class="course-image-attachment {% if not course.image %} hide {% endif %} ">
<a href="{{ course.image }}" id="image" target="_blank"> {{ course.image }} </a>
<button class="btn btn-sm btn-default btn-clear ml-4"> {{ _("Clear") }} </button>
</div>
{% else %}
<a class="btn btn-default btn-sm btn-attach mt-1 {% if course.image %} hide {% endif %}"> {{ _("Attach Image") }} </a>
{% endif %} {% endif %}
{% endif %}
{% if not course.edit_mode %} {% if membership and not course.edit_mode %}
<div class="mt-8"> {% set progress = frappe.utils.cint(membership.progress) %}
<div class="bold-heading">{{ _("Instructors") }}:</div> <div class="mt-8">
{% for instructor in get_instructors(course.name) %} <div class="progress-percent m-0">{{ progress }}% {{ _("Completed") }}</div>
<div class="mt-1"> <div class="progress" title="{{ progress }}% Completed">
{{ widgets.Avatar(member=instructor, avatar_class="avatar-small") }} <div class="progress-bar" role="progressbar" aria-valuenow="{{ progress }}"
<a class="button-links" href="{{ get_profile_url(instructor.username) }}"> aria-valuemin="0" aria-valuemax="100" style="width:{{ progress }}%">
<span class="course-instructor"> {{ instructor.full_name }} </span> </div>
</a>
</div>
{% endfor %}
</div>
{% endif %}
{% if membership and not course.edit_mode %}
{% set progress = frappe.utils.cint(membership.progress) %}
<div class="mt-8">
<div class="progress-percent m-0">{{ progress }}% {{ _("Completed") }}</div>
<div class="progress" title="{{ progress }}% Completed">
<div class="progress-bar" role="progressbar" aria-valuenow="{{ progress }}"
aria-valuemin="0" aria-valuemax="100" style="width:{{ progress }}%">
</div> </div>
</div> </div>
</div> {% endif %}
{% endif %}
{% endmacro %} {% endmacro %}
<!-- Overlay --> <!-- Overlay -->
{% macro CourseHeaderOverlay(course) %} {% macro CourseHeaderOverlay(course) %}
{% if not course.edit_mode %} {% if not course.edit_mode %}
<div class="course-overlay-card"> <div class="course-overlay-card">
{% if course.video_link %} {% if course.video_link %}
<iframe class="preview-video" src="{{ course.video_link }}"></iframe> <iframe class="preview-video" src="{{ course.video_link }}"></iframe>
{% endif %}
<div class="course-overlay-content">
<div class="course-overlay-title"> {{ course.title }} </div>
{{ Notes(course) }}
<div class="vertically-center mb-3">
<svg class="icon icon-md mr-1">
<use class="" href="#icon-users">
</svg>
{{ get_students(course.name) | length }} {{ _("Enrolled") }}
</div>
{% if get_lessons(course.name) | length %}
<div class="vertically-center mb-3">
<svg class="icon icon-md mr-1">
<use href="#icon-education"></use>
</svg>
{{ get_lessons(course.name) | length }} {{ _("Lessons") }}
</div>
{% endif %} {% endif %}
{% if course.paid_certificate %} <div class="course-overlay-content">
<div class="vertically-center mb-3"> <div class="course-overlay-title"> {{ course.title }} </div>
<svg class="icon icon-md mr-1">
<use href="#icon-badge"></use> {{ Notes(course) }}
</svg>
<span class="certificate-price" data-price="{{ course.price_certificate }}"> <div class="vertically-center mb-3">
{{ format_amount(course.price_certificate, course.currency) }} <svg class="icon icon-md mr-1">
</span> <use class="" href="#icon-users">
<span class="indicator-pill green ml-3"> {{ _("Get Certified") }} </span> </svg>
{{ get_students(course.name) | length }} {{ _("Enrolled") }}
</div>
{% if get_lessons(course.name) | length %}
<div class="vertically-center mb-3">
<svg class="icon icon-md mr-1">
<use href="#icon-education"></use>
</svg>
{{ get_lessons(course.name) | length }} {{ _("Lessons") }}
</div>
{% endif %}
{% if course.paid_certificate %}
<div class="vertically-center mb-3">
<svg class="icon icon-md mr-1">
<use href="#icon-badge"></use>
</svg>
<span class="certificate-price" data-price="{{ course.price_certificate }}">
{{ format_amount(course.price_certificate, course.currency) }}
</span>
<span class="indicator-pill green ml-3"> {{ _("Get Certified") }} </span>
</div>
{% endif %}
{{ CTASection(course, membership) }}
</div> </div>
{% endif %}
{{ CTASection(course, membership) }}
</div> </div>
</div> {{ SlotModal(course) }}
{{ SlotModal(course) }}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
<!-- Description --> <!-- Description -->
{% macro Description(course) %} {% macro Description(course) %}
<div class="course-description-section" {% if course.edit_mode %} style="min-height: 100px" {% endif %} <div class="course-description-section" {% if course.edit_mode %} style="min-height: 100px" {% endif %}
{% if course.edit_mode %} contenteditable="true" {% endif %} id="description" {% if course.edit_mode %} contenteditable="true" {% endif %} id="description"
data-placeholder="Description">{% if course.description %}{{ frappe.utils.md_to_html(course.description) }}{% endif %}</div> data-placeholder="Description">{% if course.description %}{{ frappe.utils.md_to_html(course.description) }}{% endif %}</div>
{% endmacro %} {% endmacro %}
<!-- Save --> <!-- Save -->
{% macro Save(course) %} {% macro Save(course) %}
{% if course.edit_mode %} {% if course.edit_mode %}
<div class="my-4"> <div class="my-4">
<button class="btn btn-primary btn-md btn-save-course"> <button class="btn btn-primary btn-md btn-save-course">
{{ _("Save Course Details") }} {{ _("Save Course Details") }}
</button> </button>
{% if course.name %} {% if course.name %}
<a class="btn btn-secondary btn-md btn-exit-edit ml-2" href="/courses/{{ course.name }}"> <a class="btn btn-secondary btn-md btn-exit-edit ml-2" href="/courses/{{ course.name }}">
{{ _("Back to Course") }} {{ _("Back to Course") }}
</a> </a>
{% endif %}
</div>
{% endif %} {% endif %}
</div>
{% endif %}
{% endmacro %} {% endmacro %}
{% macro CourseCreator(course) %} {% macro CourseCreator(course) %}
<div class="course-home-headings"> {{ _("Course Creators") }} </div> <div class="course-home-headings"> {{ _("Course Creators") }} </div>
<div class="common-card-style course-creators-card">
<div class="common-card-style course-creators-card"> {% set instructors = get_instructors(course.name) %}
{% set instructors = get_instructors(course.name) %} {% for instructor in instructors %}
{% for instructor in instructors %} <div class="d-flex align-items-center">
<div class="d-flex align-items-center"> {{ widgets.Avatar(member=instructor, avatar_class="avatar-medium") }}
{{ widgets.Avatar(member=instructor, avatar_class="avatar-medium") }} <div class="ml-4">
<div class="ml-4"> <div class="course-creator-name"> {{ instructor.full_name }} </div>
<div class="course-creator-name"> {{ instructor.full_name }} </div> <div class="course-meta"> {{ get_authored_courses(instructor.name) | length }} {{ _("Courses Created") }} </div>
<div class="course-meta"> {{ get_authored_courses(instructor.name) | length }} {{ _("Courses Created") }} </div> </div>
</div>
{% endfor %}
</div> </div>
</div>
{% endfor %}
</div>
{% endmacro %} {% endmacro %}
<!-- Related Courses Section --> <!-- Related Courses Section -->
{% macro RelatedCourses(course) %} {% macro RelatedCourses(course) %}
{% if course.related_courses | length %} {% if course.related_courses | length %}
<div class="related-courses"> <div class="related-courses">
<div class="container"> <div class="container">
<div class="course-home-headings"> {{ _("Other Courses") }} </div> <div class="course-home-headings"> {{ _("Other Courses") }} </div>
<div class="carousel slide" id="carouselExampleControls" data-ride="carousel" data-interval="false"> <div class="carousel slide" id="carouselExampleControls" data-ride="carousel" data-interval="false">
<div class="carousel-inner"> <div class="carousel-inner">
{% for crs in course.related_courses %} {% for crs in course.related_courses %}
{% if loop.index % 3 == 1 %} {% if loop.index % 3 == 1 %}
<div class="carousel-item {% if loop.index == 1 %} active {% endif %}"><div class="cards-parent"> <div class="carousel-item {% if loop.index == 1 %} active {% endif %}"><div class="cards-parent">
{% endif %} {% endif %}
{{ widgets.CourseCard(course=crs, read_only=False) }} {{ widgets.CourseCard(course=crs, read_only=False) }}
{% if loop.index % 3 == 0 or loop.index == course.related_courses | length %} </div> </div> {% endif %} {% if loop.index % 3 == 0 or loop.index == course.related_courses | length %} </div> </div> {% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% if course.related_courses | length > 3 %} {% if course.related_courses | length > 3 %}
<div class="slider-controls"> <div class="slider-controls">
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev"> <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="carousel-control-prev-icon" aria-hidden="true"></span>
</a> </a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next"> <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="carousel-control-next-icon" aria-hidden="true"></span>
</a> </a>
</div> </div>
{% endif %} {% endif %}
</div>
</div>
</div> </div>
</div> {% endif %}
</div>
{% endif%}
{% endmacro %} {% endmacro %}

View File

@@ -327,10 +327,12 @@ const add_tag = (e) => {
const save_course = (e) => { const save_course = (e) => {
let tags = $('.course-card-pills').map((i, el) => $(el).text().trim()).get();
tags = tags.filter(word => word.trim().length > 0);
frappe.call({ frappe.call({
method: "lms.lms.doctype.lms_course.lms_course.save_course", method: "lms.lms.doctype.lms_course.lms_course.save_course",
args: { args: {
"tags": $('.course-card-pills').map((i, el) => $(el).text().trim()).get().join(", "), "tags": tags.join(", "),
"title": $("#title").text(), "title": $("#title").text(),
"short_introduction": $("#intro").text(), "short_introduction": $("#intro").text(),
"video_link": $("#video-link").text(), "video_link": $("#video-link").text(),
@@ -339,7 +341,13 @@ const save_course = (e) => {
"course": $("#title").data("course") ? $("#title").data("course") : "" "course": $("#title").data("course") ? $("#title").data("course") : ""
}, },
callback: (data) => { callback: (data) => {
window.location.href = `/courses/${data.message}?edit=1`; frappe.show_alert({
message: __("Saved"),
indicator: "green",
});
setTimeout(() => {
window.location.href = `/courses/${data.message}?edit=1`;
}, 1000);
} }
}); });
}; };