def collate(filenames): answer = {} for fname in filenames: newList = [] f = open(fname, 'r') for line in f: try: d = ast.literal_eval(line) except: print 'failed ast.literal_eval' continue temp = fname.split('_') probName = temp[0].split('/')[-1] questionName = temp[1] grader = criteria.createGrader(allCriteria[(probName, questionName)]) username = d['username'] data = d['data'] if data == '{}': continue grade, feedback = grader.grade(util.GraphData(data)) newList.append((username, grade, feedback)) f.close() newList.sort(key=lambda x: x[1]) answer[fname] = newList return answer
def generate(visualOptions, criteriaOptions, generatorFunc, quantity=2): if isinstance(visualOptions,basestring): visualOptions = convertStringToDict(visualOptions) if isinstance(criteriaOptions, basestring): criteriaOptions = convertStringToDict(criteriaOptions) #extract axis data axisData = {} axisData['xaxis'] = visualOptions['xaxis'] axisData['xaxis']['pixels'] = axisData['xaxis'].pop('pixelDim') axisData['yaxis'] = visualOptions['yaxis'] axisData['yaxis']['pixels'] = axisData['yaxis'].pop('pixelDim') #extract grader grader = criteria.createGrader(criteriaOptions) answers = [] for i in range(quantity): genData = generatorFunc(axisData, grader) (score, feedback) = grader.grade(util.GraphData(json.dumps(genData))) answers.append({'data':genData,'score':score, 'feedback':feedback}) return answers
def collate(filenames): answer = {} for fname in filenames: newList = [] f = open(fname, 'r') for line in f: try: d = ast.literal_eval(line) except: print 'failed ast.literal_eval' continue temp = fname.split('_') probName = temp[0].split('/')[-1] questionName = temp[1] grader = criteria.createGrader(allCriteria[(probName,questionName)]) username = d['username'] data = d['data'] if data == '{}': continue grade, feedback = grader.grade(util.GraphData(data)) newList.append((username, grade, feedback)) f.close() newList.sort(key=lambda x: x[1]) answer[fname] = newList return answer
def gradeGivenCriteria(data, criteriaJSON): critList = json.loads(criteriaJSON) grader = criteria.createGrader(critList) graphData = util.GraphData(data) grade = grader.grade(graphData) return (grade[0]*100, [grade[1]])
def gradeGivenCriteria(data, criteriaJSON): critList = json.loads(criteriaJSON) grader = criteria.createGrader(critList) graphData = util.GraphData(data) grade = grader.grade(graphData) return (grade[0] * 100, [grade[1]])