From a56224c03a2c251a79cd237f27c97697c1e93cf1 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 4 Jan 2017 17:00:43 +0530 Subject: [PATCH] Rename Assessment to Assessment Plan --- erpnext/config/desktop.py | 8 +-- erpnext/config/schools.py | 2 +- erpnext/hooks.py | 1 - .../patches/v7_2/update_assessment_modules.py | 10 ++-- erpnext/schools/api.py | 8 +-- .../schools/doctype/assessment/assessment.py | 56 ------------------- .../__init__.py | 0 .../assessment_plan.js} | 2 +- .../assessment_plan.json} | 7 ++- .../assessment_plan/assessment_plan.py | 37 ++++++++++++ .../test_assessment_plan.py} | 4 +- .../assessment_result/assessment_result.js | 8 +-- .../assessment_result/assessment_result.json | 9 +-- .../assessment_result/assessment_result.py | 2 +- erpnext/schools/doctype/course/course.js | 4 +- .../course_schedule/course_schedule.py | 8 +-- .../doctype/student_group/student_group.js | 4 +- 17 files changed, 77 insertions(+), 93 deletions(-) delete mode 100644 erpnext/schools/doctype/assessment/assessment.py rename erpnext/schools/doctype/{assessment => assessment_plan}/__init__.py (100%) rename erpnext/schools/doctype/{assessment/assessment.js => assessment_plan/assessment_plan.js} (97%) rename erpnext/schools/doctype/{assessment/assessment.json => assessment_plan/assessment_plan.json} (99%) create mode 100644 erpnext/schools/doctype/assessment_plan/assessment_plan.py rename erpnext/schools/doctype/{assessment/test_assessment.py => assessment_plan/test_assessment_plan.py} (64%) diff --git a/erpnext/config/desktop.py b/erpnext/config/desktop.py index 9397ffc726..38a584626c 100644 --- a/erpnext/config/desktop.py +++ b/erpnext/config/desktop.py @@ -229,12 +229,12 @@ def get_data(): "type": "list" }, { - "module_name": "Assessment", + "module_name": "Assessment Plan", "color": "#8a70be", "icon": "fa fa-file-text-alt", - "label": _("Assessment"), - "link": "List/Assessment", - "_doctype": "Assessment", + "label": _("Assessment Plan"), + "link": "List/Assessment Plan", + "_doctype": "Assessment Plan", "type": "list" }, { diff --git a/erpnext/config/schools.py b/erpnext/config/schools.py index 581b520abe..cac6cfa27e 100644 --- a/erpnext/config/schools.py +++ b/erpnext/config/schools.py @@ -112,7 +112,7 @@ def get_data(): "items": [ { "type": "doctype", - "name": "Assessment" + "name": "Assessment Plan" }, { "type": "doctype", diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 0093375243..0a07e76d89 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -108,7 +108,6 @@ portal_menu_items = [ {"title": _("Issues"), "route": "/issues", "reference_doctype": "Issue", "role":"Customer"}, {"title": _("Addresses"), "route": "/addresses", "reference_doctype": "Address"}, {"title": _("Announcements"), "route": "/announcement", "reference_doctype": "Announcement"}, - {"title": _("Assessment Schedule"), "route": "/assessment", "reference_doctype": "Assessment", "role":"Student"}, {"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"} ] diff --git a/erpnext/patches/v7_2/update_assessment_modules.py b/erpnext/patches/v7_2/update_assessment_modules.py index a8ee865ec6..43c5764505 100644 --- a/erpnext/patches/v7_2/update_assessment_modules.py +++ b/erpnext/patches/v7_2/update_assessment_modules.py @@ -9,18 +9,20 @@ def execute(): frappe.reload_doc("schools", "doctype", "grading_scale_interval") rename_field("Grading Scale Interval", "to_score", "threshold") + frappe.rename_doc("DocType", "Assessment", "Assessment Plan", force=True) + #Rename Assessment Results - frappe.reload_doc("schools", "doctype", "assessment") - rename_field("Assessment", "grading_structure", "grading_scale") + frappe.reload_doc("schools", "doctype", "assessment_plan") + rename_field("Assessment Plan", "grading_structure", "grading_scale") frappe.reload_doc("schools", "doctype", "assessment_result") - for assessment in frappe.get_all("Assessment", fields=["name", "grading_scale"]): + for assessment in frappe.get_all("Assessment Plan", fields=["name", "grading_scale"]): for stud_result in frappe.db.sql("select * from `tabAssessment Result` where parent= %s", assessment.name, as_dict=True): if stud_result.result: assessment_result = frappe.new_doc("Assessment Result") assessment_result.student = stud_result.student assessment_result.student_name = stud_result.student_name - assessment_result.assessment = assessment.name + assessment_result.assessment_plan = assessment.name assessment_result.grading_scale = assessment.grading_scale assessment_result.total_score = stud_result.result assessment_result.flags.ignore_validate = True diff --git a/erpnext/schools/api.py b/erpnext/schools/api.py index 912a75dfc2..e48748e621 100644 --- a/erpnext/schools/api.py +++ b/erpnext/schools/api.py @@ -174,13 +174,13 @@ def get_evaluation_criterias(course): fields=["evaluation_criteria", "weightage"], filters={"parent": course}, order_by= "idx") @frappe.whitelist() -def get_assessment_details(assessment): - """Returns Evaluation Criteria and Maximum Score from Assessment Master. +def get_assessment_details(assessment_plan): + """Returns Evaluation Criteria and Maximum Score from Assessment Plan Master. - :param Assessment: Assessment + :param Assessment Plan: Assessment Plan """ return frappe.get_list("Assessment Evaluation Criteria", \ - fields=["evaluation_criteria", "maximum_score"], filters={"parent": assessment}, order_by= "idx") + fields=["evaluation_criteria", "maximum_score"], filters={"parent": assessment_plan}, order_by= "idx") @frappe.whitelist() diff --git a/erpnext/schools/doctype/assessment/assessment.py b/erpnext/schools/doctype/assessment/assessment.py deleted file mode 100644 index 1ea1577957..0000000000 --- a/erpnext/schools/doctype/assessment/assessment.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - -from __future__ import unicode_literals -from frappe.model.document import Document -import frappe -from frappe import _ - -class Assessment(Document): - def validate(self): - self.validate_overlap() - - def validate_overlap(self): - """Validates overlap for Student Group/Student Batch, Instructor, Room""" - - from erpnext.schools.utils import validate_overlap_for - - #Validate overlapping course schedules. - if self.student_batch: - validate_overlap_for(self, "Course Schedule", "student_batch") - - if self.student_group: - validate_overlap_for(self, "Course Schedule", "student_group") - - validate_overlap_for(self, "Course Schedule", "instructor") - validate_overlap_for(self, "Course Schedule", "room") - - #validate overlapping assessment schedules. - if self.student_batch: - validate_overlap_for(self, "Assessment", "student_batch") - - if self.student_group: - validate_overlap_for(self, "Assessment", "student_group") - - validate_overlap_for(self, "Assessment", "room") - validate_overlap_for(self, "Assessment", "supervisor", self.supervisor) - - -def get_assessment_list(doctype, txt, filters, limit_start, limit_page_length=20): - user = frappe.session.user - student = frappe.db.sql("select name from `tabStudent` where student_email_id= %s", user) - if student: - return frappe. db.sql('''select course, schedule_date, from_time, to_time, sgs.name from `tabAssessment` as assessment, - `tabStudent Group Student` as sgs where assessment.student_group = sgs.parent and sgs.student = %s and assessment.docstatus=1 - order by assessment.name asc limit {0} , {1}''' - .format(limit_start, limit_page_length), student, as_dict = True) - -def get_list_context(context=None): - return { - "show_sidebar": True, - 'no_breadcrumbs': True, - "title": _("Assessment Schedule"), - "get_list": get_assessment_list, - "row_template": "templates/includes/assessment/assessment_row.html" - } \ No newline at end of file diff --git a/erpnext/schools/doctype/assessment/__init__.py b/erpnext/schools/doctype/assessment_plan/__init__.py similarity index 100% rename from erpnext/schools/doctype/assessment/__init__.py rename to erpnext/schools/doctype/assessment_plan/__init__.py diff --git a/erpnext/schools/doctype/assessment/assessment.js b/erpnext/schools/doctype/assessment_plan/assessment_plan.js similarity index 97% rename from erpnext/schools/doctype/assessment/assessment.js rename to erpnext/schools/doctype/assessment_plan/assessment_plan.js index 5744982e31..7b746ffb77 100644 --- a/erpnext/schools/doctype/assessment/assessment.js +++ b/erpnext/schools/doctype/assessment_plan/assessment_plan.js @@ -5,7 +5,7 @@ cur_frm.add_fetch("student_group", "course", "course"); cur_frm.add_fetch("examiner", "instructor_name", "examiner_name"); cur_frm.add_fetch("supervisor", "instructor_name", "supervisor_name"); -frappe.ui.form.on("Assessment", { +frappe.ui.form.on("Assessment Plan", { course: function(frm) { if (frm.doc.course && frm.doc.maximum_assessment_score) { frappe.call({ diff --git a/erpnext/schools/doctype/assessment/assessment.json b/erpnext/schools/doctype/assessment_plan/assessment_plan.json similarity index 99% rename from erpnext/schools/doctype/assessment/assessment.json rename to erpnext/schools/doctype/assessment_plan/assessment_plan.json index 0b46abc912..10ae53c7bb 100644 --- a/erpnext/schools/doctype/assessment/assessment.json +++ b/erpnext/schools/doctype/assessment_plan/assessment_plan.json @@ -625,7 +625,7 @@ "label": "Amended From", "length": 0, "no_copy": 1, - "options": "Assessment", + "options": "Assessment Plan", "permlevel": 0, "print_hide": 1, "print_hide_if_no_value": 0, @@ -649,10 +649,10 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-12-15 14:35:50.780052", + "modified": "2017-01-04 16:21:40.752137", "modified_by": "Administrator", "module": "Schools", - "name": "Assessment", + "name": "Assessment Plan", "name_case": "", "owner": "Administrator", "permissions": [ @@ -683,5 +683,6 @@ "read_only_onload": 0, "sort_field": "modified", "sort_order": "DESC", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/schools/doctype/assessment_plan/assessment_plan.py b/erpnext/schools/doctype/assessment_plan/assessment_plan.py new file mode 100644 index 0000000000..4c472fc87a --- /dev/null +++ b/erpnext/schools/doctype/assessment_plan/assessment_plan.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +from frappe.model.document import Document +import frappe +from frappe import _ + +class AssessmentPlan(Document): + def validate(self): + self.validate_overlap() + + def validate_overlap(self): + """Validates overlap for Student Group/Student Batch, Instructor, Room""" + + from erpnext.schools.utils import validate_overlap_for + + #Validate overlapping course schedules. + if self.student_batch: + validate_overlap_for(self, "Course Schedule", "student_batch") + + if self.student_group: + validate_overlap_for(self, "Course Schedule", "student_group") + + validate_overlap_for(self, "Course Schedule", "instructor") + validate_overlap_for(self, "Course Schedule", "room") + + #validate overlapping assessment schedules. + if self.student_batch: + validate_overlap_for(self, "Assessment Plan", "student_batch") + + if self.student_group: + validate_overlap_for(self, "Assessment Plan", "student_group") + + validate_overlap_for(self, "Assessment Plan", "room") + validate_overlap_for(self, "Assessment Plan", "supervisor", self.supervisor) diff --git a/erpnext/schools/doctype/assessment/test_assessment.py b/erpnext/schools/doctype/assessment_plan/test_assessment_plan.py similarity index 64% rename from erpnext/schools/doctype/assessment/test_assessment.py rename to erpnext/schools/doctype/assessment_plan/test_assessment_plan.py index ce060074a9..2de4f23f5b 100644 --- a/erpnext/schools/doctype/assessment/test_assessment.py +++ b/erpnext/schools/doctype/assessment_plan/test_assessment_plan.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe import unittest -# test_records = frappe.get_test_records('Assessment') +# test_records = frappe.get_test_records('Assessment Plan') -class TestAssessment(unittest.TestCase): +class TestAssessmentPlan(unittest.TestCase): pass diff --git a/erpnext/schools/doctype/assessment_result/assessment_result.js b/erpnext/schools/doctype/assessment_result/assessment_result.js index 3bb6105806..265a626a80 100644 --- a/erpnext/schools/doctype/assessment_result/assessment_result.js +++ b/erpnext/schools/doctype/assessment_result/assessment_result.js @@ -2,15 +2,15 @@ // For license information, please see license.txt cur_frm.add_fetch("student", "title", "student_name"); -cur_frm.add_fetch("assessment", "grading_scale", "grading_scale"); -cur_frm.add_fetch("assessment", "maximum_assessment_score", "maximum_score"); +cur_frm.add_fetch("assessment_plan", "grading_scale", "grading_scale"); +cur_frm.add_fetch("assessment_plan", "maximum_assessment_score", "maximum_score"); frappe.ui.form.on("Assessment Result", { - assessment: function(frm) { + assessment_plan: function(frm) { frappe.call({ method: "erpnext.schools.api.get_assessment_details", args: { - assessment: frm.doc.assessment + assessment_plan: frm.doc.assessment_plan }, callback: function(r) { if (r.message) { diff --git a/erpnext/schools/doctype/assessment_result/assessment_result.json b/erpnext/schools/doctype/assessment_result/assessment_result.json index e76b7b9c88..3bf9758623 100644 --- a/erpnext/schools/doctype/assessment_result/assessment_result.json +++ b/erpnext/schools/doctype/assessment_result/assessment_result.json @@ -101,7 +101,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "assessment", + "fieldname": "assessment_plan", "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, @@ -109,10 +109,10 @@ "in_filter": 0, "in_list_view": 1, "in_standard_filter": 0, - "label": "Assessment", + "label": "Assessment Plan", "length": 0, "no_copy": 0, - "options": "Assessment", + "options": "Assessment Plan", "permlevel": 0, "precision": "", "print_hide": 0, @@ -388,7 +388,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-12-27 17:05:36.436123", + "modified": "2017-01-04 16:56:33.868949", "modified_by": "Administrator", "module": "Schools", "name": "Assessment Result", @@ -423,5 +423,6 @@ "sort_field": "modified", "sort_order": "DESC", "title_field": "student_name", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/schools/doctype/assessment_result/assessment_result.py b/erpnext/schools/doctype/assessment_result/assessment_result.py index 0afd4b9fbf..7ef3240180 100644 --- a/erpnext/schools/doctype/assessment_result/assessment_result.py +++ b/erpnext/schools/doctype/assessment_result/assessment_result.py @@ -10,7 +10,7 @@ from erpnext.schools.api import get_grade class AssessmentResult(Document): def validate(self): - self.maximum_score = frappe.db.get_value("Assessment", self.assessment, "maximum_assessment_score") + self.maximum_score = frappe.db.get_value("Assessment Plan", self.assessment_plan, "maximum_assessment_score") self.validate_grade() def validate_grade(self): diff --git a/erpnext/schools/doctype/course/course.js b/erpnext/schools/doctype/course/course.js index fe38806ff7..c667eca2b7 100644 --- a/erpnext/schools/doctype/course/course.js +++ b/erpnext/schools/doctype/course/course.js @@ -21,11 +21,11 @@ frappe.ui.form.on("Course", "refresh", function(frm) { frappe.set_route("List", "Course Schedule"); }); - frm.add_custom_button(__("Assessment"), function() { + frm.add_custom_button(__("Assessment Plan"), function() { frappe.route_options = { course: frm.doc.name } - frappe.set_route("List", "Assessment"); + frappe.set_route("List", "Assessment Plan"); }); } }); \ No newline at end of file diff --git a/erpnext/schools/doctype/course_schedule/course_schedule.py b/erpnext/schools/doctype/course_schedule/course_schedule.py index ec30c62140..7550ab1c47 100644 --- a/erpnext/schools/doctype/course_schedule/course_schedule.py +++ b/erpnext/schools/doctype/course_schedule/course_schedule.py @@ -55,11 +55,11 @@ class CourseSchedule(Document): #validate overlapping assessment schedules. if self.student_batch: - validate_overlap_for(self, "Assessment", "student_batch") + validate_overlap_for(self, "Assessment Plan", "student_batch") if self.student_group: - validate_overlap_for(self, "Assessment", "student_group") + validate_overlap_for(self, "Assessment Plan", "student_group") - validate_overlap_for(self, "Assessment", "room") - validate_overlap_for(self, "Assessment", "supervisor", self.instructor) + validate_overlap_for(self, "Assessment Plan", "room") + validate_overlap_for(self, "Assessment Plan", "supervisor", self.instructor) diff --git a/erpnext/schools/doctype/student_group/student_group.js b/erpnext/schools/doctype/student_group/student_group.js index 6f4084be25..392793a1f6 100644 --- a/erpnext/schools/doctype/student_group/student_group.js +++ b/erpnext/schools/doctype/student_group/student_group.js @@ -10,11 +10,11 @@ frappe.ui.form.on("Student Group", { frappe.set_route("List", "Course Schedule"); }); - frm.add_custom_button(__("Assessment"), function() { + frm.add_custom_button(__("Assessment Plan"), function() { frappe.route_options = { student_group: frm.doc.name } - frappe.set_route("List", "Assessment"); + frappe.set_route("List", "Assessment Plan"); }); } },