From 6660a675f16887491645b29a8804e1606f99e4f0 Mon Sep 17 00:00:00 2001 From: scmmishra Date: Mon, 8 Oct 2018 17:18:11 +0530 Subject: [PATCH] templates: add templates for LMS content Co-authored-by: Chinmay Pai --- erpnext/www/lms/course.html | 65 ++++++------------- erpnext/www/lms/course.py | 10 ++- erpnext/www/lms/program.html | 2 +- erpnext/www/lms/program.py | 13 ++-- .../www/lms/templates/includes/article.html | 33 ++++++++++ erpnext/www/lms/templates/includes/quiz.html | 56 ++++++++++++++++ erpnext/www/lms/templates/includes/video.html | 36 ++++++++++ 7 files changed, 159 insertions(+), 56 deletions(-) create mode 100644 erpnext/www/lms/templates/includes/article.html create mode 100644 erpnext/www/lms/templates/includes/quiz.html create mode 100644 erpnext/www/lms/templates/includes/video.html diff --git a/erpnext/www/lms/course.html b/erpnext/www/lms/course.html index 4538b9f573..3acc76e5d0 100644 --- a/erpnext/www/lms/course.html +++ b/erpnext/www/lms/course.html @@ -8,56 +8,33 @@ {% endblock %} -{% macro video(id) %} -
- -
-{% endmacro %} {% block content %} -
-
- {% if lesson.video_url is defined %} - {{ video("lesson,video") }} - {% endif %} -
-
-

{{ lesson.name }}

- - 49 Mins - — Published on 28th October 2018. - -
-
- Previous - Next -
-
-
-
-
-{% for lesson in lesson_list %} - {{ lesson }} -{% endfor %} -
-
-
- {{ lesson.content }} -
- - -
- -
+{% with current_content = current_content %} +{% include "www/lms/templates/includes/" + current_content.content_type.lower() + ".html" %} +{% endwith %} {% endblock %} \ No newline at end of file diff --git a/erpnext/www/lms/course.py b/erpnext/www/lms/course.py index 453c9c7905..ff7073dc9c 100644 --- a/erpnext/www/lms/course.py +++ b/erpnext/www/lms/course.py @@ -1,2 +1,8 @@ -# current_module = frappe.get_doc("Course", frappe.form_dict["lesson"]) -# current_lesson = frappe.get_doc("Lesson", frappe.form_dict["lesson"]) \ No newline at end of file +from __future__ import unicode_literals +import frappe + + +def get_context(context): + context.current_course = frappe.get_doc("Course", frappe.form_dict["course"]) + context.current_content = frappe.get_doc("Content", frappe.form_dict["content"]) + next_content = get_next_content() \ No newline at end of file diff --git a/erpnext/www/lms/program.html b/erpnext/www/lms/program.html index e079b4155a..449c040c42 100644 --- a/erpnext/www/lms/program.html +++ b/erpnext/www/lms/program.html @@ -22,7 +22,7 @@ diff --git a/erpnext/www/lms/program.py b/erpnext/www/lms/program.py index 809e6cdd2d..b6ebcf44d2 100644 --- a/erpnext/www/lms/program.py +++ b/erpnext/www/lms/program.py @@ -2,18 +2,13 @@ from __future__ import unicode_literals import frappe -# Get the classroom's route parameter from the url -url_param = frappe.form_dict["code"] -# Get classroom from classroom_name -current_program = frappe.get_doc("Program", url_param) - def get_context(context): - context.program = current_program - context.course_list, context.course_data = get_courses() + context.program = frappe.get_doc("Program", frappe.form_dict["code"]) + context.course_list, context.course_data = get_courses(context) -def get_courses(): +def get_courses(context): course_data = {} - course_names = [program.course_name for program in current_program.courses] + course_names = [program.course_name for program in context.program.courses] program_courses = [frappe.get_doc('Course', name) for name in course_names] for course_item in program_courses: course_data[course_item.name] = [content_item.content for content_item in course_item.course_content if content_item.content_type in ('Video', 'Article')] diff --git a/erpnext/www/lms/templates/includes/article.html b/erpnext/www/lms/templates/includes/article.html new file mode 100644 index 0000000000..f9fd6e0036 --- /dev/null +++ b/erpnext/www/lms/templates/includes/article.html @@ -0,0 +1,33 @@ +
+
+
+
+

{{ current_content.name }}

+ + 49 Mins + — Published on 28th October 2018. + +
+
+ Previous + Next +
+
+
+
+
+
+
+
+ {{ current_content.article_content }} +
+ + +
+
\ No newline at end of file diff --git a/erpnext/www/lms/templates/includes/quiz.html b/erpnext/www/lms/templates/includes/quiz.html new file mode 100644 index 0000000000..97a2e6828c --- /dev/null +++ b/erpnext/www/lms/templates/includes/quiz.html @@ -0,0 +1,56 @@ +{% macro quiz(question, opt1, opt2, opt3, opt4) %} +
+
{{ question }}
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+{% endmacro %} + +
+
+
+
+

Quiz — Accounting with ERPNext

+
+
+
+
+
+ {{ quiz('1. What is a Sales Invoice?','The bills that you raise to your Customers for the products or services you provide.','Bills that your Suppliers give you for their products or services.','The bills for accounting entries, like payments, credit and other types.','The bills that were recovered from an oblivion of files and folders stacked in a old and rusty closet.') }} + {{ quiz('2. How to create a Sales Invoice?','Accounts > Billing > Sales Invoice > New Sales Invoice','Accounts > Buying > New Sales Invoice','Accounts > CRM > New Sales Invoice','Accounts > Purchases > New Sales Invoice') }} + {{ quiz('3. The long term assets that have no physical existence but are rights that have value is known as','Current Assets','Fixed Assets','Intangible Assets','Investments') }} +
+ + +
+
+
+ +
+
\ No newline at end of file diff --git a/erpnext/www/lms/templates/includes/video.html b/erpnext/www/lms/templates/includes/video.html new file mode 100644 index 0000000000..77a4e6cc97 --- /dev/null +++ b/erpnext/www/lms/templates/includes/video.html @@ -0,0 +1,36 @@ +
+
+
+ +
+
+
+

{{ current_content.name }}

+ + 49 Mins + — Published on 28th October 2018. + +
+
+ Previous + Next +
+
+
+
+
+
+
+
+ {{ current_content.video_description }} +
+ + +
+
\ No newline at end of file