diff upreckon/problem.py @ 205:166a23999bf7

Added confvar okexitcodemask; changed the validator protocol Callable validators now return three-tuples (number granted, bool correct, str comment) instead of two-tuples (number granted, str comment). They are still allowed to return single numbers. Callable validators must now explicitly raise upreckon.exceptions.WrongAnswer if they want the verdict to be Wrong Answer rather than Partly Correct. okexitcodemask specifies a bitmask ANDed with the exit code of the external validator to get a boolean flag showing whether the answer is to be marked as 'OK' rather than 'partly correct'. The bits covered by the bitmask are reset to zeroes before devising the number of points granted from the resulting number.
author Oleg Oshmyan <chortos@inbox.lv>
date Wed, 17 Aug 2011 20:44:54 +0300
parents 67088c1765b4
children c03a8113685d
line wrap: on
line diff
--- a/upreckon/problem.py	Wed Aug 17 18:48:21 2011 +0300
+++ b/upreckon/problem.py	Wed Aug 17 20:44:54 2011 +0300
@@ -192,18 +192,17 @@
 				#	verdict = 'unknown error [this may be a bug in Upreckon]%s' % strerror(sys.exc_info()[1])
 				else:
 					try:
-						granted, comment = granted
+						granted, correct, comment = granted
 					except TypeError:
 						comment = ''
+						correct = granted >= 1
 					else:
 						if comment:
 							comment = ' (%s)' % comment
-					if granted >= 1:
+					if correct:
 						contexts[-1].case_correct()
 						prob.testcases.send(True)
 						verdict = 'OK' + comment
-					elif not granted:
-						verdict = 'wrong answer' + comment
 					else:
 						verdict = 'partly correct' + comment
 					granted *= case.points