LMS: Fixed views for article and video
diff --git a/erpnext/education/doctype/video/video.json b/erpnext/education/doctype/video/video.json
index d10f196..d8c3368 100644
--- a/erpnext/education/doctype/video/video.json
+++ b/erpnext/education/doctype/video/video.json
@@ -54,7 +54,7 @@
"collapsible": 0,
"columns": 0,
"fieldname": "description",
- "fieldtype": "Data",
+ "fieldtype": "Text Editor",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -185,7 +185,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-10-17 06:57:00.219252",
+ "modified": "2018-10-18 12:26:47.709081",
"modified_by": "Administrator",
"module": "Education",
"name": "Video",
diff --git a/erpnext/www/lms/course.html b/erpnext/www/lms/course.html
index 5e2e393..9896b01 100644
--- a/erpnext/www/lms/course.html
+++ b/erpnext/www/lms/course.html
@@ -1,45 +1,41 @@
{% extends "frappe_theme/templates/base.html" %}
{% block title %}ERPNext Academy{% endblock %}
-
{% from "templates/includes/media.html" import media %}
-
{% block head_include %}
<meta name="description" content="ERPNext Academy is a learnig platform to gain expertise in the world's top 100% open source ERP software." />
<meta name="keywords" content="ERP Software, Cloud ERP, Open Source ERP, Accounting Software, Online ERP, Online Accounting, ERP for small business, Learn ERP, ERPNext Academy, Learn ERPNext, Learn Accounting" />
{% endblock %}
-
{% block content %}
-<div id="content-holder" data-type="{{current_content.content_type}}" data-content="{{ current_content.name }}" data-course="{{ current_course.name }}" data-program="{{ current_program }}">
-{% with quiz = quiz, current_content = current_content, next_content = next_content, course_name = course_name, program=current_program%}
-{% include "www/lms/templates/includes/" + current_content.content_type.lower() + ".html" %}
-{% endwith %}
+<div id="content-holder" data-type="{{ content_type }}" data-content="{{ current_content.name }}" data-course="{{ course_name }}" data-program="{{ program_name }}">
+ {% with content = current_content, next_content = next_content, course_name = course_name, program_name = program_name %}
+ {% include "www/lms/templates/includes/" + content_type.lower() + ".html" %}
+ {% endwith %}
</div>
<style>
- .footer-message {
- display: none;
- }
+.footer-message {
+ display: none;
+}
- .video-top-section {
- padding-top: 3rem !important;
- padding-bottom: 1rem !important;
- }
+.video-top-section {
+ padding-top: 3rem !important;
+ padding-bottom: 1rem !important;
+}
- .video-description-section {
- padding-top: 0em !important;
- }
+.video-description-section {
+ padding-top: 0em !important;
+}
- .article-top-section {
- padding-top: 3rem !important;
- padding-bottom: 0rem !important;
- }
+.article-top-section {
+ padding-top: 3rem !important;
+ padding-bottom: 0rem !important;
+}
- .article-content-section {
- padding-top: 0em !important;
- }
+.article-content-section {
+ padding-top: 0em !important;
+}
- .quiz-section {
- padding-top: 0rem !important;
- }
+.quiz-section {
+ padding-top: 0rem !important;
+}
</style>
-
{% endblock %}
\ No newline at end of file
diff --git a/erpnext/www/lms/course.js b/erpnext/www/lms/course.js
index e8f1dd5..a25d00e 100644
--- a/erpnext/www/lms/course.js
+++ b/erpnext/www/lms/course.js
@@ -34,4 +34,4 @@
"program": $('#content-holder').data('program'),
}
})
-}
\ No newline at end of file
+}
diff --git a/erpnext/www/lms/course.py b/erpnext/www/lms/course.py
index 19e495f..9e87427 100644
--- a/erpnext/www/lms/course.py
+++ b/erpnext/www/lms/course.py
@@ -1,23 +1,31 @@
from __future__ import unicode_literals
import erpnext.education.utils as utils
+from urlparse import urlparse, parse_qs
import frappe
def get_context(context):
if frappe.form_dict['course']:
- context.current_content = frappe.get_doc("Content", frappe.form_dict["content"])
- context.course_name = frappe.form_dict["course"]
- context.current_course = utils.get_contents_in_course(context.course_name)
- context.current_program = frappe.form_dict["program"]
- context.next_content = get_next_content(context)
- if context.current_content.content_type == "Quiz":
- context.questions = utils.get_quiz_as_dict(context.current_content.name)
+ # Save form_dict variables
+ program_name = frappe.form_dict["program"]
+ course_name = frappe.form_dict["course"]
+ content_name = frappe.form_dict["content"]
+ content_type = frappe.form_dict["type"]
+ # Get the required doctypes
+ current_course = frappe.get_doc("Course", course_name)
+ current_content = frappe.get_doc(content_type, content_name)
-def get_next_content(context):
- if context.current_course:
- course_data = [content.name for content in context.current_course]
- try:
- return course_data[course_data.index(context.current_content.name) + 1]
- except IndexError:
- return None
\ No newline at end of file
+ # Saving context variables for Jinja
+ context.current_content = current_content
+ context.course_name = course_name
+ context.program_name = program_name
+ context.content_type = content_type
+ context.next_content_type, context.next_content = get_next_content(content_name, content_type, current_course.get_content_info())
+
+def get_next_content(c_name, c_type, content_list):
+ try:
+ next = content_list[content_list.index([c_type, c_name]) + 1]
+ return next[0], next[1]
+ except IndexError:
+ return None, None
\ No newline at end of file
diff --git a/erpnext/www/lms/program.html b/erpnext/www/lms/program.html
index 5c1f159..00e13cb 100644
--- a/erpnext/www/lms/program.html
+++ b/erpnext/www/lms/program.html
@@ -11,7 +11,7 @@
<div class='card-body'>
<div class="row">
<div class="course-details col-xs-8 col-sm-9 col-md-10">
- <h5>{{ course.name }}</h5>
+ <h5>{{ course.course_name }}</h5>
<span class="course-list text-muted" id="getting-started">
Course Content
<ul class="mb-0 mt-1">
@@ -22,7 +22,7 @@
</span>
</div>
<div class='text-center col-xs-4 col-sm-3 col-md-2'>
- <a class='btn btn-primary btn-sm btn-block' href="/lms/course?program={{ program.program_code }}&course={{ course.name }}&content={{ course.course_content[0].content }}">Start Course</a>
+ <a class='btn btn-primary btn-sm btn-block' href="/lms/course?program={{ program.program_code }}&course={{ course.name }}&type={{course.course_content[0].content_type}}&content={{ course.course_content[0].content }}">Start Course</a>
</div>
</div>
</div>
diff --git a/erpnext/www/lms/program.py b/erpnext/www/lms/program.py
index c5bf018..10bdd6b 100644
--- a/erpnext/www/lms/program.py
+++ b/erpnext/www/lms/program.py
@@ -4,5 +4,8 @@
def get_context(context):
- context.program = frappe.get_doc("Program", frappe.form_dict["program"])
- context.course_list = utils.get_courses_in_program(frappe.form_dict["program"])
\ No newline at end of file
+ program = frappe.get_doc("Program", frappe.form_dict["program"])
+ course_list = program.get_course_list()
+
+ context.program = program
+ context.course_list = course_list
\ No newline at end of file
diff --git a/erpnext/www/lms/templates/includes/article.html b/erpnext/www/lms/templates/includes/article.html
index 2ca93fa..15835b8 100644
--- a/erpnext/www/lms/templates/includes/article.html
+++ b/erpnext/www/lms/templates/includes/article.html
@@ -2,19 +2,15 @@
<div class='container'>
<div class="row">
<div class="col-md-8">
- <h2>{{ current_content.name }}</h2>
+ <h2>{{ content.title }}</h2>
<span class="text-muted">
- <i class="octicon octicon-clock" title="Duration"></i> 49 Mins
- — Published on 28th October 2018.
+ Published on {{ content.publish_date }}, by {{ content.author }}
</span>
</div>
<div class="col-md-4 text-right">
- <a class='btn btn-outline-secondary' href="#">Previous</a>
- {% if next_content != None %}
- <a class='btn btn-primary' onclick="addActivity()" href="/lms/course?program={{ program }}&course={{ course_name }}&content={{ next_content }}">Next</a>
- {% else %}
- <a class='btn btn-primary' onclick="addActivity()" href="/lms/program?program={{ program }}">Finish Course</a>
- {% endif %}
+ {% with next_content = next_content, course_name = course_name, program_name = program_name %}
+ {% include "www/lms/templates/includes/lms-nav.html" %}
+ {% endwith %}
</div>
</div>
<hr>
@@ -23,11 +19,12 @@
<section class="article-content-section">
<div class='container'>
<div class="content">
- {{ current_content.article_content }}
+ {{ content.content }}
</div>
- <div class="text-right hidden">
- <a class='btn btn-outline-secondary' href="/classrooms/module">Previous</a>
- <a class='btn btn-primary' href="/lms/course?program={{ program }}&course={{ course_name }}&content={{ next_content }}">Next</a>
+ <div class="text-right">
+ {% with next_content = next_content, course_name = course_name, program_name = program_name %}
+ {% include "www/lms/templates/includes/lms-nav.html" %}
+ {% endwith %}
</div>
<div class="mt-3 text-right">
<a class="text-muted" href="/report"><i class="octicon octicon-issue-opened" title="Report"></i> Report a
diff --git a/erpnext/www/lms/templates/includes/lms-nav.html b/erpnext/www/lms/templates/includes/lms-nav.html
new file mode 100644
index 0000000..64932f6
--- /dev/null
+++ b/erpnext/www/lms/templates/includes/lms-nav.html
@@ -0,0 +1,6 @@
+<a class='btn btn-outline-secondary' href="#">Previous</a>
+{% if next_content != None %}
+<a class='btn btn-primary' onclick="addActivity()" href="/lms/course?program={{ program_name }}&course={{ course_name }}&type={{ next_content_type }}&content={{ next_content }}">Next</a>
+{% else %}
+<a class='btn btn-primary' onclick="addActivity()" href="/lms/program?program={{ program_name }}">Finish Course</a>
+{% endif %}
\ No newline at end of file
diff --git a/erpnext/www/lms/templates/includes/video.html b/erpnext/www/lms/templates/includes/video.html
index 6727321..e3ddacb 100644
--- a/erpnext/www/lms/templates/includes/video.html
+++ b/erpnext/www/lms/templates/includes/video.html
@@ -1,23 +1,20 @@
<section class='video-top-section video-section-bg'>
<div class='container'>
<div class="embed-responsive embed-responsive-16by9">
- <iframe class="embed-responsive-item" src="https://www.youtube.com/embed/{{ current_content.video_url }}" allowfullscreen></iframe>
+ <iframe class="embed-responsive-item" src="https://www.youtube.com/embed/{{ content.url.split('v=')[1].split('&')[0] }}" allowfullscreen></iframe>
</div>
<div class="mt-3 row">
<div class="col-md-8">
- <h2>{{ current_content.name }}</h2>
+ <h2>{{ content.name }}</h2>
<span class="text-muted">
- <i class="octicon octicon-clock" title="Duration"></i> 49 Mins
- — Published on 28th October 2018.
+ <i class="octicon octicon-clock" title="Duration"></i> {{ content.duration }} Mins
+ — Published on {{ content.publish_date }}.
</span>
</div>
<div class="col-md-4 text-right">
- <a class='btn btn-outline-secondary' href="#">Previous</a>
- {% if next_content != None %}
- <a class='btn btn-primary' onclick="addActivity()" href="/lms/course?program={{ program }}&course={{ course_name }}&content={{ next_content }}">Next</a>
- {% else %}
- <a class='btn btn-primary' onclick="addActivity()" href="/lms/program?program={{ program }}">Finish Course</a>
- {% endif %}
+ {% with next_content = next_content, course_name = course_name, program_name = program_name %}
+ {% include "www/lms/templates/includes/lms-nav.html" %}
+ {% endwith %}
</div>
</div>
<hr>
@@ -26,7 +23,7 @@
<section class="video-description-section">
<div class='container'>
<div class="content">
- {{ current_content.video_description }}
+ {{ content.description }}
</div>
<div class="text-right hidden">
<a class='btn btn-outline-secondary' href="/classrooms/module">Previous</a>