Skip to content

Instantly share code, notes, and snippets.

@cflewis
Created March 18, 2009 06:17
Show Gist options
  • Save cflewis/80968 to your computer and use it in GitHub Desktop.
Save cflewis/80968 to your computer and use it in GitHub Desktop.
A script to automate the generation of UC Santa Cruz narrative evaluations given a grades spreadsheet and student enrollment spreadsheet.
#!/usr/bin/env python
# encoding: utf-8
"""
evaluations.py
Created by Chris Lewis on 2009-03-17.
Copyright (c) 2009 Regents of the University of California.
Released under a BSD license:
http://www.opensource.org/licenses/bsd-license.php
To do: Read in student list, create dictionary of student emails
and their IDs, then use that to print the final output.
"""
import sys
import os
import csv
def get_percentage_description(grade):
s = "inadequate"
grade = float(grade)
if grade >= 89:
s = "excellent"
elif grade >= 74:
s = "very good"
elif grade >= 60:
s = "satisfactory"
elif grade >= 54:
s = "marginal"
return s
def get_finalist_string(string):
s = ""
if string == "finalist":
s = ". This project was also picked as one of six finalists for the best project in the class"
elif string == "semifinalist":
s = ". This project was also picked as one of seven semi-finalists for the best project in the class"
return s
def convert_to_string(number):
s = str(number)
if s == "" or s is None:
s = "0"
return s
def main():
students = {}
errors = "Errors:"
# cflewis | 2009-03-18 | Open with Universal Newline mode.
# Excel 2008 on Mac saves CSVs with this, maybe on Windows too
students_reader = csv.DictReader(open("students.csv", "rU"))
# cflewis | 2009-03-18 | Create a mapping from student emails
# to their student IDs
for row in students_reader:
students[row["Email Address"]] = row["ID"]
grades_reader = csv.DictReader(open("gradesfinal.csv"))
print \
"""
@@@@@,CMPS 80K 01,41765,2090,1178695
This course required two types of work from students: work to understand the structures and functions of computer games (conducted individually) and work on a quarter-long game project (conducted in teams). In the first of these areas, %(FMNAME)s demonstrated %(EXAM)s understanding on the final exam and was also assigned reading quizzes (%(QUIZ)s), a game analysis paper (%(ESSAY)s), and two game creation tutorials (%(TUTORIAL1)s, %(TUTORIAL2)s). In the second, project-focused area, %(FMNAME)s's project was %(PROJECT)s%(FINALIST)s. Leading up to this, %(FMNAME)s was assigned a team formation document (%(TEAM)s), concept document (%(CONCEPT)s), work breakdown (%(BREAKDOWN)s), progress report (%(PROGRESS REPORT)s), and prototype (%(PROTOTYPE)s). Overall, %(FMNAME)s's performance was %(FINAL)s.
"""
# cflewis | 2009-03-18 | Yes, I'm ashamed of the ugliness of the print
# statement. Sue me!
for row in grades_reader:
try:
exam_grade = float(row["Final"]) * 100
except ValueError:
exam_grade = 0
try:
project_grade = (float(row["Project"]) / 25) * 100
except ValueError:
project_grade = 0
try:
print \
"""
&&&&, %(LNAME)s, %(FMNAME)s, ,%(SID)s,
""" % \
{"FMNAME": row["First Name"], \
"LNAME": row["Last Name"], \
"SID": students[row["Email Address"]], \
"EXAM": get_percentage_description(exam_grade), \
"QUIZ": convert_to_string(row["Quiz"] + "/16"), \
"ESSAY": convert_to_string(row["Multi-Game Analysis"] + "/15"), \
"TUTORIAL1": convert_to_string(row["Tutorial #1"]) + "%", \
"TUTORIAL2": convert_to_string(row["Tutorial #2"]) + "%", \
"TEAM": convert_to_string(row["Team Formation"]) + "%", \
"CONCEPT": convert_to_string(row["Concept Doc"]) + "%", \
"BREAKDOWN": convert_to_string(row["Work breakdown"]) + "%", \
"PROGRESS REPORT": convert_to_string(row["Progress Report"]) + "%", \
"PROTOTYPE": convert_to_string(row["Concept Doc"]) + "%", \
"FINAL": get_percentage_description(row["Final Grade"]), \
"PROJECT": get_percentage_description(project_grade), \
"FINALIST": get_finalist_string(row["Finalist"])}
except KeyError, e:
# cflewis | 2009-03-18 | Raise an error if the grading sheet
# had a student that wasn't in the final class list
# ie. a student that dropped or withdrew.
errors = errors + "\n Not in class list %s" % e
if errors is not "Errors:":
print errors
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment