def grade_histogram(module_id):
 from django.db import connection
 cursor = connection.cursor()
 query = '        SELECT courseware_studentmodule.grade,\n        COUNT(courseware_studentmodule.student_id)\n        FROM courseware_studentmodule\n        WHERE courseware_studentmodule.module_id=%s\n        GROUP BY courseware_studentmodule.grade'
 cursor.execute(query, [module_id.to_deprecated_string()])
 grades = list(cursor.fetchall())
 grades.sort(key=(lambda x: x[0]))
 if ((len(grades) >= 1) and (grades[0][0] is None)):
  return []
 return grades

def grade_histogram ( module_id ) : from django . db import connection cursor = connection . cursor ( ) query = '        SELECT courseware_studentmodule.grade,\n        COUNT(courseware_studentmodule.student_id)\n        FROM courseware_studentmodule\n        WHERE courseware_studentmodule.module_id=%s\n        GROUP BY courseware_studentmodule.grade' cursor . execute ( query , [ module_id . to_deprecated_string ( ) ] ) grades = list ( cursor . fetchall ( ) ) grades . sort ( key = ( lambda x : x [ 0 ] ) ) if ( ( len ( grades ) >= 1 ) and ( grades [ 0 ] [ 0 ] is None ) ) : return [ ] return grades
print out a histogram of grades on a given problem in staff member debug info .