From ff1363b43751a7656e085b431618700f55a8422d Mon Sep 17 00:00:00 2001 From: pateljannat Date: Wed, 25 Aug 2021 21:01:13 +0530 Subject: [PATCH] fix: certificate, profile, quiz, and video markdown --- community/hooks.py | 3 +- community/lms/doctype/lesson/lesson.js | 9 +++ .../lms_certification/lms_certification.py | 8 ++- .../lms/doctype/lms_course/lms_course.json | 26 +++++++- community/lms/md.py | 2 + community/plugins.py | 3 + community/public/css/style.css | 62 +++++++++++++++---- community/templates/certificate.html | 55 ++++++++-------- community/templates/quiz.html | 8 +-- community/www/batch/learn.html | 6 +- community/www/batch/learn.js | 13 +++- community/www/courses/certificate.js | 6 +- community/www/profiles/profile.html | 19 ++++-- 13 files changed, 158 insertions(+), 62 deletions(-) diff --git a/community/hooks.py b/community/hooks.py index 4c5394f8..26ac5de0 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -134,7 +134,7 @@ fixtures = ["Custom Field"] website_route_rules = [ {"from_route": "/sketches/", "to_route": "sketches/sketch"}, {"from_route": "/courses/", "to_route": "courses/course"}, - {"from_route": "/courses//", "to_route": "courses/topic"}, + {"from_route": "/courses//", "to_route": "courses/certificate"}, {"from_route": "/hackathons/", "to_route": "hackathons/hackathon"}, {"from_route": "/hackathons//", "to_route": "hackathons/project"}, {"from_route": "/add-a-new-batch", "to_route": "add-a-new-batch"}, @@ -175,4 +175,5 @@ community_markdown_macro_renderers = { "Exercise": "community.plugins.exercise_renderer", "Quiz": "community.plugins.quiz_renderer", "YouTubeVideo": "community.plugins.youtube_video_renderer", + "Video": "community.plugins.video_renderer" } diff --git a/community/lms/doctype/lesson/lesson.js b/community/lms/doctype/lesson/lesson.js index bac10995..43a11795 100644 --- a/community/lms/doctype/lesson/lesson.js +++ b/community/lms/doctype/lesson/lesson.js @@ -17,6 +17,15 @@ frappe.ui.form.on('Lesson', { +
+
+ Video +
+
+ {{ Video("url_of_source") }} +
+
+
YouTube Video diff --git a/community/lms/doctype/lms_certification/lms_certification.py b/community/lms/doctype/lms_certification/lms_certification.py index 3ca4d4ce..0625506a 100644 --- a/community/lms/doctype/lms_certification/lms_certification.py +++ b/community/lms/doctype/lms_certification/lms_certification.py @@ -29,13 +29,17 @@ def create_certificate(course): return certificate else: - expires_after_yrs = course_details.expiry + expires_after_yrs = int(course_details.expiry) + expiry_date = None + if expires_after_yrs: + expiry_date = add_years(nowdate(), expires_after_yrs) + certificate = frappe.get_doc({ "doctype": "LMS Certification", "student": frappe.session.user, "course": course, "issue_date": nowdate(), - "expiry_date": add_years(nowdate(), int(expires_after_yrs)) + "expiry_date": expiry_date }) certificate.save(ignore_permissions=True) return certificate.name diff --git a/community/lms/doctype/lms_course/lms_course.json b/community/lms/doctype/lms_course/lms_course.json index 82463ede..d8c4d9e2 100644 --- a/community/lms/doctype/lms_course/lms_course.json +++ b/community/lms/doctype/lms_course/lms_course.json @@ -29,7 +29,10 @@ "section_break_5", "short_introduction", "description", - "chapters" + "chapters", + "certification_section", + "enable_certification", + "expiry" ], "fields": [ { @@ -119,6 +122,25 @@ { "fieldname": "column_break_11", "fieldtype": "Column Break" + }, + { + "fieldname": "certification_section", + "fieldtype": "Section Break", + "label": "Certification" + }, + { + "default": "0", + "fieldname": "enable_certification", + "fieldtype": "Check", + "label": "Enable Certification" + }, + { + "default": "0", + "depends_on": "enable_certification", + "fieldname": "expiry", + "fieldtype": "Select", + "label": "Certification Expires After Years", + "options": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10" } ], "index_web_pages_for_search": 1, @@ -140,7 +162,7 @@ "link_fieldname": "course" } ], - "modified": "2021-08-20 11:01:15.795219", + "modified": "2021-08-25 11:04:57.211898", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course", diff --git a/community/lms/md.py b/community/lms/md.py index 73be75d9..14d27813 100644 --- a/community/lms/md.py +++ b/community/lms/md.py @@ -20,6 +20,7 @@ import markdown from markdown import Extension from markdown.inlinepatterns import InlineProcessor import xml.etree.ElementTree as etree +import html as HTML def markdown_to_html(text): """Renders markdown text into html. @@ -109,4 +110,5 @@ def sanitize_html(html, macro): classname = "" if macro == "YouTubeVideo": classname = "lesson-video" + return "
" + "\n".join(str(node) for node in nodes) + "
" diff --git a/community/plugins.py b/community/plugins.py index 4c3066fb..b81a9b94 100644 --- a/community/plugins.py +++ b/community/plugins.py @@ -106,3 +106,6 @@ def youtube_video_renderer(video_id): allowfullscreen> """ + +def video_renderer(src): + return "".format(src) diff --git a/community/public/css/style.css b/community/public/css/style.css index dee90122..b006c55a 100644 --- a/community/public/css/style.css +++ b/community/public/css/style.css @@ -1414,17 +1414,24 @@ textarea.form-control { } .certificate-page .common-card-style { - flex-direction: column; font-family: Inter; color: black; - font-size: 2rem; - text-align: center; + width: 40%; + margin: 0 auto; +} + +.certificate-content { padding: 5rem; - background-image: url(/assets/community/images/certificate-background.png); +} + +.certificate-ribbon { + background-color: var(--primary-color); + margin-right: 2rem; + width: 20%; } .certificate-heading { - font-size: 4rem; + font-size: 2rem; margin-bottom: 3rem; font-weight: bold; } @@ -1433,18 +1440,47 @@ textarea.form-control { margin-bottom: 3rem; } -@media (max-width: 768px) { - .certificate-page .common-card-style { - padding: 2rem; - font-size: 1.5rem; - } +.certificate-logo { + height: 20px; + margin-top: 2rem; +} - .certificate-heading { - font-size: 3rem; +@media (max-width: 1024px) { + .certificate-content { + padding: 3rem; } } -@media (max-width: 360px) { + +@media (max-width: 768px) { + .certificate-page .common-card-style { + width: 50%; + } + + .certificate-content { + padding: 2rem; + } + + .certificate-ribbon { + margin-right: 1rem; + } + + .certificate-heading { + font-size: 2rem; + } +} + +@media (max-width: 550px) { + .certificate-page .common-card-style { + width: 60%; + } +} + +@media (max-width: 500px) { + .certificate-page .common-card-style { + width: 90%; + } + .certificate-heading { font-size: 2rem; } diff --git a/community/templates/certificate.html b/community/templates/certificate.html index eb0aaf51..8ac8216f 100644 --- a/community/templates/certificate.html +++ b/community/templates/certificate.html @@ -1,32 +1,35 @@
-
- Certificate of Completion -
-
- This is to certify that {{ student.full_name }} has successfully completed - {{ course.title }} online course on - {{ frappe.utils.format_date(certificate.issue_date, "medium") }} -
-