changeset 5:eb15a5a9b026

Output validators can now award partial scores Added the maxexitcode configuration option. Output validators can now cause a fraction of the points allocated for the test case to be awarded (exitcode/maxexitcode is the fraction, ranging from 0 to 1).
author Oleg Oshmyan <chortos@inbox.lv>
date Sun, 14 Feb 2010 00:08:16 +0000
parents 06eef313aeaa
children b0034b18f942
files test.py
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/test.py	Sat Feb 13 23:40:53 2010 +0000
+++ b/test.py	Sun Feb 14 00:08:16 2010 +0000
@@ -31,6 +31,7 @@
 dummyinname = ''
 dummyoutname = ''
 tester = ''
+maxexitcode = 0
 
 def exectestconf_helper(name):
 	if os.path.isfile('tests.tar'):
@@ -844,16 +845,24 @@
 					data = ''.join((' (', data[0].strip(), ')'))
 				else:
 					data = ''
-				if r:
+				if not maxexitcode and r or maxexitcode and not r:
 					print '0/%g, wrong answer%s' % (npoints, data)
 					sys.stdout.flush()
-				elif r == 0:
+				elif not maxexitcode and r == 0 or maxexitcode and r >= maxexitcode:
 					print '%g/%g, OK%s' % (npoints, npoints, data)
 					sys.stdout.flush()
 					scoregrp += npoints
 					ncorrectgrp += 1
 					if npoints:
 						ncorrectvalued += 1
+				elif maxexitcode and r != None:
+					actualpoints = npoints*r/maxexitcode if not npoints*r%maxexitcode else float(npoints*r)/maxexitcode
+					print '%g/%g, partly OK%s' % (actualpoints, npoints, data)
+					sys.stdout.flush()
+					scoregrp += actualpoints
+					ncorrectgrp += 1
+					if npoints:
+						ncorrectvalued += 1
 		if ntotalgrp:
 			if scoregrp < maxpointsgrp:
 				scoregrp = 0
@@ -874,12 +883,13 @@
 	elif stdio:
 		copytestcase(realinname.replace('$', s), inname)
 		copytestcase(realoutname.replace('$', s), ansname)
+	actualpoints = (score*taskweight/maxpoints if not score*taskweight%maxpoints else float(score*taskweight)/maxpoints) if maxpoints else 0
 	if nvalued != ntotal:
-		print 'Grand total: %d/%d tests (%d/%d valued); %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, ncorrectvalued, nvalued, score, maxpoints, (score*taskweight/maxpoints if not score*taskweight%maxpoints else float(score*taskweight)/maxpoints) if maxpoints else 0, taskweight)
+		print 'Grand total: %d/%d tests (%d/%d valued); %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, ncorrectvalued, nvalued, score, maxpoints, actualpoints, taskweight)
 	else:
-		print 'Grand total: %d/%d tests; %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, score, maxpoints, (score*taskweight/maxpoints if not score*taskweight%maxpoints else float(score*taskweight)/maxpoints) if maxpoints else 0, taskweight)
+		print 'Grand total: %d/%d tests; %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, score, maxpoints, actualpoints, taskweight)
 	
-	scoresumoveralltasks += score*taskweight//maxpoints if maxpoints else 0
+	scoresumoveralltasks += actualpoints
 	scoremaxoveralltasks += taskweight
 	ntasks += 1
 	nfulltasks += int((score == maxpoints) if maxpoints else (taskweight == 0))