comparison 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
comparison
equal deleted inserted replaced
204:00c80bba7f13 205:166a23999bf7
190 verdict = 'unspecified reason [this may be a bug in Upreckon]%s' % strerror(sys.exc_info()[1]) 190 verdict = 'unspecified reason [this may be a bug in Upreckon]%s' % strerror(sys.exc_info()[1])
191 #except Exception: 191 #except Exception:
192 # verdict = 'unknown error [this may be a bug in Upreckon]%s' % strerror(sys.exc_info()[1]) 192 # verdict = 'unknown error [this may be a bug in Upreckon]%s' % strerror(sys.exc_info()[1])
193 else: 193 else:
194 try: 194 try:
195 granted, comment = granted 195 granted, correct, comment = granted
196 except TypeError: 196 except TypeError:
197 comment = '' 197 comment = ''
198 correct = granted >= 1
198 else: 199 else:
199 if comment: 200 if comment:
200 comment = ' (%s)' % comment 201 comment = ' (%s)' % comment
201 if granted >= 1: 202 if correct:
202 contexts[-1].case_correct() 203 contexts[-1].case_correct()
203 prob.testcases.send(True) 204 prob.testcases.send(True)
204 verdict = 'OK' + comment 205 verdict = 'OK' + comment
205 elif not granted:
206 verdict = 'wrong answer' + comment
207 else: 206 else:
208 verdict = 'partly correct' + comment 207 verdict = 'partly correct' + comment
209 granted *= case.points 208 granted *= case.points
210 say('%g/%g, %s' % (granted, case.points, verdict)) 209 say('%g/%g, %s' % (granted, case.points, verdict))
211 contexts[-1].case_end() 210 contexts[-1].case_end()