#!/usr/bin/env python import os import sys import shutil ## Requirements to use this program. ## The files that are to be marked must be named with the for q.{ss,py} ## For example, a9q4.ss , testq1.py ## The languages that this is set up for are Scheme and Python # sets the course number to be used crs = 116 # sets the term term = 'Spring 2010' # Save this file to your home directory (in the course account) # to call this program, ~/make-all.py x # x is the name of the assignment (e.g a4) if len(sys.argv)!= 2: print "Usage:", sys.argv[0], "" sys.exit(1) asstnum = sys.argv[1] #Assignment name folders=os.listdir("/u4/cs%d/marking/%s/test.1/in/"%(crs,asstnum)) number_of_qs = 0 for i in folders: try: int(i) number_of_qs+=1 except: pass lang_file = file('/u4/cs%d/marking/%s/test.1/in/options.ss'%(crs,asstnum),'r') line = '' language = '' while not language: line = lang_file.readline() try: lang = line[1:9] if lang == 'language': language = line.split()[1][:-1] else: pass except: pass ms_file = file('/u4/cs%d/marking/%s/test.1/mark-scheme'%(crs,asstnum),'w') ms_file.write('".ad c\n\ .br\n\ ========================================================================\n\ .br\n\ %s CS %d Assignment %s\n\ \n\ .br\n\ \n\ Marked By: TOTAL: / %d\n\ .br\n\ ========================================================================\n\ .br\n\ .ad l\n\ .in 13\n\n\ '%(term,crs,asstnum,(20 * number_of_qs))) print"There must be 10 marks per question assigned to autotesting, and the total should be 20 for each question." if language == 'python' or language == 'advanced': eff = '/Effects' else: eff = '' def set_val(param,name): param = raw_input('%s: '%name) try: return int(param) except: print "%s must be an int, but is %s"%(name,type(param)) return set_val(param,name) for i in range(1,number_of_qs+1): rightsum = False while not rightsum: print "Question %d"%i funcname = raw_input('Function name: ') cont,purp,exam,test,styl='','','','','' cont=set_val(cont,'Contract') purp = set_val(purp,'Purpose%s'%eff) exam = set_val(exam,'Examples') test = set_val(test,'Tests') styl = set_val(styl,'Style') print '' desrec = cont + purp + exam + test tot = desrec + styl + 10 if tot == 20: rightsum = True else: print "Total is %d, should be 20."%tot ms_file.write('.ti -13\n\ ________/20 Problem %d: %s\n\ \n\ .ti -9\n\ ________/%d Design recipe\n\ \n\ .ti -5\n\ ________/%d Contract\n\ \n\ .ti -5\n\ ________/%d Purpose%s\n\ \n\ .ti -5\n\ ________/%d Examples\n\ \n\ .ti -5\n\ ________/%d Tests\n\ \n\ .ti -9\n\ ________/%d Style\n\ \n\ .ti -9\n\ $t%se/$t%so Autotesting\n\ \n' %(i,funcname,desrec,cont,purp,eff,exam,test,styl,i,i)) ms_file.write('"') ms_file.close()