LMS: Course Completion Status Working
diff --git a/erpnext/www/lms/course.html b/erpnext/www/lms/course.html
index 11b134d..799480b 100644
--- a/erpnext/www/lms/course.html
+++ b/erpnext/www/lms/course.html
@@ -1,13 +1,8 @@
{% 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="{{ content_type }}" data-content="{{ content.name }}" data-course="{{ course_name }}" data-program="{{ program_name }}">
-
{% include "www/lms/templates/includes/" + content_type.lower() + ".html" %}
</div>
diff --git a/erpnext/www/lms/course.js b/erpnext/www/lms/course.js
index d24c024..b4eb8f7 100644
--- a/erpnext/www/lms/course.js
+++ b/erpnext/www/lms/course.js
@@ -35,3 +35,13 @@
}
})
}
+
+function addFinalActivity() {
+ addActivity()
+ frappe.call({
+ method: "erpnext.education.utils.mark_course_complete",
+ args: {
+ "course": $('#content-holder').data('course'),
+ },
+ })
+}
diff --git a/erpnext/www/lms/index.html b/erpnext/www/lms/index.html
index 444bbde..c39ee6e 100644
--- a/erpnext/www/lms/index.html
+++ b/erpnext/www/lms/index.html
@@ -3,11 +3,6 @@
{% 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 %}
-
{% macro featured_card(program_name, description, hero_image, code) %}
<div class='card-deck mt-5'>
<div class="card">
diff --git a/erpnext/www/lms/program.html b/erpnext/www/lms/program.html
index 00e13cb..bee0136 100644
--- a/erpnext/www/lms/program.html
+++ b/erpnext/www/lms/program.html
@@ -1,11 +1,6 @@
{% extends "frappe_theme/templates/base.html" %}
{% block title %}ERPNext Academy{% endblock %}
-{% 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 %}
-
{% macro course_card(course) %}
<div class="card mt-3" data-list="getting-started">
<div class='card-body'>
@@ -22,7 +17,11 @@
</span>
</div>
<div class='text-center col-xs-4 col-sm-3 col-md-2'>
+ {% if not check_complete(course.name) %}
<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>
+ {% else %}
+ <a class='btn btn-success 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 }}">Complete</a>
+ {% endif %}
</div>
</div>
</div>
diff --git a/erpnext/www/lms/program.py b/erpnext/www/lms/program.py
index 10bdd6b..a8c9c0e 100644
--- a/erpnext/www/lms/program.py
+++ b/erpnext/www/lms/program.py
@@ -8,4 +8,14 @@
course_list = program.get_course_list()
context.program = program
- context.course_list = course_list
\ No newline at end of file
+ context.course_list = course_list
+ context.check_complete = check_complete
+
+
+def check_complete(course_name):
+ try:
+ enrollment = utils.get_course_enrollment(course_name, frappe.session.user)
+ completed = frappe.get_value('Course Enrollment', enrollment['name'], "completed")
+ return bool(completed)
+ except:
+ return False
\ No newline at end of file
diff --git a/erpnext/www/lms/templates/includes/lms-nav.html b/erpnext/www/lms/templates/includes/lms-nav.html
index 64932f6..efd1b8b 100644
--- a/erpnext/www/lms/templates/includes/lms-nav.html
+++ b/erpnext/www/lms/templates/includes/lms-nav.html
@@ -2,5 +2,5 @@
{% 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>
+<a class='btn btn-primary' onclick="addFinalActivity()" href="/lms/program?program={{ program_name }}">Finish Course</a>
{% endif %}
\ No newline at end of file