#!/usr/bin/python import os,sys,subprocess,time runcmd = False assn = 'a10' autotest_folder = '/home/nick/f12_presentation/markus/test.0.AUTOTESTRESULTS/' # In each pair, the first item is the question name as shown in marking/test.0/in # The second item is a list of break of points for rubric levels. If a level is not set # use -1. # Examples: # 0: Very Poor 0-4 of 14 tests passed # 1: Weak 5-8 of 14 tests passed # 2: Passable 9-11 of 14 tests passed # 3: Good 12-13 of 14 tests passed # 4: Excellent 14 of 14 tests passed # breakpoints = [4, 8, 11, 13, 14] # put -1 for empty levels # 0: Very Poor 0-3 of 7 tests passed # 2: Passable 4-6 of 7 tests passed # 4: Excellent 7 of 7 tests passed # breakpoints = [3, -1, 6, -1, 7] rubric = [ ['1', [3, 6, 9, 11, 12]], ['2', [5, 11, 16, 18, 19]], ['3', [1, 3, 5, 7, 8]], #['4', [-1, -1, -1, -1, 4]], ['5', [19, 34, 44, 49, 50]], ['6', [9, -1, -1, -1, 10]], ['puzzles', [2, 6, 9, 11,12]]] def autotest2rubric(score, breakpoints): level = 0 for bp in breakpoints: if score <= bp: return level level += 1; print "ERROR in autotest2rubric(" + str(score) + ", " + str(breakpoints) + ')' exit(1) # Testing for autotest2rubric # for i in range(15): # print str(i) + ' => ' + str(autotest2rubric(i, [0, 1, -1, 2, 3])) id2url = {} f = open('UrlList.txt','r') for l in f.readlines(): id2url[l.split(',')[0]] = l.split('/')[-1][:-1]; f.close() problem_students = [] autotest_score_prefix = len(' ** Question ') autotest_folder_contents = os.listdir(autotest_folder) autotest_folder_contents.sort() for stud in autotest_folder_contents: if os.path.isdir(autotest_folder + '/' + stud): reading_autotest_scores = False f = open(autotest_folder + '/' + stud + '/OUTPUT.txt') # read autotest scores into a dictionary stud_score = {} lines = f.readlines() for l in lines: if l.startswith(' ** Question 4: '): stud_score['4'] = 'x' elif l.startswith(' ** Question 7a: '): score = int( l[ l.find(':') + 1 : l.find('/') ] ) # get nextline q7b = lines[22] assert q7b.startswith(' ** Question 7b: ') score += int( q7b[ q7b.find(':') + 1 : q7b.find('/') ] ) stud_score['7'] = score elif l.startswith(' ** Question '): reading_autotest_scores = True question = l[autotest_score_prefix : l.find(':') ] score = int( l[ l.find(':') + 1 : l.find('/') ] ) stud_score[question] = score elif reading_autotest_scores: break # form command if id2url.has_key(stud): if len(stud_score) != 0: cmd = './markus -urlid %s %s %s' % (id2url[stud], assn, stud) for qpair in rubric: cmd += ' ' + str(autotest2rubric( stud_score[qpair[0]], qpair[1] )) if qpair[0] == '3': cmd += ' x' # q4 elif qpair[0] == '6': if stud_score['7'] >= 9: cmd += ' 4' else: cmd += ' 0' print cmd if runcmd: result = subprocess.call(cmd, shell = True) if result != 0: problem_students.append(stud) f.close() print problem_students