Skip to content

Instantly share code, notes, and snippets.

@LindseyB
Created November 5, 2011 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LindseyB/1341129 to your computer and use it in GitHub Desktop.
Save LindseyB/1341129 to your computer and use it in GitHub Desktop.
Creates an easy to parse grade report from grade grinder csv's
# Creates an easy to parse grade report from grade grinder csv's
# Usage: python grade_report.py [filename].csv
# Note: This assumes the CSV has had the rows before the problem headers removed
import sys
import csv
reader = csv.reader(open(sys.argv[1], 'rb'), delimiter=',', quotechar="'")
# Assignments as defined by the course webpage
# Some students do more than the required problems, so we need this to eliminate
# Non-homework problems.
assigns = [
["1.2", "1.3", "1.4", "1.5", "1.6", "1.9", "1.13", "1.14", "1.18",
"2.1", "2.2", "2.8", "2.9", "2.10", "2.17", "2.20", "2.25", "2.27"],
["4.8", "4.10", "4.29", "4.30", "4.40", "6.3", "6.6", "6.11", "6.13",
"6.16", "6.17", "6.18", "6.29", "6.32", "6.33"],
["7.12", "7.13", "7.18", "7.19", "7.20", "8.18", "8.19", "8.20", "8.21",
"8.22", "8.23", "8.24", "8.25", "8.35", "8.37", "8.41", "8.47", "8.53"],
["17.14", "17.15", "17.16", "17.18", "17.19", "17.20", "17.21", "17.33",
"17.34", "17.35", "17.40", "17.42", "9.1", "9.2", "9.3", "9.9", "9.12", "9.14"],
["9.16", "9.17", "9.18", "9.20", "10.1", "10.3", "10.13", "10.17", "10.20",
"10.25"],
["11.5", "11.6", "11.16", "11.20", "11.21", "11.22", "11.29", "11.30",
"11.37", "11.38", "12.16", "12.17"],
["13.5", "13.6", "13.7", "13.13", "13.14", "13.15", "13.17", "13.18",
"13.21", "13.24", "13.25", "13.49", "13.50", "13.52", "18.2", "18.3",
"18.7", "18.8", "18.13", "18.14"],
["18.20", "18.21", "18.22", "18.23", "18.28", "18.30"]
]
rowCount = 0
for row in reader:
scores = [0,0,0,0,0,0,0,0]
if rowCount == 0:
# header row contains all the graded assignments
header = row
for colCount in range(0,len(header)):
for hw in range(0, len(assigns)):
# calculate the max possible points
if header[colCount] in assigns[hw]:
scores[hw] += 1
print "\nmax: " + str(scores) + "\n"
else:
for colCount in range(0,min(len(row),len(header))):
for hw in range(0,len(assigns)):
# if the problem is correct and is counted for credit give a point
if header[colCount] in assigns[hw] and row[colCount] == "1":
scores[hw] += 1
# print the student and their score list
print row[0] + " " + str(scores)
rowCount += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment