Commit 51392b566bfd1e290c132f4f270e4f9af9dffc88

Authored by Miguel Barão
1 parent 0d5211b6
Exists in dev

minor refactor in testfactory.py

Showing 1 changed file with 5 additions and 1 deletions   Show diff stats
perguntations/testfactory.py
@@ -62,6 +62,7 @@ test_schema = schema.Schema({ @@ -62,6 +62,7 @@ test_schema = schema.Schema({
62 schema.Optional('points'): float 62 schema.Optional('points'): float
63 }] 63 }]
64 }, ignore_extra_keys=True) 64 }, ignore_extra_keys=True)
  65 + # FIXME schema error with 'testfile' which is added in the code
65 66
66 # ============================================================================ 67 # ============================================================================
67 class TestFactoryException(Exception): 68 class TestFactoryException(Exception):
@@ -315,8 +316,11 @@ class TestFactory(dict): @@ -315,8 +316,11 @@ class TestFactory(dict):
315 # normalize question points to scale 316 # normalize question points to scale
316 if self['scale'] is not None: 317 if self['scale'] is not None:
317 scale_min, scale_max = self['scale'] 318 scale_min, scale_max = self['scale']
  319 + factor = (scale_max - scale_min) / total_points
318 for question in questions: 320 for question in questions:
319 - question['points'] *= (scale_max - scale_min) / total_points 321 + question['points'] *= factor
  322 + logger.debug('Points normalized from %g to [%g, %g]',
  323 + total_points, scale_min, scale_max)
320 else: 324 else:
321 self['scale'] = [0, total_points] 325 self['scale'] = [0, total_points]
322 else: 326 else: