Added report in config/schools.py

This commit is contained in:
Manas Solanki 2017-05-05 15:04:59 +05:30
parent c4125b32ee
commit 85480b3af7
3 changed files with 44 additions and 16 deletions

View File

@ -137,7 +137,14 @@ def get_data():
{
"type": "doctype",
"name": "Assessment Result Tool"
}
},
{
"type": "report",
"is_query_report": True,
"name": "Course wise Assessment Report",
"doctype": "Assessment Result"
},
]
},
{

View File

@ -15,7 +15,12 @@ frappe.query_reports["Course wise Assessment Report"] = {
"label": __("Student Group"),
"fieldtype": "Link",
"options": "Student Group",
"reqd": 1
},
{
"fieldname":"course",
"label": __("Course"),
"fieldtype": "Link",
"options": "Course",
},
]
}

View File

@ -7,18 +7,34 @@ from frappe import _
from collections import defaultdict
def execute(filters=None):
print "======================================"
assessment_group = filters.get("assessment_group")
student_group = filters.get("student_group")
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})
assessment_plan = frappe.db.sql('''select ap.name, apc.assessment_criteria, apc.maximum_score as max_score
# 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
where ap.assessment_group=%s and ap.student_group=%s and ap.name=apc.parent and ap.docstatus=1
order by apc.assessment_criteria''', (assessment_group, student_group), as_dict=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, course), as_dict=1)
print 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
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
from `tabStudent Group` sg, `tabStudent Group Student` sgs
where sg.name = sgs.parent and sg.name = %s
order by sgs.group_roll_number asc''', (student_group), as_list=1)
where sg.name = sgs.parent and sg.name in (%s)
order by sgs.group_roll_number asc''' %', '.join(['%s']*len(student_group_list)), tuple(student_group_list), as_list=1)
data = []
for student in student_list:
tmp_list = student + result_dict[student[1]]
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 = [
_("Group Roll No") + "::80",
_("Batch Roll No") + "::60",
_("Student ID") + ":Link/Student:90",
_("Student Name") + "::160",
]
for d in assessment_plan:
columns.append(d.get("assessment_criteria") + "::110")
columns.append("Max Score(" + str(int(d.get("max_score"))) + ")::110")
for d in assessment_criteria:
columns.append(d[0] + "::110")
columns.append("Score(" + str(int(d[1])) + ")::100")
return columns