Added report in config/schools.py
This commit is contained in:
parent
c4125b32ee
commit
85480b3af7
@ -137,7 +137,14 @@ def get_data():
|
|||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Assessment Result Tool"
|
"name": "Assessment Result Tool"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"type": "report",
|
||||||
|
"is_query_report": True,
|
||||||
|
"name": "Course wise Assessment Report",
|
||||||
|
"doctype": "Assessment Result"
|
||||||
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,7 +15,12 @@ frappe.query_reports["Course wise Assessment Report"] = {
|
|||||||
"label": __("Student Group"),
|
"label": __("Student Group"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Student Group",
|
"options": "Student Group",
|
||||||
"reqd": 1
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"course",
|
||||||
|
"label": __("Course"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Course",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,18 +7,34 @@ from frappe import _
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
|
print "======================================"
|
||||||
|
|
||||||
assessment_group = filters.get("assessment_group")
|
assessment_group = filters.get("assessment_group")
|
||||||
student_group = filters.get("student_group")
|
student_group = filters.get("student_group")
|
||||||
course = frappe.db.get_value("Student Group", student_group, "course")
|
|
||||||
if not course:
|
|
||||||
frappe.throw(_("Student Group {0} is not linked with any course").format(student_group))
|
|
||||||
|
|
||||||
assessment_plan = frappe.db.sql('''select ap.name, apc.assessment_criteria, apc.maximum_score as max_score
|
if student_group:
|
||||||
|
course = frappe.db.get_value("Student Group", student_group, "course")
|
||||||
|
if not course:
|
||||||
|
frappe.throw(_("Student Group {0} is not linked with any course").format(student_group))
|
||||||
|
# student_group_list = [student_group]
|
||||||
|
else:
|
||||||
|
course = filters.get("course")
|
||||||
|
if not course:
|
||||||
|
frappe.throw(_("Please select Student Group or Course"))
|
||||||
|
# student_group_list = frappe.get_list("Student Group", fields=["name"], filters={"program":program, "course":course})
|
||||||
|
|
||||||
|
# find assessment plan according to the student group list
|
||||||
|
assessment_plan = frappe.db.sql('''select ap.name, ap.student_group, apc.assessment_criteria, apc.maximum_score as max_score
|
||||||
from `tabAssessment Plan` ap, `tabAssessment Plan Criteria` apc
|
from `tabAssessment Plan` ap, `tabAssessment Plan Criteria` apc
|
||||||
where ap.assessment_group=%s and ap.student_group=%s and ap.name=apc.parent and ap.docstatus=1
|
where ap.assessment_group=%s and ap.course=%s and ap.name=apc.parent and ap.docstatus=1
|
||||||
order by apc.assessment_criteria''', (assessment_group, student_group), as_dict=1)
|
order by apc.assessment_criteria''', (assessment_group, course), as_dict=1)
|
||||||
|
print assessment_plan
|
||||||
assessment_plan_list = set([d["name"] for d in assessment_plan])
|
assessment_plan_list = set([d["name"] for d in assessment_plan])
|
||||||
|
student_group_list = set([d["student_group"] for d in assessment_plan])
|
||||||
|
assessment_criteria_list = set([(d["assessment_criteria"],d["max_score"]) for d in assessment_plan])
|
||||||
|
assessment_plan
|
||||||
|
if not assessment_plan_list:
|
||||||
|
frappe.throw(_("No assessment plan linked with this assessment group"))
|
||||||
|
|
||||||
assessment_result = frappe.db.sql('''select ar.student, ard.assessment_criteria, ard.grade, ard.score
|
assessment_result = frappe.db.sql('''select ar.student, ard.assessment_criteria, ard.grade, ard.score
|
||||||
from `tabAssessment Result` ar, `tabAssessment Result Detail` ard
|
from `tabAssessment Result` ar, `tabAssessment Result Detail` ard
|
||||||
@ -32,23 +48,23 @@ def execute(filters=None):
|
|||||||
|
|
||||||
student_list = frappe.db.sql('''select sgs.group_roll_number, sgs.student, sgs.student_name
|
student_list = frappe.db.sql('''select sgs.group_roll_number, sgs.student, sgs.student_name
|
||||||
from `tabStudent Group` sg, `tabStudent Group Student` sgs
|
from `tabStudent Group` sg, `tabStudent Group Student` sgs
|
||||||
where sg.name = sgs.parent and sg.name = %s
|
where sg.name = sgs.parent and sg.name in (%s)
|
||||||
order by sgs.group_roll_number asc''', (student_group), as_list=1)
|
order by sgs.group_roll_number asc''' %', '.join(['%s']*len(student_group_list)), tuple(student_group_list), as_list=1)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
for student in student_list:
|
for student in student_list:
|
||||||
tmp_list = student + result_dict[student[1]]
|
tmp_list = student + result_dict[student[1]]
|
||||||
data.append(tmp_list)
|
data.append(tmp_list)
|
||||||
|
|
||||||
return get_column(assessment_plan), data
|
return get_column(assessment_criteria_list), data
|
||||||
|
|
||||||
def get_column(assessment_plan):
|
def get_column(assessment_criteria):
|
||||||
columns = [
|
columns = [
|
||||||
_("Group Roll No") + "::80",
|
_("Batch Roll No") + "::60",
|
||||||
_("Student ID") + ":Link/Student:90",
|
_("Student ID") + ":Link/Student:90",
|
||||||
_("Student Name") + "::160",
|
_("Student Name") + "::160",
|
||||||
]
|
]
|
||||||
for d in assessment_plan:
|
for d in assessment_criteria:
|
||||||
columns.append(d.get("assessment_criteria") + "::110")
|
columns.append(d[0] + "::110")
|
||||||
columns.append("Max Score(" + str(int(d.get("max_score"))) + ")::110")
|
columns.append("Score(" + str(int(d[1])) + ")::100")
|
||||||
return columns
|
return columns
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user