feat: added topic page
diff --git a/erpnext/www/lms/course.html b/erpnext/www/lms/course.html
index 1182eb9..d046ac8 100644
--- a/erpnext/www/lms/course.html
+++ b/erpnext/www/lms/course.html
@@ -36,7 +36,7 @@
<div class="col-sm-{{ 12 if length%3 == 1 and index == 1 else 6 if length%3 == 2 and index in [1,2] else 4}} mb-4 text-left">
<div class="card h-100">
{% if has_access %}
- <a href="/lms/content?program={{ program }}&course={{ course.name }}&topic={{ topic.name }}&type={{ topic.topic_content[0].content_type }}&content={{ topic.topic_content[0].content }}" class="no-decoration no-underline">
+ <a href="/lms/topic?program={{ program }}&course={{ course.name }}&topic={{ topic.name }}" class="no-decoration no-underline">
{% else %}
<div>
{% endif %}
@@ -72,7 +72,7 @@
{% elif progress[topic.name].started %}
<span class="indicator orange">In Progress</span>
{% else %}
- <span class="indicator blue">Open</span>
+ <span class="indicator blue">Start</span>
{% endif %}
</div>
</a>
@@ -85,11 +85,11 @@
{% block content %}
<section class="section ">
- {{ hero(course.course_name, course.course_intro, has_access, {'name': 'Program', 'url': '/lms/program?program=' + program }) }}
+ {{ hero(course.course_name, course.description, has_access, {'name': 'Program', 'url': '/lms/program?program=' + program }) }}
<div class='container'>
<div class="row mt-5">
{% for topic in topics %}
- {{ card(topic.as_dict(), loop.index, topics|length) }}
+ {{ card(topic, loop.index, topics|length) }}
{% endfor %}
</div>
</div>
diff --git a/erpnext/www/lms/macros/hero.html b/erpnext/www/lms/macros/hero.html
index d9c4059..85052e1 100644
--- a/erpnext/www/lms/macros/hero.html
+++ b/erpnext/www/lms/macros/hero.html
@@ -2,7 +2,7 @@
<div class='container pb-5'>
<div class="mb-3">
<a href="{{ back.url }}" class="text-muted">
- <i class="fa fa-chevron-left"></i> Back to {{ back.name }}
+ <i class="octicon octicon-chevron-left"></i> Back to {{ back.name }}
</a>
</div>
<h1>{{ title }}</h1>
diff --git a/erpnext/www/lms/program.html b/erpnext/www/lms/program.html
index 07536da..615abd5 100644
--- a/erpnext/www/lms/program.html
+++ b/erpnext/www/lms/program.html
@@ -45,7 +45,7 @@
{% endif %}
<div class='card-body'>
<h5 class='card-title'>{{ course.course_name }}</h5>
- <div>{{ course.course_intro or '' }}</div>
+ <div>{{ course.description or '' }}</div>
</div>
{% if has_access and progress[course.name] %}
<div class='card-footer'>
@@ -54,7 +54,7 @@
{% elif progress[course.name].started %}
<span class="indicator orange">In Progress</span>
{% else %}
- <span class="indicator blue">Open</span>
+ <span class="indicator blue">Start</span>
{% endif %}
</div>
{% endif %}
diff --git a/erpnext/www/lms/topic.html b/erpnext/www/lms/topic.html
new file mode 100644
index 0000000..bb96007
--- /dev/null
+++ b/erpnext/www/lms/topic.html
@@ -0,0 +1,44 @@
+{% extends "templates/base.html" %}
+{% block title %}Topic Title{% endblock %}
+{% from "www/lms/macros/hero.html" import hero %}
+
+
+{% macro card(content, index, length) %}
+<div class="col-sm-{{ 12 if length%3 == 1 and index == 1 else 6 if length%3 == 2 and index in [1,2] else 4}} mb-4 text-left">
+ <a href="/lms/content?program={{ program }}&course={{ course }}&topic={{ topic.name }}&type={{ content.content_type }}&content={{ content.content.name }}" class="no-decoration no-underline">
+ <div class="card h-100">
+ <div class='card-body'>
+ <div>{{ content.content_type or '' }}</div>
+ <h5 class='card-title'>{{ content.content.name }}</h5>
+ </div>
+ {% if has_access %}
+ <div class='card-footer'>
+ {% if content.content_type == 'Quiz' %}
+ {% if content.result == 'Fail' %} <span class="indicator red">Fail <span class="text-muted">({{ content.score }}/100)</span></span>
+ {% elif content.result == 'Pass' %} <span class="indicator green">Pass <span class="text-muted">({{ content.score }}/100)</span>
+ {% else %} <span class="indicator blue">Start</span>
+ {% endif %}
+ {% else %}
+ {% if content.completed %} <span class="indicator green">Completed</span>
+ {% else %} <span class="indicator blue">Start</span>
+ {% endif %}
+ {% endif %}
+ </div>
+ {% endif %}
+ </div>
+ </a>
+</div>
+{% endmacro %}
+
+{% block content %}
+<section class="section">
+ {{ hero(topic.topic_name, topic.description, has_access, {'name': 'Course', 'url': '/lms/course?name=' + course +'&program=' + program}) }}
+ <div class='container'>
+ <div class="row mt-5">
+ {% for content in contents %}
+ {{ card(content, loop.index, topic.contents|length) }}
+ {% endfor %}
+ </div>
+ </div>
+</section>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/www/lms/topic.py b/erpnext/www/lms/topic.py
new file mode 100644
index 0000000..d2c6da3
--- /dev/null
+++ b/erpnext/www/lms/topic.py
@@ -0,0 +1,34 @@
+from __future__ import unicode_literals
+import erpnext.education.utils as utils
+import frappe
+
+no_cache = 1
+
+def get_context(context):
+ course = frappe.form_dict['course']
+ program = frappe.form_dict['program']
+ topic = frappe.form_dict['topic']
+
+ context.program = program
+ context.course = course
+ context.topic = frappe.get_doc("Topic", topic)
+ context.contents = get_contents(context.topic, course, program)
+ context.has_access = utils.allowed_program_access(program)
+
+def get_contents(topic, course, program):
+ student = utils.get_current_student()
+ if not student:
+ return None
+ course_enrollment = utils.get_or_create_course_enrollment(course, program)
+ contents = topic.get_contents()
+ progress = []
+ if contents:
+ for content in contents:
+ if content.doctype in ('Article', 'Video'):
+ status = utils.check_content_completion(content.name, content.doctype, course_enrollment.name)
+ progress.append({'content': content, 'content_type': content.doctype, 'completed': status})
+ elif content.doctype == 'Quiz':
+ status, score, result = utils.check_quiz_completion(content, course_enrollment.name)
+ progress.append({'content': content, 'content_type': content.doctype, 'completed': status, 'score': score, 'result': result})
+
+ return progress
\ No newline at end of file