diff --git a/lms/lms/doctype/course_lesson/course_lesson.json b/lms/lms/doctype/course_lesson/course_lesson.json
index 66798e15..eaee75f2 100644
--- a/lms/lms/doctype/course_lesson/course_lesson.json
+++ b/lms/lms/doctype/course_lesson/course_lesson.json
@@ -66,7 +66,7 @@
},
{
"fieldname": "body",
- "fieldtype": "Text Editor",
+ "fieldtype": "Markdown Editor",
"ignore_xss_filter": 1,
"label": "Body",
"reqd": 1
@@ -135,7 +135,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-04-05 12:42:16.926753",
+ "modified": "2023-05-02 12:42:16.926753",
"modified_by": "Administrator",
"module": "LMS",
"name": "Course Lesson",
diff --git a/lms/lms/doctype/lms_certificate/lms_certificate.json b/lms/lms/doctype/lms_certificate/lms_certificate.json
index 91ec1085..d1d2a8a2 100644
--- a/lms/lms/doctype/lms_certificate/lms_certificate.json
+++ b/lms/lms/doctype/lms_certificate/lms_certificate.json
@@ -56,7 +56,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2022-04-06 11:49:36.077370",
+ "modified": "2023-04-14 12:33:37.839625",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate",
diff --git a/lms/lms/doctype/lms_certificate/lms_certificate.py b/lms/lms/doctype/lms_certificate/lms_certificate.py
index 3c5f4de8..5e4f8688 100644
--- a/lms/lms/doctype/lms_certificate/lms_certificate.py
+++ b/lms/lms/doctype/lms_certificate/lms_certificate.py
@@ -5,8 +5,6 @@ import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import add_years, nowdate
-from frappe.utils.pdf import get_pdf
-
from lms.lms.utils import is_certified
@@ -47,10 +45,3 @@ def create_certificate(course):
)
certificate.save(ignore_permissions=True)
return certificate
-
-
-@frappe.whitelist()
-def get_certificate_pdf(html):
- frappe.local.response.filename = "certificate.pdf"
- frappe.local.response.filecontent = get_pdf(html, {"orientation": "LandScape"})
- frappe.local.response.type = "pdf"
diff --git a/lms/lms/doctype/lms_course/lms_course.json b/lms/lms/doctype/lms_course/lms_course.json
index 839cf40a..beac3d4e 100644
--- a/lms/lms/doctype/lms_course/lms_course.json
+++ b/lms/lms/doctype/lms_course/lms_course.json
@@ -57,7 +57,7 @@
},
{
"fieldname": "description",
- "fieldtype": "Text Editor",
+ "fieldtype": "Markdown Editor",
"label": "Description",
"reqd": 1
},
@@ -260,7 +260,7 @@
}
],
"make_attachments_public": 1,
- "modified": "2023-02-23 09:45:54.826328",
+ "modified": "2023-05-02 09:45:54.826328",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Course",
diff --git a/lms/lms/doctype/lms_settings/lms_settings.json b/lms/lms/doctype/lms_settings/lms_settings.json
index 7dbeed68..f3ed9073 100644
--- a/lms/lms/doctype/lms_settings/lms_settings.json
+++ b/lms/lms/doctype/lms_settings/lms_settings.json
@@ -15,7 +15,6 @@
"search_placeholder",
"portal_course_creation",
"column_break_2",
- "custom_certificate_template",
"livecode_url",
"signup_settings_tab",
"signup_settings_section",
@@ -139,12 +138,6 @@
"fieldtype": "Check",
"label": "Ask User Category during Signup"
},
- {
- "fieldname": "custom_certificate_template",
- "fieldtype": "Link",
- "label": "Custom Certificate Template",
- "options": "Web Template"
- },
{
"default": "0",
"fieldname": "is_onboarding_complete",
@@ -192,7 +185,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2023-02-23 10:39:38.912549",
+ "modified": "2023-04-17 12:54:44.706101",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Settings",
diff --git a/lms/lms/print_format/__init__.py b/lms/lms/print_format/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/lms/lms/print_format/certificate/__init__.py b/lms/lms/print_format/certificate/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/lms/lms/print_format/certificate/certificate.json b/lms/lms/print_format/certificate/certificate.json
new file mode 100644
index 00000000..cea5f505
--- /dev/null
+++ b/lms/lms/print_format/certificate/certificate.json
@@ -0,0 +1,32 @@
+{
+ "absolute_value": 0,
+ "align_labels_right": 0,
+ "creation": "2023-02-22 21:36:54.560420",
+ "css": ".outer-border {\n font-family: \"Inter\" sans-serif;\n font-size: 16px;\n border-radius: 0.5rem;\n border: 1px solid #E2E6E9;\n padding: 1rem;\n}\n\n.inner-border {\n border: 10px solid #0089FF;\n border-radius: 8px;\n text-align: center;\n padding: 6rem 4rem;\n background-color: #FFFFFF;\n}\n\n.certificate-logo {\n height: 1.5rem;\n margin-bottom: 4rem;\n}\n\n.certificate-name {\n font-size: 2rem;\n font-weight: 500;\n color: #192734;\n margin-bottom: 0.5rem;\n}\n\n.certificate-footer {\n margin: 4rem auto 0;\n width: 70%;\n text-align: center;\n}\n\n.certificate-footer-item {\n color: #192734;\n}\n\n.cursive-font {\n font-family: cursive;\n font-weight: 600;\n}\n\n.certificate-divider {\n margin: 0.5rem 0;\n}\n\n.certificate-expiry {\n margin-left: 2rem;\n}",
+ "custom_format": 1,
+ "disabled": 0,
+ "doc_type": "LMS Certificate",
+ "docstatus": 0,
+ "doctype": "Print Format",
+ "font_size": 14,
+ "format_data": "{\"header\":\"
\",\"sections\":[{\"label\":\"\",\"columns\":[{\"label\":\"\",\"fields\":[{\"label\":\"Course\",\"fieldname\":\"course\",\"fieldtype\":\"Link\",\"options\":\"LMS Course\"},{\"label\":\"Member\",\"fieldname\":\"member\",\"fieldtype\":\"Link\",\"options\":\"User\"},{\"label\":\"Member Name\",\"fieldname\":\"member_name\",\"fieldtype\":\"Data\"},{\"label\":\"Evaluator\",\"fieldname\":\"evaluator\",\"fieldtype\":\"Data\",\"options\":\"\"}]},{\"label\":\"\",\"fields\":[{\"label\":\"Issue Date\",\"fieldname\":\"issue_date\",\"fieldtype\":\"Date\"},{\"label\":\"Expiry Date\",\"fieldname\":\"expiry_date\",\"fieldtype\":\"Date\"},{\"label\":\"Version\",\"fieldname\":\"version\",\"fieldtype\":\"Select\",\"options\":\"V13\\nV14\"},{\"label\":\"Module Names for Certificate\",\"fieldname\":\"module_names_for_certificate\",\"fieldtype\":\"Data\"}]}],\"has_fields\":true}]}",
+ "html": "{% set certificate = frappe.db.get_value(\"LMS Certificate\", doc.name, [\"name\", \"member\", \"issue_date\", \"expiry_date\", \"course\"], as_dict=True) %}\n{% set member = frappe.db.get_value(\"User\", doc.member, [\"full_name\"], as_dict=True) %}\n{% set course = frappe.db.get_value(\"LMS Course\", doc.course, [\"title\", \"name\", \"image\"], as_dict=True) %}\n{% set logo = frappe.db.get_single_value(\"Website Settings\", \"banner_image\") %}\n{% set instructors = frappe.get_all(\"Course Instructor\", {\"parent\": doc.course}, pluck=\"instructor\", order_by=\"idx\") %}\n\n\n\n\n\n\n\n
\n \n

\n
\n {{ _(\"This certifies that\") }}\n
\n \n
\n {{ member.full_name }}\n
\n
\n {{ _(\"has successfully completed the course on\") }}\n {{ course.title }} \n on {{ frappe.utils.format_date(certificate.issue_date, \"medium\") }}.\n
\n \n \n
\n
",
+ "idx": 0,
+ "line_breaks": 0,
+ "margin_bottom": 0.0,
+ "margin_left": 0.0,
+ "margin_right": 0.0,
+ "margin_top": 0.0,
+ "modified": "2023-04-17 13:46:38.633751",
+ "modified_by": "Administrator",
+ "module": "LMS",
+ "name": "Certificate",
+ "owner": "Administrator",
+ "page_number": "Hide",
+ "print_format_builder": 0,
+ "print_format_builder_beta": 1,
+ "print_format_type": "Jinja",
+ "raw_printing": 0,
+ "show_section_headings": 0,
+ "standard": "Yes"
+}
\ No newline at end of file
diff --git a/lms/patches.txt b/lms/patches.txt
index 791d9b3b..3fe84429 100644
--- a/lms/patches.txt
+++ b/lms/patches.txt
@@ -50,6 +50,6 @@ lms.patches.v0_0.video_embed_link
lms.patches.v0_0.rename_exercise_doctype
lms.patches.v0_0.add_question_type #09-04-2023
lms.patches.v0_0.add_evaluator_to_assignment #09-04-2023
-lms.patches.v0_0.convert_lesson_markdown_to_html #05-04-2023
-lms.patches.v0_0.convert_course_description_to_html
+lms.patches.v0_0.share_certificates
execute:frappe.delete_doc("Web Form", "class", ignore_missing=True, force=True)
+lms.patches.v0_0.amend_course_and_lesson_editor_fields
diff --git a/lms/patches/v0_0/amend_course_and_lesson_editor_fields.py b/lms/patches/v0_0/amend_course_and_lesson_editor_fields.py
new file mode 100644
index 00000000..aa40a4a1
--- /dev/null
+++ b/lms/patches/v0_0/amend_course_and_lesson_editor_fields.py
@@ -0,0 +1,37 @@
+import frappe
+from frappe.utils import to_markdown
+
+
+def execute():
+ amend_lesson_content()
+ amend_course_description()
+
+
+def amend_lesson_content():
+ lesson_content_field = frappe.db.get_value(
+ "DocField", {"parent": "Course Lesson", "fieldname": "body"}, "fieldtype"
+ )
+
+ if lesson_content_field == "Text Editor":
+ lessons = frappe.get_all("Course Lesson", fields=["name", "body"])
+
+ for lesson in lessons:
+ frappe.db.set_value("Course Lesson", lesson.name, "body", to_markdown(lesson.body))
+
+ frappe.reload_doc("lms", "doctype", "course_lesson")
+
+
+def amend_course_description():
+ course_description_field = frappe.db.get_value(
+ "DocField", {"parent": "LMS Course", "fieldname": "description"}, "fieldtype"
+ )
+
+ if course_description_field == "Text Editor":
+ courses = frappe.get_all("LMS Course", fields=["name", "description"])
+
+ for course in courses:
+ frappe.db.set_value(
+ "LMS Course", course.name, "description", to_markdown(course.description)
+ )
+
+ frappe.reload_doc("lms", "doctype", "lms_course")
diff --git a/lms/patches/v0_0/share_certificates.py b/lms/patches/v0_0/share_certificates.py
new file mode 100644
index 00000000..ed9b3154
--- /dev/null
+++ b/lms/patches/v0_0/share_certificates.py
@@ -0,0 +1,25 @@
+import frappe
+
+
+def execute():
+ certificates = frappe.get_all("LMS Certificate", fields=["member", "name"])
+
+ for certificate in certificates:
+ if not frappe.db.exists(
+ "DocShare",
+ {
+ "share_doctype": "LMS Certificate",
+ "share_name": certificate.name,
+ "user": certificate.member,
+ },
+ ):
+ share = frappe.get_doc(
+ {
+ "doctype": "DocShare",
+ "user": certificate.member,
+ "share_doctype": "LMS Certificate",
+ "share_name": certificate.name,
+ "read": 1,
+ }
+ )
+ share.save(ignore_permissions=True)
diff --git a/lms/public/css/style.css b/lms/public/css/style.css
index e70bf947..fded8915 100644
--- a/lms/public/css/style.css
+++ b/lms/public/css/style.css
@@ -974,71 +974,67 @@ pre {
object-fit: cover;
}
-.certificate-content {
- background-color: #FFFFFF;
- border-width: 10px;
- border-style: solid;
-}
-
-@media (max-width: 500px) {
- .certificate-content {
- border-width: 50px;
- }
-}
-
-.certificate-footer {
- display: flex;
- justify-content: center;
- margin: 4rem auto 0;
- width: fit-content;
-}
-
-.certificate-ribbon {
- background-color: var(--primary-color);
- padding: 0.5rem;
- border-radius: var(--border-radius-md);
-}
-
-.certificate-heading {
- font-size: 2rem;
- font-weight: 500;
- color: var(--text-color);
-}
-
-.certificate-para {
- margin-bottom: 4rem;
-}
-
.certificate-card {
background: #FFFFFF;
- border-radius: var(--border-radius-md);
- position: relative;
- box-shadow: var(--shadow-sm);
+ font-size: 14px
+}
+
+.certificate-content {
+ border-radius: 0.5rem;
+ border: 1px solid #EEF0F2;
padding: 1rem;
+ font-size: var(--text-lg);
+}
+
+.certificate-border {
+ border: 10px solid #0089FF;
+ /* border-image: url(/assets/lms/images/border.png);
+ border-width: 100;
+ border-style: solid ; */
+ border-radius: 8px;
+ padding: 6rem 4rem;
+ background-color: #FFFFFF;
text-align: center;
}
-.certificate-footer-item {
- color: var(--text-color);
- font-weight: bold;
- font-family: cursive;
- font-size: 1.25rem;
+.certificate-parent {
+ display: grid;
+ grid-template-columns: 10fr 2fr;
+ grid-gap: 3rem;
}
.certificate-logo {
- height: 1.5rem;
+ height: 1.5rem;
+ margin-bottom: 4rem;
}
-@media (max-width: 768px) {
- .certificate-card {
- margin: 0;
- }
+.certificate-name {
+ font-size: 2rem;
+ font-weight: 500;
+ color: #192734;
+ margin-bottom: 0.25rem;
}
-@media (max-width: 550px) {
- .certificate-content {
- padding: 1rem;
- }
+.certificate-footer {
+ margin: 4rem auto 0;
+ width: fit-content;
+}
+
+.certificate-footer-item {
+ color: #192734;
+}
+
+.cursive-font {
+ font-family: cursive;
+ font-weight: 600;
+}
+
+.certificate-divider {
+ margin: 0.5rem 0;
+}
+
+.certificate-expiry {
+ margin-left: 2rem;
}
.column-card {
@@ -1336,10 +1332,10 @@ pre {
margin-bottom: 1.875rem;
}
-.job-card-heading {
+.card-heading {
font-weight: 600;
color: var(--gray-900);
- margin-bottom: 0.5rem;
+ margin-bottom: 0.25rem;
}
.course-head-container {
diff --git a/lms/templates/certificate.html b/lms/templates/certificate.html
deleted file mode 100644
index 245970cb..00000000
--- a/lms/templates/certificate.html
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-

-
- {{ _("This certifies that") }}
-
-
-
- {{ member.full_name }}
-
-
- {{ _("has successfully completed the course on") }}
- {{ course.title }}
- on {{ frappe.utils.format_date(certificate.issue_date, "medium") }}.
-
-
-
- {% if instructors %}
-
-
- {{ instructors }}
-
-
-
{{ _("Course Instructor") }}
-
- {% endif %}
-
- {% if certificate.expiry_date %}
-
-
- {{ frappe.utils.format_date(certificate.expiry_date, "medium") }}
-
-
-
{{ _("Expiry date") }}
-
- {% endif %}
-
-
-
diff --git a/lms/www/courses/certificate.html b/lms/www/courses/certificate.html
index 85b164d7..15bea0cd 100644
--- a/lms/www/courses/certificate.html
+++ b/lms/www/courses/certificate.html
@@ -2,25 +2,70 @@
{% block title %} {{ member.full_name }} - {{ course.title }} {% endblock %}
{% block content %}
-
-
-
- {% if certificate.member == frappe.session.user %}
-
{{ _("Export") }}
- {% endif %}
+
+
- {% if custom_template %}
- {{ custom_template }}
- {% else %}
- {% include "lms/templates/certificate.html" %}
- {% endif %}
-
+
+
+
+
+ {{ final_template }}
+
+
+
+
+ {% if doc.member == frappe.session.user %}
+
+ {% endif %}
+
+
+ {{ _("Certificate Recipient") }}:
+
+
+
+ {{ widgets.Avatar(member=member, avatar_class="avatar-small") }}
+
+ {{ member.full_name }}
+
+
+
+
+ {{ _("Issued On") }}:
+
+
+
+ {{ frappe.utils.format_date(doc.issue_date, "medium") }}
+
+
+
+ {{ _("About the Course") }}:
+
+
+
+ {{ course.title }}
+
+
+
+
+
+
+
+
+
+
diff --git a/lms/www/courses/certificate.js b/lms/www/courses/certificate.js
deleted file mode 100644
index b4118f31..00000000
--- a/lms/www/courses/certificate.js
+++ /dev/null
@@ -1,56 +0,0 @@
-frappe.ready(() => {
- $("#export-as-pdf").click((e) => {
- export_as_png(e);
- });
-});
-
-const export_as_pdf = (e) => {
- var formData = new FormData();
-
- //Push the HTML content into an element
- formData.append("html", $("#certificate-card").html());
-
- var blob = new Blob([], { type: "text/xml" });
- formData.append("blob", blob);
-
- var xhr = new XMLHttpRequest();
- xhr.open(
- "POST",
- "/api/method/lms.lms.doctype.lms_certificate.lms_certificate.get_certificate_pdf"
- );
- xhr.setRequestHeader("X-Frappe-CSRF-Token", frappe.csrf_token);
- xhr.responseType = "arraybuffer";
-
- xhr.onload = function (success) {
- if (this.status === 200) {
- var blob = new Blob([success.currentTarget.response], {
- type: "application/pdf",
- });
- var objectUrl = URL.createObjectURL(blob);
-
- //Open report in a new window
- window.open(objectUrl);
- }
- };
- xhr.send(formData);
-};
-
-const export_as_png = (e) => {
- let button = $(e.currentTarget);
- button.text(__("Exporting..."));
-
- html2canvas(document.querySelector("#certificate-card"), {
- scrollY: -window.scrollY,
- scrollX: 0,
- })
- .then(function (canvas) {
- let dataURL = canvas.toDataURL("image/png");
- let a = document.createElement("a");
- a.href = dataURL;
- a.download = button.attr("data-certificate-name");
- a.click();
- })
- .finally(() => {
- button.text(__("Export"));
- });
-};
diff --git a/lms/www/courses/certificate.py b/lms/www/courses/certificate.py
index 404b1b4b..0784db9d 100644
--- a/lms/www/courses/certificate.py
+++ b/lms/www/courses/certificate.py
@@ -1,7 +1,6 @@
import frappe
from frappe.utils.jinja import render_template
-
-from lms.lms.utils import get_instructors
+from frappe.utils import get_url
def get_context(context):
@@ -13,32 +12,40 @@ def get_context(context):
except KeyError:
redirect_to_course_list()
- context.certificate = frappe.db.get_value(
+ context.doc = frappe.db.get_value(
"LMS Certificate",
certificate_name,
["name", "member", "issue_date", "expiry_date", "course"],
as_dict=True,
)
- if context.certificate.course != course_name:
+ if context.doc.course != course_name:
redirect_to_course_list()
context.course = frappe.db.get_value(
"LMS Course", course_name, ["title", "name", "image"], as_dict=True
)
- context.instructors = (", ").join([x.full_name for x in get_instructors(course_name)])
context.member = frappe.db.get_value(
- "User", context.certificate.member, ["full_name"], as_dict=True
+ "User", context.doc.member, ["full_name", "username"], as_dict=True
+ )
+ context.url = f"{get_url()}/courses/{context.course.name}/{context.doc.name}"
+
+ default_print_format = frappe.db.get_value(
+ "Property Setter",
+ {
+ "doc_type": "LMS Certificate",
+ "property": "default_print_format",
+ },
+ ["value"],
+ as_dict=True,
)
- context.logo = frappe.db.get_single_value("Website Settings", "banner_image")
- template_name = frappe.db.get_single_value(
- "LMS Settings", "custom_certificate_template"
+ template = frappe.db.get_value(
+ "Print Format", default_print_format.value, ["html", "css"], as_dict=True
)
- context.custom_certificate_template = frappe.db.get_value(
- "Web Template", template_name, "template"
- )
- context.custom_template = render_template(context.custom_certificate_template, context)
+ merged_template = "" + template.html
+ final_template = render_template(merged_template, context)
+ context.final_template = final_template
def redirect_to_course_list():
diff --git a/lms/www/jobs/index.html b/lms/www/jobs/index.html
index 1c464a59..54971584 100644
--- a/lms/www/jobs/index.html
+++ b/lms/www/jobs/index.html
@@ -20,7 +20,7 @@
-
{{ _(job.job_title) }}
+
{{ _(job.job_title) }}