From 47b9b1dcd6cfd9f0fe4f6af955272c883d350379 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 15 Sep 2022 22:52:17 +0530 Subject: [PATCH 1/3] fix: show first chapter and question form by default --- .../job_opportunity/job_opportunity.json | 3 ++- .../job_opportunity/job_opportunity.py | 13 ++++++++++ .../job_opportunity/job_opportunity.json | 9 +++---- lms/lms/widgets/CourseOutline.html | 16 +++++++++--- lms/public/js/common_functions.js | 4 +-- lms/www/batch/learn.html | 4 ++- lms/www/batch/learn.js | 10 ++++++-- lms/www/batch/learn.py | 2 +- lms/www/batch/quiz.html | 2 +- lms/www/batch/quiz.js | 25 ++++++++++++++++--- lms/www/courses/course.html | 2 +- 11 files changed, 69 insertions(+), 21 deletions(-) diff --git a/lms/job/doctype/job_opportunity/job_opportunity.json b/lms/job/doctype/job_opportunity/job_opportunity.json index b1684238..7ac25e65 100644 --- a/lms/job/doctype/job_opportunity/job_opportunity.json +++ b/lms/job/doctype/job_opportunity/job_opportunity.json @@ -45,6 +45,7 @@ "fieldtype": "Column Break" }, { + "default": "Full Time", "fieldname": "type", "fieldtype": "Select", "label": "Type", @@ -115,7 +116,7 @@ "index_web_pages_for_search": 1, "links": [], "make_attachments_public": 1, - "modified": "2022-09-14 12:47:20.840223", + "modified": "2022-09-15 17:22:21.662675", "modified_by": "Administrator", "module": "Job", "name": "Job Opportunity", diff --git a/lms/job/doctype/job_opportunity/job_opportunity.py b/lms/job/doctype/job_opportunity/job_opportunity.py index fc4ebc75..fbb648e6 100644 --- a/lms/job/doctype/job_opportunity/job_opportunity.py +++ b/lms/job/doctype/job_opportunity/job_opportunity.py @@ -9,10 +9,23 @@ from frappe.utils import get_link_to_form class JobOpportunity(Document): + def validate(self): + self.validate_urls() + self.validate_logo() + + + def validate_urls(self): frappe.utils.validate_url(self.company_website, True) frappe.utils.validate_url(self.application_link, True) + + def validate_logo(self): + if "/private" in self.company_logo: + frappe.db.set_value("File", {"file_url": self.company_logo}, "is_private", 0) + frappe.db.set_value("File", {"file_url": self.company_logo}, "file_url", self.company_logo.replace("/private", "")) + self.company_logo = self.company_logo.replace("/private", "") + @frappe.whitelist() def report(job, reason): system_managers = get_system_managers(only_name=True) diff --git a/lms/job/web_form/job_opportunity/job_opportunity.json b/lms/job/web_form/job_opportunity/job_opportunity.json index a8f1e611..f54dc557 100644 --- a/lms/job/web_form/job_opportunity/job_opportunity.json +++ b/lms/job/web_form/job_opportunity/job_opportunity.json @@ -16,11 +16,11 @@ "docstatus": 0, "doctype": "Web Form", "idx": 0, - "is_multi_step_form": 0, "is_standard": 1, + "list_columns": [], "login_required": 1, "max_attachment_size": 0, - "modified": "2022-02-24 11:31:25.290524", + "modified": "2022-09-15 17:22:43.957184", "modified_by": "Administrator", "module": "Job", "name": "job-opportunity", @@ -28,11 +28,9 @@ "payment_button_label": "Buy Now", "published": 1, "route": "job-opportunity", - "route_to_success_link": 1, "show_attachments": 0, - "show_in_grid": 0, + "show_list": 1, "show_sidebar": 0, - "sidebar_items": [], "success_message": "", "success_url": "/jobs", "title": "Job Opportunity", @@ -63,6 +61,7 @@ }, { "allow_read_on_all_link_options": 0, + "default": "Full Time", "fieldname": "type", "fieldtype": "Select", "hidden": 0, diff --git a/lms/lms/widgets/CourseOutline.html b/lms/lms/widgets/CourseOutline.html index 2aec5324..41c22908 100644 --- a/lms/lms/widgets/CourseOutline.html +++ b/lms/lms/widgets/CourseOutline.html @@ -1,18 +1,28 @@
+ {% set chapters = get_chapters(course.name) %} + {% if course.edit_mode and course.name %} {% endif %} - {% if course.name and (course.edit_mode or get_chapters(course.name) | length) %} + {% if course.name and (course.edit_mode or chapters | length) %}
{{ _("Course Content") }}
{% endif %} - {% if get_chapters(course.name) | length %} + {% if course.edit_mode and course.name and not chapters | length %} +
+
+
+ +
+ {% endif %} - {% for chapter in get_chapters(course.name) %} + {% if chapters | length %} + + {% for chapter in chapters %}
{{ LessonContent(lesson) }} - {% if not lesson.edit_mode %} {{ Discussions() }} {% endif %} + {% if not lesson.edit_mode and course.staus == "Approved" and not course.upcoming %} + {{ Discussions() }} + {% endif %}
diff --git a/lms/www/batch/learn.js b/lms/www/batch/learn.js index 620c2b53..435ff01c 100644 --- a/lms/www/batch/learn.js +++ b/lms/www/batch/learn.js @@ -498,8 +498,14 @@ const save_lesson = (e) => { "idx": $("#title").data("index"), "lesson": lesson ? lesson : "" }, - callback: (data) => { - window.location.href = window.location.href.split("?")[0]; + callback: (data) => {; + frappe.show_alert({ + message: __("Saved"), + indicator: "green", + }); + setTimeout(() => { + window.location.href = window.location.href.split("?")[0]; + }, 1000); } }); }; diff --git a/lms/www/batch/learn.py b/lms/www/batch/learn.py index fd8066fe..a1674156 100644 --- a/lms/www/batch/learn.py +++ b/lms/www/batch/learn.py @@ -24,7 +24,7 @@ def get_context(context): 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() + context.show_lesson = context.membership or (context.lesson and context.lesson.include_in_preview) or instructor or has_course_moderator_role() if not context.lesson: context.lesson = frappe._dict() diff --git a/lms/www/batch/quiz.html b/lms/www/batch/quiz.html index 26a2ca7f..53f8cb0a 100644 --- a/lms/www/batch/quiz.html +++ b/lms/www/batch/quiz.html @@ -40,7 +40,7 @@ {% for question in quiz.questions %}
{% if question.question %} {{ question.question }} {% endif %}
+ class="question mb-4 req">{% if question.question %} {{ question.question }} {% endif %}
{% for i in range(1,5) %} {% set num = frappe.utils.cstr(i) %} diff --git a/lms/www/batch/quiz.js b/lms/www/batch/quiz.js index a7491fed..f114e2c6 100644 --- a/lms/www/batch/quiz.js +++ b/lms/www/batch/quiz.js @@ -1,7 +1,11 @@ frappe.ready(() => { + if(!$(".quiz-card").length) { + add_question(); + } + $(".btn-question").click((e) => { - add_question(e); + add_question(); }); $(".btn-save-question").click((e) => { @@ -17,10 +21,15 @@ frappe.ready(() => { }); -const add_question = (e) => { +const add_question = () => { + if ($(".new-quiz-card").length) { + scroll_to_question_container(); + return; + } + let add_after = $(".quiz-card").length ? $(".quiz-card:last") : $("#quiz-title"); - let question_template = `
-
+ let question_template = `
+
`; $(question_template).insertAfter(add_after); get_question_template(); @@ -109,3 +118,11 @@ const get_questions = () => { return questions; }; + + +const scroll_to_question_container = () => { + $([document.documentElement, document.body]).animate({ + scrollTop: $(".new-quiz-card").offset().top + }, 1000); + $(".new-quiz-card").find(".question").focus(); +} diff --git a/lms/www/courses/course.html b/lms/www/courses/course.html index e4c24cc4..163e1c5e 100644 --- a/lms/www/courses/course.html +++ b/lms/www/courses/course.html @@ -22,7 +22,7 @@ {{ Description(course) }} {{ Save(course) }} {{ widgets.CourseOutline(course=course, membership=membership, is_user_interested=is_user_interested) }} - {% if not course.edit_mode %} + {% if not course.edit_mode and course.staus == "Approved" and not course.upcoming %} {{ widgets.Reviews(course=course, membership=membership) }} {% endif %}
From f7ba72217b84a84b9d29a600d79bf908e4b8eed2 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Fri, 16 Sep 2022 11:37:11 +0530 Subject: [PATCH 2/3] fix: controls script loading --- lms/hooks.py | 2 +- lms/www/courses/course.html | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lms/hooks.py b/lms/hooks.py index 9c94b94c..fc70e0e6 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -21,7 +21,7 @@ app_license = "AGPL" # include js, css files in header of web template web_include_css = "lms.bundle.css" # web_include_css = "/assets/lms/css/lms.css" -web_include_js = "website.bundle.js" +web_include_js = ["website.bundle.js", "controls.bundle.js"] # include custom scss in every website theme (without file extension ".scss") # website_theme_scss = "lms/public/scss/website" diff --git a/lms/www/courses/course.html b/lms/www/courses/course.html index 163e1c5e..27e7257a 100644 --- a/lms/www/courses/course.html +++ b/lms/www/courses/course.html @@ -6,7 +6,6 @@ {% block head_include %} {% include "public/icons/symbol-defs.svg" %} - {% endblock %} @@ -22,7 +21,7 @@ {{ Description(course) }} {{ Save(course) }} {{ widgets.CourseOutline(course=course, membership=membership, is_user_interested=is_user_interested) }} - {% if not course.edit_mode and course.staus == "Approved" and not course.upcoming %} + {% if not course.edit_mode and course.status == "Approved" and not frappe.utils.cint(course.upcoming) %} {{ widgets.Reviews(course=course, membership=membership) }} {% endif %} @@ -423,9 +422,3 @@ {% endmacro %} - - -{% block base_scripts %} - {{ include_script("frappe-web.bundle.js") }} - {{ include_script('controls.bundle.js') }} -{% endblock %} From 023fd73b86fd00a29bda0c06899fae3ee2ef0709 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Fri, 16 Sep 2022 16:05:33 +0530 Subject: [PATCH 3/3] fix: removed unused classes --- lms/www/batch/quiz.html | 2 +- lms/www/batch/quiz.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/www/batch/quiz.html b/lms/www/batch/quiz.html index 53f8cb0a..26a2ca7f 100644 --- a/lms/www/batch/quiz.html +++ b/lms/www/batch/quiz.html @@ -40,7 +40,7 @@ {% for question in quiz.questions %}
{% if question.question %} {{ question.question }} {% endif %}
+ class="question mb-4">{% if question.question %} {{ question.question }} {% endif %}
{% for i in range(1,5) %} {% set num = frappe.utils.cstr(i) %} diff --git a/lms/www/batch/quiz.js b/lms/www/batch/quiz.js index f114e2c6..140d9fdf 100644 --- a/lms/www/batch/quiz.js +++ b/lms/www/batch/quiz.js @@ -29,7 +29,7 @@ const add_question = () => { let add_after = $(".quiz-card").length ? $(".quiz-card:last") : $("#quiz-title"); let question_template = `
-
+
`; $(question_template).insertAfter(add_after); get_question_template();