# HG changeset patch # User Oleg Oshmyan # Date 1285200684 0 # Node ID c23d81f4a1a36aecb1f4a2ad44dab36acca04034 # Parent c1f52b5d80d6f41f65a8de9d2b2ea0727b13dd50 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. diff -r c1f52b5d80d6 -r c23d81f4a1a3 2.00/config.py --- a/2.00/config.py Wed Sep 22 23:34:51 2010 +0000 +++ b/2.00/config.py Thu Sep 23 00:11:24 2010 +0000 @@ -118,9 +118,6 @@ for name in defaults_problem: if not hasattr(globalconf, name): setattr(module, name, getattr(module, name, defaults_problem[name])) - for name in patterns: - if hasattr(module, name): - setattr(module, name, getattr(module, name).replace('%', problem_name)) if not hasattr(module, 'path'): if hasattr(module, 'name'): module.path = module.name @@ -131,7 +128,11 @@ if options.no_maxtime: module.maxtime = 0 sys.dont_write_bytecode = dwb - return Config(module, globalconf) + module = Config(module, globalconf) + for name in patterns: + if hasattr(module, name): + setattr(module, name, getattr(module, name).replace('%', problem_name)) + return module def load_global(): dwb = sys.dont_write_bytecode diff -r c1f52b5d80d6 -r c23d81f4a1a3 2.00/problem.py --- a/2.00/problem.py Wed Sep 22 23:34:51 2010 +0000 +++ b/2.00/problem.py Thu Sep 23 00:11:24 2010 +0000 @@ -137,14 +137,15 @@ comment = ' (%s)' % comment else: comment = '' - if granted == case.points: + if granted >= 1: ncorrect += 1 - if granted: ncorrectvalued += 1 + if case.points: ncorrectvalued += 1 verdict = 'OK' + comment elif not granted: verdict = 'wrong answer' + comment else: verdict = 'partly correct' + comment + granted *= case.points say('%g/%g, %s' % (granted, case.points, verdict)) real += granted weighted = real * prob.config.taskweight / max if max else 0 diff -r c1f52b5d80d6 -r c23d81f4a1a3 2.00/testcases.py --- a/2.00/testcases.py Wed Sep 22 23:34:51 2010 +0000 +++ b/2.00/testcases.py Thu Sep 23 00:11:24 2010 +0000 @@ -321,7 +321,7 @@ pass else: raise WrongAnswer - return case.points + return 1 elif callable(case.validator): return case.validator(output) else: @@ -340,9 +340,9 @@ if case.process.returncode: raise WrongAnswer(comment) else: - return case.points, comment + return 1, comment else: - return case.points * case.process.returncode / case.problem.config.maxexitcode, comment + return case.process.returncode / case.problem.config.maxexitcode, comment class BatchTestCase(ValidatedTestCase):