From 41e2959389c0c5c878e6fda13bebb3e99071d074 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 28 Apr 2022 10:41:30 +0530 Subject: [PATCH] chore: remove files related to LMS --- erpnext/domains/education.py | 19 -- erpnext/hooks.py | 1 - erpnext/projects/doctype/project/project.py | 16 +- .../js/education/assessment_result_tool.html | 72 ----- erpnext/public/js/education/lms/quiz.js | 238 ----------------- erpnext/www/lms/__init__.py | 0 erpnext/www/lms/content.html | 246 ------------------ erpnext/www/lms/content.py | 75 ------ erpnext/www/lms/course.html | 106 -------- erpnext/www/lms/course.py | 28 -- erpnext/www/lms/index.html | 69 ----- erpnext/www/lms/index.py | 17 -- erpnext/www/lms/macros/__init__.py | 0 erpnext/www/lms/macros/card.html | 34 --- erpnext/www/lms/macros/hero.html | 53 ---- erpnext/www/lms/profile.html | 64 ----- erpnext/www/lms/profile.py | 37 --- erpnext/www/lms/program.html | 87 ------- erpnext/www/lms/program.py | 32 --- erpnext/www/lms/topic.html | 58 ----- erpnext/www/lms/topic.py | 57 ---- 21 files changed, 14 insertions(+), 1295 deletions(-) delete mode 100644 erpnext/domains/education.py delete mode 100644 erpnext/public/js/education/assessment_result_tool.html delete mode 100644 erpnext/public/js/education/lms/quiz.js delete mode 100644 erpnext/www/lms/__init__.py delete mode 100644 erpnext/www/lms/content.html delete mode 100644 erpnext/www/lms/content.py delete mode 100644 erpnext/www/lms/course.html delete mode 100644 erpnext/www/lms/course.py delete mode 100644 erpnext/www/lms/index.html delete mode 100644 erpnext/www/lms/index.py delete mode 100644 erpnext/www/lms/macros/__init__.py delete mode 100644 erpnext/www/lms/macros/card.html delete mode 100644 erpnext/www/lms/macros/hero.html delete mode 100644 erpnext/www/lms/profile.html delete mode 100644 erpnext/www/lms/profile.py delete mode 100644 erpnext/www/lms/program.html delete mode 100644 erpnext/www/lms/program.py delete mode 100644 erpnext/www/lms/topic.html delete mode 100644 erpnext/www/lms/topic.py diff --git a/erpnext/domains/education.py b/erpnext/domains/education.py deleted file mode 100644 index 23b8258baf..0000000000 --- a/erpnext/domains/education.py +++ /dev/null @@ -1,19 +0,0 @@ -data = { - "desktop_icons": [ - "Student", - "Program", - "Course", - "Student Group", - "Instructor", - "Fees", - "Task", - "ToDo", - "Education", - "Student Attendance Tool", - "Student Applicant", - ], - "default_portal_role": "Student", - "restricted_roles": ["Student", "Instructor", "Academics User", "Education Manager"], - "modules": ["Education"], - "on_setup": "erpnext.education.setup.setup_education", -} diff --git a/erpnext/hooks.py b/erpnext/hooks.py index fe0a89a276..e1785626ee 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -69,7 +69,6 @@ treeviews = [ # website update_website_context = [ "erpnext.e_commerce.shopping_cart.utils.update_website_context", - "erpnext.education.doctype.education_settings.education_settings.update_website_context", ] my_account_context = "erpnext.e_commerce.shopping_cart.utils.update_my_account_context" webform_list_context = "erpnext.controllers.website_list_for_contact.get_webform_list_context" diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index 29f1ce455e..a97efffec8 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -11,10 +11,9 @@ from frappe.utils import add_days, flt, get_datetime, get_time, get_url, nowtime from erpnext.controllers.employee_boarding_controller import update_employee_boarding_status from erpnext.controllers.queries import get_filters_cond -from erpnext.education.doctype.student_attendance.student_attendance import get_holiday_list from erpnext.hr.doctype.daily_work_summary.daily_work_summary import get_users_email from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday - +from erpnext import get_default_company class Project(Document): def get_feed(self): @@ -665,3 +664,16 @@ def set_project_status(project, status): project.status = status project.save() + +def get_holiday_list(company=None): + if not company: + company = get_default_company() or frappe.get_all("Company")[0].name + + holiday_list = frappe.get_cached_value("Company", company, "default_holiday_list") + if not holiday_list: + frappe.throw( + _("Please set a default Holiday List for Company {0}").format( + frappe.bold(get_default_company()) + ) + ) + return holiday_list \ No newline at end of file diff --git a/erpnext/public/js/education/assessment_result_tool.html b/erpnext/public/js/education/assessment_result_tool.html deleted file mode 100644 index f7d1ab39fc..0000000000 --- a/erpnext/public/js/education/assessment_result_tool.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - {% for c in criteria %} - - {% endfor %} - - - - - - {% for c in criteria %} - - {% endfor %} - - - - - {% for s in students %} - - - - - {% for c in criteria %} - - {% endfor %} - - - {% endfor %} - -
StudentStudent Name{{ c.assessment_criteria }}CommentsTotal Marks
Score ({{ c.maximum_score }})Score ({{max_total_score}})
{{ s.student }}{{ s.student_name }} - - {% if(s.assessment_details) { %} - {{s.assessment_details[c.assessment_criteria][1]}} - {% } %} - - - - - - - {% if(s.assessment_details) { %} - {{s.assessment_details.total_score[1]}} - {% } %} - - - {% if(s.assessment_details) { %} - {{s.assessment_details.total_score[0]}} - {% } %} - - - - - - -
diff --git a/erpnext/public/js/education/lms/quiz.js b/erpnext/public/js/education/lms/quiz.js deleted file mode 100644 index 66160a7610..0000000000 --- a/erpnext/public/js/education/lms/quiz.js +++ /dev/null @@ -1,238 +0,0 @@ -class Quiz { - constructor(wrapper, options) { - this.wrapper = wrapper; - Object.assign(this, options); - this.questions = [] - this.refresh(); - } - - refresh() { - this.get_quiz(); - } - - get_quiz() { - frappe.call('erpnext.education.utils.get_quiz', { - quiz_name: this.name, - course: this.course - }).then(res => { - this.make(res.message) - }); - } - - make(data) { - if (data.is_time_bound) { - $(".lms-timer").removeClass("hide"); - if (!data.activity || (data.activity && !data.activity.is_complete)) { - this.initialiseTimer(data.duration); - this.is_time_bound = true; - this.time_taken = 0; - } - } - data.questions.forEach(question_data => { - let question_wrapper = document.createElement('div'); - let question = new Question({ - wrapper: question_wrapper, - ...question_data - }); - this.questions.push(question) - this.wrapper.appendChild(question_wrapper); - }) - if (data.activity && data.activity.is_complete) { - this.disable() - let indicator = 'red' - let message = 'Your are not allowed to attempt the quiz again.' - if (data.activity.result == 'Pass') { - indicator = 'green' - message = 'You have already cleared the quiz.' - } - if (data.activity.time_taken) { - this.calculate_and_display_time(data.activity.time_taken, "Time Taken - "); - } - this.set_quiz_footer(message, indicator, data.activity.score) - } - else { - this.make_actions(); - } - window.addEventListener('beforeunload', (event) => { - event.preventDefault(); - event.returnValue = ''; - }); - } - - initialiseTimer(duration) { - this.time_left = duration; - var self = this; - var old_diff; - this.calculate_and_display_time(this.time_left, "Time Left - "); - this.start_time = new Date().getTime(); - this.timer = setInterval(function () { - var diff = (new Date().getTime() - self.start_time)/1000; - var variation = old_diff ? diff - old_diff : diff; - old_diff = diff; - self.time_left -= variation; - self.time_taken += variation; - self.calculate_and_display_time(self.time_left, "Time Left - "); - if (self.time_left <= 0) { - clearInterval(self.timer); - self.time_taken -= 1; - self.submit(); - } - }, 1000); - } - - calculate_and_display_time(second, text) { - var timer_display = document.getElementsByClassName("lms-timer")[0]; - var hours = this.append_zero(Math.floor(second / 3600)); - var minutes = this.append_zero(Math.floor(second % 3600 / 60)); - var seconds = this.append_zero(Math.ceil(second % 3600 % 60)); - timer_display.innerText = text + hours + ":" + minutes + ":" + seconds; - } - - append_zero(time) { - return time > 9 ? time : "0" + time; - } - - make_actions() { - const button = document.createElement("button"); - button.classList.add("btn", "btn-primary", "mt-5", "mr-2"); - - button.id = 'submit-button'; - button.innerText = 'Submit'; - button.onclick = () => this.submit(); - this.submit_btn = button - this.wrapper.appendChild(button); - } - - submit() { - if (this.is_time_bound) { - clearInterval(this.timer); - $(".lms-timer").text(""); - } - this.submit_btn.innerText = 'Evaluating..' - this.submit_btn.disabled = true - this.disable() - frappe.call('erpnext.education.utils.evaluate_quiz', { - quiz_name: this.name, - quiz_response: this.get_selected(), - course: this.course, - program: this.program, - time_taken: this.is_time_bound ? this.time_taken : 0 - }).then(res => { - this.submit_btn.remove() - if (!res.message) { - frappe.throw(__("Something went wrong while evaluating the quiz.")) - } - - let indicator = 'red' - let message = 'Fail' - if (res.message.status == 'Pass') { - indicator = 'green' - message = 'Congratulations, you cleared the quiz.' - } - - this.set_quiz_footer(message, indicator, res.message.score) - }); - } - - set_quiz_footer(message, indicator, score) { - const div = document.createElement("div"); - div.classList.add("mt-5"); - div.innerHTML = `
-
-

${message}

-
Score: ${score}/100
-
- -
` - - this.wrapper.appendChild(div) - } - - disable() { - this.questions.forEach(que => que.disable()) - } - - get_selected() { - let que = {} - this.questions.forEach(question => { - que[question.name] = question.get_selected() - }) - return que - } -} - -class Question { - constructor(opts) { - Object.assign(this, opts); - this.make(); - } - - make() { - this.make_question() - this.make_options() - } - - get_selected() { - let selected = this.options.filter(opt => opt.input.checked) - if (this.type == 'Single Correct Answer') { - if (selected[0]) return selected[0].name - } - if (this.type == 'Multiple Correct Answer') { - return selected.map(opt => opt.name) - } - return null - } - - disable() { - let selected = this.options.forEach(opt => opt.input.disabled = true) - } - - make_question() { - let question_wrapper = document.createElement('h5'); - question_wrapper.classList.add('mt-3'); - question_wrapper.innerHTML = this.question; - this.wrapper.appendChild(question_wrapper); - } - - make_options() { - let make_input = (name, value) => { - let input = document.createElement('input'); - input.id = name; - input.name = this.name; - input.value = value; - input.type = 'radio'; - if (this.type == 'Multiple Correct Answer') - input.type = 'checkbox'; - input.classList.add('form-check-input'); - return input; - } - - let make_label = function (name, value) { - let label = document.createElement('label'); - label.classList.add('form-check-label'); - label.htmlFor = name; - label.innerText = value; - return label - } - - let make_option = function (wrapper, option) { - let option_div = document.createElement('div'); - option_div.classList.add('form-check', 'pb-1'); - let input = make_input(option.name, option.option); - let label = make_label(option.name, option.option); - option_div.appendChild(input); - option_div.appendChild(label); - wrapper.appendChild(option_div); - return { input: input, ...option }; - } - - let options_wrapper = document.createElement('div') - options_wrapper.classList.add('ml-2') - let option_list = [] - this.options.forEach(opt => option_list.push(make_option(options_wrapper, opt))) - this.options = option_list - this.wrapper.appendChild(options_wrapper) - } -} diff --git a/erpnext/www/lms/__init__.py b/erpnext/www/lms/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/www/lms/content.html b/erpnext/www/lms/content.html deleted file mode 100644 index d22ef66d2a..0000000000 --- a/erpnext/www/lms/content.html +++ /dev/null @@ -1,246 +0,0 @@ -{% extends "templates/base.html" %} -{% block title %}{{ content.name or 'Content Page' }}{% endblock %} - -{% block head_include %} - - -{% endblock %} - -{% macro title() %} -
- - {{_('Back to Course')}} - -
-
-

{{ content.name }} ({{ position + 1 }}/{{length}})

-
-
-{% endmacro %} - -{% macro navigation() %} - {% if previous %} - {{_('Previous')}} - {% else %} - {{ _('Back to Course') }} - {% endif %} - - {% if next %} - - {% else %} - - {% endif %} -{% endmacro %} - -{% macro video() %} -
- {{ title() }} -
- {% if content.duration %} - {{ content.duration }} {{_('Mins')}} - {% endif %} - - {% if content.publish_date and content.duration%} - - - {% endif %} - - {% if content.publish_date %} - {{_('Published on')}} {{ content.publish_date.strftime('%d, %b %Y') }} - {% endif %} -
-
-
-
- {{ content.description }} -
-{% endmacro %} - -{% macro article() %} -
- {{ title() }} -
- {% if content.author or content.publish_date %} - {{_('Published')}} - {% endif %} - {% if content.author %} - {{_('by')}} {{ content.author }} - {% endif %} - {% if content.publish_date %} - {{_('on')}} {{ content.publish_date.strftime('%d, %b %Y') }} - {% endif %} -
-
-
- {{ content.content }} -
-{% endmacro %} - -{% macro quiz() %} -
- {{ title() }} -
-
-
-{% endmacro %} - -{% block content %} -
-
-
- {% if content_type=='Video' %} - {{ video() }} - {% elif content_type=='Article'%} - {{ article() }} - {% elif content_type=='Quiz' %} - {{ quiz() }} - {% endif %} -
- {{ navigation() }} -
-
-
-
-{% endblock %} - -{% block script %} - {% if content_type=='Video' %} - - {% elif content_type == 'Quiz' %} - - {% endif %} - -{% endblock %} diff --git a/erpnext/www/lms/content.py b/erpnext/www/lms/content.py deleted file mode 100644 index 99462ceeee..0000000000 --- a/erpnext/www/lms/content.py +++ /dev/null @@ -1,75 +0,0 @@ -import frappe - -import erpnext.education.utils as utils - -no_cache = 1 - - -def get_context(context): - # Load Query Parameters - try: - program = frappe.form_dict["program"] - content = frappe.form_dict["content"] - content_type = frappe.form_dict["type"] - course = frappe.form_dict["course"] - topic = frappe.form_dict["topic"] - except KeyError: - frappe.local.flags.redirect_location = "/lms" - raise frappe.Redirect - - # Check if user has access to the content - has_program_access = utils.allowed_program_access(program) - has_content_access = allowed_content_access(program, content, content_type) - - if frappe.session.user == "Guest" or not has_program_access or not has_content_access: - frappe.local.flags.redirect_location = "/lms" - raise frappe.Redirect - - # Set context for content to be displayer - context.content = frappe.get_doc(content_type, content).as_dict() - context.content_type = content_type - context.program = program - context.course = course - context.topic = topic - - topic = frappe.get_doc("Topic", topic) - content_list = [ - {"content_type": item.content_type, "content": item.content} for item in topic.topic_content - ] - - # Set context for progress numbers - context.position = content_list.index({"content": content, "content_type": content_type}) - context.length = len(content_list) - - # Set context for navigation - context.previous = get_previous_content(content_list, context.position) - context.next = get_next_content(content_list, context.position) - - -def get_next_content(content_list, current_index): - try: - return content_list[current_index + 1] - except IndexError: - return None - - -def get_previous_content(content_list, current_index): - if current_index == 0: - return None - else: - return content_list[current_index - 1] - - -def allowed_content_access(program, content, content_type): - contents_of_program = frappe.db.sql( - """select `tabTopic Content`.content, `tabTopic Content`.content_type - from `tabCourse Topic`, - `tabProgram Course`, - `tabTopic Content` - where `tabCourse Topic`.parent = `tabProgram Course`.course - and `tabTopic Content`.parent = `tabCourse Topic`.topic - and `tabProgram Course`.parent = %(program)s""", - {"program": program}, - ) - - return (content, content_type) in contents_of_program diff --git a/erpnext/www/lms/course.html b/erpnext/www/lms/course.html deleted file mode 100644 index c07b9402b1..0000000000 --- a/erpnext/www/lms/course.html +++ /dev/null @@ -1,106 +0,0 @@ -{% extends "templates/base.html" %} -{% block title %}{{ course.course_name }}{% endblock %} -{% from "www/lms/macros/hero.html" import hero %} -{% from "www/lms/macros/card.html" import null_card %} - -{% block head_include %} - -{% endblock %} - - -{% macro card(topic) %} -
-
- {% if has_access %} - - {% else %} - - {% endif %} - {% if topic.hero_image %} -
- {% else %} -
-
-
- {% endif %} -
- {% if has_access %} - - - {% else %} - - {% endif %} -
-
-{% endmacro %} - -{% block content %} -
- {{ hero(course.course_name, course.description, has_access, {'name': 'Program', 'url': '/lms/program?program=' + program }) }} -
-
- {% for topic in topics %} - {{ card(topic) }} - {% endfor %} - {% if topics %} - {% for n in range( (3 - (topics|length)) %3) %} - {{ null_card() }} - {% endfor %} - {% endif %} -
-
-
-{% endblock %} diff --git a/erpnext/www/lms/course.py b/erpnext/www/lms/course.py deleted file mode 100644 index 840beee3ad..0000000000 --- a/erpnext/www/lms/course.py +++ /dev/null @@ -1,28 +0,0 @@ -import frappe - -import erpnext.education.utils as utils - -no_cache = 1 - - -def get_context(context): - try: - program = frappe.form_dict["program"] - course_name = frappe.form_dict["name"] - except KeyError: - frappe.local.flags.redirect_location = "/lms" - raise frappe.Redirect - - context.education_settings = frappe.get_single("Education Settings") - course = frappe.get_doc("Course", course_name) - context.program = program - context.course = course - - context.topics = course.get_topics() - context.has_access = utils.allowed_program_access(context.program) - context.progress = get_topic_progress(context.topics, course, context.program) - - -def get_topic_progress(topics, course, program): - progress = {topic.name: utils.get_topic_progress(topic, course.name, program) for topic in topics} - return progress diff --git a/erpnext/www/lms/index.html b/erpnext/www/lms/index.html deleted file mode 100644 index c1e96205eb..0000000000 --- a/erpnext/www/lms/index.html +++ /dev/null @@ -1,69 +0,0 @@ -{% extends "templates/base.html" %} -{% block title %}{{ education_settings.portal_title }}{% endblock %} -{% from "www/lms/macros/card.html" import program_card %} -{% from "www/lms/macros/card.html" import null_card %} - -{% block head_include %} - - - -{% endblock %} - -{% block content %} -
-
-

{{ education_settings.portal_title }}

- {% if education_settings.description %} -

{{ education_settings.description }}

- {% endif %} -

- {% if frappe.session.user == 'Guest' %} - {{_('Sign Up')}} - {% endif %} -

-
-
-
- {% if featured_programs %} - {% for program in featured_programs %} - {{ program_card(program.program, program.has_access) }} - {% endfor %} - {% for n in range( (3 - (featured_programs|length)) %3) %} - {{ null_card() }} - {% endfor %} - {% else %} -

You have not enrolled in any program. Contact your Instructor.

- {% endif %} -
-
-
-{% endblock %} diff --git a/erpnext/www/lms/index.py b/erpnext/www/lms/index.py deleted file mode 100644 index 782ac481a0..0000000000 --- a/erpnext/www/lms/index.py +++ /dev/null @@ -1,17 +0,0 @@ -import frappe - -import erpnext.education.utils as utils - -no_cache = 1 - - -def get_context(context): - context.education_settings = frappe.get_single("Education Settings") - if not context.education_settings.enable_lms: - frappe.local.flags.redirect_location = "/" - raise frappe.Redirect - context.featured_programs = get_featured_programs() - - -def get_featured_programs(): - return utils.get_portal_programs() or [] diff --git a/erpnext/www/lms/macros/__init__.py b/erpnext/www/lms/macros/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/www/lms/macros/card.html b/erpnext/www/lms/macros/card.html deleted file mode 100644 index 3cbdec61aa..0000000000 --- a/erpnext/www/lms/macros/card.html +++ /dev/null @@ -1,34 +0,0 @@ -{% macro program_card(program, has_access) %} -
- - - -
-{% endmacro %} - - -{% macro null_card() %} -
-
-
-
-{% endmacro %} diff --git a/erpnext/www/lms/macros/hero.html b/erpnext/www/lms/macros/hero.html deleted file mode 100644 index dd3c23a014..0000000000 --- a/erpnext/www/lms/macros/hero.html +++ /dev/null @@ -1,53 +0,0 @@ -{% macro hero(title, description, has_access, back) %} -
- -

{{ title }}

-

{{ description or ''}}

-

- {% if frappe.session.user == 'Guest' %} - {{_('Sign Up')}} - {% elif not has_access %} - - {% endif %} -

-
- -{% block script %} - -{% endblock %} -{% endmacro %} diff --git a/erpnext/www/lms/profile.html b/erpnext/www/lms/profile.html deleted file mode 100644 index 5755dfe6d8..0000000000 --- a/erpnext/www/lms/profile.html +++ /dev/null @@ -1,64 +0,0 @@ -{% extends "templates/base.html" %} -{% block title %}Profile{% endblock %} -{% from "www/lms/macros/hero.html" import hero %} - -{% block head_include %} - -{% endblock %} - -{% macro card(program) %} -
- - - -
-{% endmacro %} - -{% block content %} -
-
- -

{{ student.first_name }} {{ student.last_name or '' }}

-

{{ student.name }}

-
-
-
- {% for program in progress %} - {{ card(program) }} - {% endfor %} -
-
-
-{% endblock %} diff --git a/erpnext/www/lms/profile.py b/erpnext/www/lms/profile.py deleted file mode 100644 index c4c1cd78eb..0000000000 --- a/erpnext/www/lms/profile.py +++ /dev/null @@ -1,37 +0,0 @@ -import frappe - -import erpnext.education.utils as utils - -no_cache = 1 - - -def get_context(context): - if frappe.session.user == "Guest": - frappe.local.flags.redirect_location = "/lms" - raise frappe.Redirect - - context.student = utils.get_current_student() - if not context.student: - context.student = frappe.get_doc("User", frappe.session.user) - context.progress = get_program_progress(context.student.name) - - -def get_program_progress(student): - enrolled_programs = frappe.get_all( - "Program Enrollment", filters={"student": student}, fields=["program"] - ) - student_progress = [] - for list_item in enrolled_programs: - program = frappe.get_doc("Program", list_item.program) - progress = utils.get_program_progress(program) - completion = utils.get_program_completion(program) - student_progress.append( - { - "program": program.program_name, - "name": program.name, - "progress": progress, - "completion": completion, - } - ) - - return student_progress diff --git a/erpnext/www/lms/program.html b/erpnext/www/lms/program.html deleted file mode 100644 index 30528c667d..0000000000 --- a/erpnext/www/lms/program.html +++ /dev/null @@ -1,87 +0,0 @@ -{% extends "templates/base.html" %} -{% block title %}{{ program.program_name }}{% endblock %} -{% from "www/lms/macros/hero.html" import hero %} -{% from "www/lms/macros/card.html" import null_card %} - -{% block head_include %} - -{% endblock %} - - -{% macro card(course) %} -
- -
- {% if course.hero_image %} -
- {% else %} -
-
-
- {% endif %} -
-
{{ course.course_name }}
-
{{ course.description[:110] + '...' if course.description else '' }}
-
- {% if has_access and progress[course.name] %} - - {% endif %} -
-
-
-{% endmacro %} - -{% block content %} -
- {{ hero(program.program_name, program.description, has_access, {'name': 'Home', 'url': '/lms'}) }} -
-
- {% for course in courses %} - {{ card(course) }} - {% endfor %} - {% if courses %} - {% for n in range( (3 - (courses|length)) %3) %} - {{ null_card() }} - {% endfor %} - {% endif %} -
-
-
-{% endblock %} diff --git a/erpnext/www/lms/program.py b/erpnext/www/lms/program.py deleted file mode 100644 index 1df2aa5bac..0000000000 --- a/erpnext/www/lms/program.py +++ /dev/null @@ -1,32 +0,0 @@ -import frappe -from frappe import _ - -import erpnext.education.utils as utils - -no_cache = 1 - - -def get_context(context): - try: - program = frappe.form_dict["program"] - except KeyError: - frappe.local.flags.redirect_location = "/lms" - raise frappe.Redirect - - context.education_settings = frappe.get_single("Education Settings") - context.program = get_program(program) - context.courses = [frappe.get_doc("Course", course.course) for course in context.program.courses] - context.has_access = utils.allowed_program_access(program) - context.progress = get_course_progress(context.courses, context.program) - - -def get_program(program_name): - try: - return frappe.get_doc("Program", program_name) - except frappe.DoesNotExistError: - frappe.throw(_("Program {0} does not exist.").format(program_name)) - - -def get_course_progress(courses, program): - progress = {course.name: utils.get_course_progress(course, program) for course in courses} - return progress or {} diff --git a/erpnext/www/lms/topic.html b/erpnext/www/lms/topic.html deleted file mode 100644 index dc69599112..0000000000 --- a/erpnext/www/lms/topic.html +++ /dev/null @@ -1,58 +0,0 @@ -{% extends "templates/base.html" %} -{% block title %}{{ topic.name }}{% endblock %} -{% from "www/lms/macros/hero.html" import hero %} -{% from "www/lms/macros/card.html" import null_card %} - -{% block head_include %} - -{% endblock %} - - -{% macro card(content, index, length) %} -
- -
-
-
{{ content.content_type or '' }}
-
{{ content.content.name }}
-
- {% if has_access %} - - {% endif %} -
-
-
-{% endmacro %} - -{% block content %} -
- {{ hero(topic.topic_name, topic.description, has_access, {'name': 'Course', 'url': '/lms/course?name=' + course +'&program=' + program}) }} -
-
- {% for content in contents %} - {{ card(content, loop.index, topic.contents|length) }} - {% endfor %} - {% if contents %} - {% for n in range( (3 - (contents|length)) %3) %} - {{ null_card() }} - {% endfor %} - {% endif %} -
-
-
-{% endblock %} diff --git a/erpnext/www/lms/topic.py b/erpnext/www/lms/topic.py deleted file mode 100644 index 7783211a41..0000000000 --- a/erpnext/www/lms/topic.py +++ /dev/null @@ -1,57 +0,0 @@ -import frappe - -import erpnext.education.utils as utils - -no_cache = 1 - - -def get_context(context): - try: - course = frappe.form_dict["course"] - program = frappe.form_dict["program"] - topic = frappe.form_dict["topic"] - except KeyError: - frappe.local.flags.redirect_location = "/lms" - raise frappe.Redirect - - 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 student: - 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"): - if student: - status = utils.check_content_completion(content.name, content.doctype, course_enrollment.name) - else: - status = True - progress.append({"content": content, "content_type": content.doctype, "completed": status}) - elif content.doctype == "Quiz": - if student: - status, score, result, time_taken = utils.check_quiz_completion( - content, course_enrollment.name - ) - else: - status = False - score = None - result = None - progress.append( - { - "content": content, - "content_type": content.doctype, - "completed": status, - "score": score, - "result": result, - } - ) - - return progress