Final Assessment Report in School


I am running this versions:

ERPNext: v10.0.23 (master)
Frappe Framework: v10.0.25 (master)

I am facing the below error when trying to generate report for final assessment, the problem appears when I am selecting the parent assessment group (which contains another assessment groups).
It seems an error related to the query, because this error appears for each student (if you have 2 students in the student group, it will appears twice and if you have 3 students in the student group, it will appears 3 times).

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 62, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 53, in execute_cmd
return, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 939, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/”, line 96, in run
res = frappe.get_attr(method_name)(frappe._dict(filters))
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/education/report/final_assessment_grades/”, line 24, in execute
values = get_formatted_result(args, get_course=True)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/education/report/course_wise_assessment_report/”, line 106, in get_formatted_result
tuple(args_list), as_dict=1)
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 166, in sql
self._cursor.execute(query, values)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/”, line 165, in execute
result = self._query(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/”, line 321, in _query
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/”, line 860, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/”, line 1061, in _read_query_result
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/”, line 1349, in read
first_packet = self.connection._read_packet()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/”, line 1018, in _read_packet
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/”, line 384, in check_error
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/”, line 107, in raise_mysql_exception
raise errorclass(errno, errval)
ProgrammingError: (1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘) and ar.student in (‘STUD00001’, ‘STUD00002’)\n\t\tORDER BY\n\t\t\tard.assessment_cri’ at line 8")

As first investigation:
It seems the problem in the below script from file:

    assessment_result = frappe.db.sql('''
                    ar.student, ar.student_name, ar.academic_year, ar.academic_term, ar.program, ar.course,
                    ar.assessment_plan, ar.grading_scale, ar.assessment_group, ar.student_group,
                    ard.assessment_criteria, ard.maximum_score, ard.grade, ard.score
                    `tabAssessment Result` ar, `tabAssessment Result Detail` ard
           and ar.docstatus=1 and ar.academic_year=%s {0} {1} {2} {3} {4}
            ORDER BY
                    ard.assessment_criteria'''.format(cond, cond1, cond2, cond3, cond4),
            tuple(args_list), as_dict=1)

But I am not sure :slight_smile: