Merge pull request #13310 from manassolanki/student-report-card

addition of student report card generation tool
This commit is contained in:
Manas Solanki 2018-03-16 02:00:07 +05:30 committed by GitHub
commit 7b91042ae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 726 additions and 10 deletions

View File

@ -0,0 +1,82 @@
<style>
.whole-report {
font-size: 9pt;
font-family: 'Helvetica Neue', Helvetica, Arial, 'Open Sans', 'sans-serif';
-webkit-print-color-adjust: exact;
}
h2 {
text-align: center;
}
span {
padding-bottom: 5px;
}
thead {
background-color: #eee !important;
font-weight: bold;
}
td {
vertical-align: top !important;
padding: 6px !important;
text-align: left;
}
.doc-field {
margin-bottom: 5px;
}
</style>
<div class="whole-report">
<h2>{{ _("Student Report Card") }}</h2>
<hr>
<span class="doc-field"> {{ _("Student: ") }} <b> {{ frappe.db.get_value("Student", doc.students[0], "title") }} </b> </span> <br>
<span class="doc-field"> {{ _("Program: ") }} <b> {{ doc.program }} </b> </span> <br>
<span class="doc-field"> {{ _("Assessment Group: ") }} <b> {{ doc.assessment_group }} </b> </span>
<hr>
{% for course in courses %}
<br>
<div class="doc-field">
Course: <b>{{ course }} ({{ frappe.db.get_value("Course", course, "course_name") }}) </b>
</div>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<td>Assessment Criteria</td>
{% for assessment_group in assessment_groups %}
<td> {{ assessment_group }}</td>
{% endfor %}
</tr>
</thead>
<tbody>
{% for criteria in course_criteria[course] %}
<tr>
<td>{{ criteria }}</td>
{% for assessment_group in assessment_groups %}
{% if (assessment_result.get(course) and assessment_result.get(course).get(assessment_group) and assessment_result.get(course).get(assessment_group).get(criteria)) %}
<td> {{ assessment_result.get(course).get(assessment_group).get(criteria).get("grade") }} </td>
{% else %}
<td></td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
<hr>
<h4>{{ _("Attendance")}}</h4> <br>
<div>
Present {{ doc.present_days }} out of {{ doc.max_days }}
</div>
<hr>
<h4>{{ _("Parents Meeting Attendance")}}</h4> <br>
<div>
Present {{ doc.parents_attendance }} out of {{ doc.parents_meeting }}
</div>
</div>

View File

@ -0,0 +1,32 @@
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Student Report Generation Tool', {
onload: function(frm) {
frm.set_query("academic_term",function(){
return{
"filters":{
"academic_year": frm.doc.academic_year
}
};
});
frm.set_query("assessment_group", function() {
return{
filters: {
"is_group": 1
}
};
});
},
refresh: function(frm) {
frm.disable_save();
frm.page.clear_indicator();
frm.fields_dict.preview_report_card.$input.addClass("btn-primary");
},
preview_report_card: function(frm) {
let url = "/api/method/erpnext.education.doctype.student_report_generation_tool.student_report_generation_tool.preview_report_card";
open_url_post(url, frm.doc);
}
});

View File

@ -0,0 +1,485 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2018-01-15 15:36:32.830069",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "academic_year",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Academic Year",
"length": 0,
"no_copy": 0,
"options": "Academic Year",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "academic_term",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Academic Term",
"length": 0,
"no_copy": 0,
"options": "Academic Term",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "student",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Student",
"length": 0,
"no_copy": 0,
"options": "Student",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "assessment_group",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Assessment Group",
"length": 0,
"no_copy": 0,
"options": "Assessment Group",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "program",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Program",
"length": 0,
"no_copy": 0,
"options": "Program",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_5",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Attendance Print Section",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "max_days",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Institution Open (Days)",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "present_days",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Student Present (Days)",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_10",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "parents_meeting",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Total Parent's Meeting",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "parents_attendance",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Parent Present",
"length": 0,
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_9",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "preview_report_card",
"fieldtype": "Button",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Print Report Card",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 1,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2018-03-16 01:56:31.095554",
"modified_by": "Administrator",
"module": "Education",
"name": "Student Report Generation Tool",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 0,
"read": 1,
"report": 0,
"role": "System Manager",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 1
}
],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0
}

View File

