LMS: Course Completion Status Working

This commit is contained in:
scmmishra 2018-10-24 16:46:46 +05:30 committed by Aditya Hase
parent a8703d4036
commit 1e1f1ad186
8 changed files with 77 additions and 18 deletions

View File

@ -144,6 +144,40 @@
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "0",
"fieldname": "completed",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Completed",
"length": 0,
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
"has_web_view": 0,
@ -156,7 +190,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-10-19 17:46:46.595749",
"modified": "2018-10-24 16:05:02.961543",
"modified_by": "Administrator",
"module": "Education",
"name": "Course Enrollment",

View File

@ -99,6 +99,8 @@ def add_quiz_activity(enrollment, quiz, score, answers, quiz_response):
@frappe.whitelist()
def add_activity(content_type, content, course, program):
if content_type == "Quiz":
pass
enrollment = get_course_enrollment(course, frappe.session.user)
if check_activity_exists(enrollment['name'], content_type, content):
pass
@ -168,3 +170,17 @@ def get_student_id(email=None):
except IndexError:
frappe.throw("Student with email {0} does not exist".format(email))
return None
@frappe.whitelist()
def mark_course_complete(course):
try:
enrollment_name = get_course_enrollment(course, frappe.session.user)
enrollment = frappe.get_doc("Course Enrollment", enrollment_name)
enrollment.completed = 1
enrollment.save()
pass
except:
import traceback
traceback.print_exc()
frappe.throw("The user is not enrolled for the course {course}".format(course=course))
return None

View File

@ -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>

View File

@ -35,3 +35,13 @@ function addActivity() {
}
})
}
function addFinalActivity() {
addActivity()
frappe.call({
method: "erpnext.education.utils.mark_course_complete",
args: {
"course": $('#content-holder').data('course'),
},
})
}

View File

@ -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">

View File

@ -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>

View File

@ -9,3 +9,13 @@ def get_context(context):
context.program = program
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

View File

@ -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 %}