2016-12-29 11:35:29 +00:00
|
|
|
import frappe
|
|
|
|
from frappe.model.utils.rename_field import rename_field
|
|
|
|
|
|
|
|
def execute():
|
|
|
|
#Rename Grading Structure to Grading Scale
|
2017-05-23 16:21:32 +00:00
|
|
|
if not frappe.db.exists("DocType", "Grading Scale"):
|
|
|
|
frappe.rename_doc("DocType", "Grading Structure", "Grading Scale", force=True)
|
|
|
|
if not frappe.db.exists("DocType", "Grading Scale Interval"):
|
|
|
|
frappe.rename_doc("DocType", "Grade Interval", "Grading Scale Interval", force=True)
|
2016-12-29 11:35:29 +00:00
|
|
|
|
|
|
|
frappe.reload_doc("schools", "doctype", "grading_scale_interval")
|
2017-05-23 10:06:03 +00:00
|
|
|
if "to_score" in frappe.db.get_table_columns("Grading Scale Interval"):
|
|
|
|
rename_field("Grading Scale Interval", "to_score", "threshold")
|
2016-12-29 11:35:29 +00:00
|
|
|
|
2017-05-23 16:21:32 +00:00
|
|
|
if not frappe.db.exists("DocType", "Assessment Plan"):
|
|
|
|
frappe.rename_doc("DocType", "Assessment", "Assessment Plan", force=True)
|
2017-01-04 11:30:43 +00:00
|
|
|
|
2016-12-29 11:35:29 +00:00
|
|
|
#Rename Assessment Results
|
2017-01-04 11:30:43 +00:00
|
|
|
frappe.reload_doc("schools", "doctype", "assessment_plan")
|
2017-05-23 10:06:03 +00:00
|
|
|
if "grading_structure" in frappe.db.get_table_columns("Assessment Plan"):
|
|
|
|
rename_field("Assessment Plan", "grading_structure", "grading_scale")
|
2016-12-29 11:35:29 +00:00
|
|
|
|
|
|
|
frappe.reload_doc("schools", "doctype", "assessment_result")
|
2017-01-23 09:29:19 +00:00
|
|
|
frappe.reload_doc("schools", "doctype", "assessment_result_detail")
|
2017-02-01 13:10:30 +00:00
|
|
|
frappe.reload_doc("schools", "doctype", "assessment_criteria")
|
2017-01-24 04:58:49 +00:00
|
|
|
|
2017-01-23 09:29:19 +00:00
|
|
|
|
2017-05-23 16:21:32 +00:00
|
|
|
for assessment in frappe.get_all("Assessment Plan",
|
|
|
|
fields=["name", "grading_scale"], filters = [["docstatus", "!=", 2 ]]):
|
|
|
|
for stud_result in frappe.db.sql("select * from `tabAssessment Result` where parent= %s",
|
|
|
|
assessment.name, as_dict=True):
|
2016-12-29 11:35:29 +00:00
|
|
|
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
|
2017-01-04 11:30:43 +00:00
|
|
|
assessment_result.assessment_plan = assessment.name
|
2016-12-29 11:35:29 +00:00
|
|
|
assessment_result.grading_scale = assessment.grading_scale
|
|
|
|
assessment_result.total_score = stud_result.result
|
|
|
|
assessment_result.flags.ignore_validate = True
|
2017-01-30 11:10:14 +00:00
|
|
|
assessment_result.flags.ignore_mandatory = True
|
2016-12-29 11:35:29 +00:00
|
|
|
assessment_result.save()
|
|
|
|
|
|
|
|
frappe.db.sql("""delete from `tabAssessment Result` where parent != '' or parent is not null""")
|