@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from erpnext.education.api import get_grade
from frappe.utils.pdf import get_pdf
from erpnext.education.report.course_wise_assessment_report.course_wise_assessment_report import get_formatted_result
from erpnext.education.report.course_wise_assessment_report.course_wise_assessment_report import get_child_assessment_groups
class StudentReportGenerationTool(Document):
pass
@frappe.whitelist()
def preview_report_card(program, assessment_group, academic_year, academic_term=None, student=None, student_group=None,
max_days=None, present_days=None, parents_meeting=None, parents_attendance=None):
doc = frappe._dict()
# doc.program = program
doc.assessment_group = assessment_group
doc.academic_year = academic_year
doc.max_days = max_days
doc.present_days = present_days
doc.parents_meeting = parents_meeting
doc.parents_attendance = parents_attendance
if academic_term:
doc.academic_term = academic_term
if student_group:
doc.student_group = student_group
if student:
doc.students = [student]
if not doc.students and not doc.student_group:
frappe.throw("Please select the Student or Student Group")
values = get_formatted_result(doc, get_course=True, get_all_assessment_groups=True)
student_details = values.get("student_details")
assessment_result = values.get("assessment_result").get(doc.students[0])
courses = values.get("course_dict")
course_criteria = get_courses_criteria(courses)
assessment_groups = get_child_assessment_groups(doc.assessment_group)
if program:
doc.program = program
template = "erpnext/education/doctype/student_report_generation_tool/student_report_generation_tool.html"
base_template_path = "frappe/www/printview.html"
html = frappe.render_template(template,
{
"doc": doc,
"assessment_result": assessment_result,
"courses": courses,
"assessment_groups": assessment_groups,
"course_criteria": course_criteria
})
final_template = frappe.render_template(base_template_path, {
"body": html,
"title": "Report Card"
})
frappe.response.filename = "Report Card.pdf"
frappe.response.filecontent = get_pdf(final_template)
frappe.response.type = "download"
def get_courses_criteria(courses):
course_criteria = frappe._dict()
for course in courses:
course_criteria[course] = [d.assessment_criteria for d in frappe.get_all("Course Assessment Criteria",
fields=["assessment_criteria"], filters={"parent": course})]
return course_criteria

View File

@ -0,0 +1,23 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Student Report Generation Tool", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Student Report Generation Tool
() => frappe.tests.make('Student Report Generation Tool', [
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
},
() => done()
]);
});

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import frappe
import unittest
class TestStudentReportGenerationTool(unittest.TestCase):
pass

View File

@ -60,7 +60,7 @@ def execute(filters=None):
return columns, data, None, chart
def get_formatted_result(args, get_assessment_criteria=False, get_course=False):
def get_formatted_result(args, get_assessment_criteria=False, get_course=False, get_all_assessment_groups=False):
cond, cond1, cond2, cond3, cond4 = " ", " ", " ", " ", " "
args_list = [args.academic_year]
@ -77,15 +77,9 @@ def get_formatted_result(args, get_assessment_criteria=False, get_course=False):
args_list.append(args.student_group)
create_total_dict = False
group_type = frappe.get_value("Assessment Group", args.assessment_group, "is_group")
if group_type:
from frappe.desk.treeview import get_children
assessment_groups = [d.get("value") for d in get_children("Assessment Group",
args.assessment_group) if d.get("value") and not d.get("expandable")]
cond3 = " and ar.assessment_group in (%s)"%(', '.join(['%s']*len(assessment_groups)))
else:
assessment_groups = [args.assessment_group]
cond3 = " and ar.assessment_group=%s"
assessment_groups = get_child_assessment_groups(args.assessment_group)
cond3 = " and ar.assessment_group in (%s)"%(', '.join(['%s']*len(assessment_groups)))
args_list += assessment_groups
if args.students:
@ -156,6 +150,9 @@ def get_formatted_result(args, get_assessment_criteria=False, get_course=False):
# create the total of all the assessment groups criteria-wise
elif create_total_dict:
if get_all_assessment_groups:
formatted_assessment_result[result.student][result.course][result.assessment_group]\
[result.assessment_criteria] = assessment_criteria_details
if not formatted_assessment_result[result.student][result.course][args.assessment_group]:
formatted_assessment_result[result.student][result.course][args.assessment_group] = defaultdict(dict)
formatted_assessment_result[result.student][result.course][args.assessment_group]\
@ -238,3 +235,15 @@ def get_chart_data(grades, criteria_list, kounter):
},
"type": 'bar',
}
def get_child_assessment_groups(assessment_group):
assessment_groups = []
group_type = frappe.get_value("Assessment Group", assessment_group, "is_group")
if group_type:
from frappe.desk.treeview import get_children
assessment_groups = [d.get("value") for d in get_children("Assessment Group",
assessment_group) if d.get("value") and not d.get("expandable")]
else:
assessment_groups = [args.assessment_group]
return assessment_groups