comparison 2.00/problem.py @ 24:c23d81f4a1a3

Score returned by TestCase.__call__() is now normalized to 0..1 TestCase.__call__() now returns the fraction (a number from 0 to 1) of case.points that is to be awarded. Bug fix: %-patterns in configuration variables common to all problems are now substituted.
author Oleg Oshmyan <chortos@inbox.lv>
date Thu, 23 Sep 2010 00:11:24 +0000
parents c1f52b5d80d6
children 5bbb68833868
comparison
equal deleted inserted replaced
23:c1f52b5d80d6 24:c23d81f4a1a3
135 granted, comment = granted 135 granted, comment = granted
136 if comment: 136 if comment:
137 comment = ' (%s)' % comment 137 comment = ' (%s)' % comment
138 else: 138 else:
139 comment = '' 139 comment = ''
140 if granted == case.points: 140 if granted >= 1:
141 ncorrect += 1 141 ncorrect += 1
142 if granted: ncorrectvalued += 1 142 if case.points: ncorrectvalued += 1
143 verdict = 'OK' + comment 143 verdict = 'OK' + comment
144 elif not granted: 144 elif not granted:
145 verdict = 'wrong answer' + comment 145 verdict = 'wrong answer' + comment
146 else: 146 else:
147 verdict = 'partly correct' + comment 147 verdict = 'partly correct' + comment
148 granted *= case.points
148 say('%g/%g, %s' % (granted, case.points, verdict)) 149 say('%g/%g, %s' % (granted, case.points, verdict))
149 real += granted 150 real += granted
150 weighted = real * prob.config.taskweight / max if max else 0 151 weighted = real * prob.config.taskweight / max if max else 0
151 if nvalued != ntotal: 152 if nvalued != ntotal:
152 say('Problem total: %d/%d tests (%d/%d valued); %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, ncorrectvalued, nvalued, real, max, weighted, prob.config.taskweight)) 153 say('Problem total: %d/%d tests (%d/%d valued); %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, ncorrectvalued, nvalued, real, max, weighted, prob.config.taskweight))