Commit 074f8187e83bf950c01ceab806fccc79dd605f20

Authored by Miguel Barão
1 parent 5ca3c366
Exists in master and in 1 other branch dev

- added --review option to start test without loading questions. This is used to…

… review previously submited tests.
Showing 2 changed files with 20 additions and 15 deletions   Show diff stats
serve.py
... ... @@ -323,6 +323,7 @@ def main():
323 323 argparser.add_argument('--allow-all', action='store_true', help='Students are initially allowed to login (can be denied later)')
324 324 argparser.add_argument('--debug', action='store_true', help='Enable debug messages')
325 325 argparser.add_argument('--show-ref', action='store_true', help='Show question references')
  326 + argparser.add_argument('--review', action='store_true', help='Review mode: don\'t generate test')
326 327  
327 328 arg = argparser.parse_args()
328 329  
... ... @@ -344,6 +345,7 @@ def main():
344 345 'debug': arg.debug,
345 346 'allow_all': arg.allow_all,
346 347 'show_ref': arg.show_ref,
  348 + 'review': arg.review,
347 349 }
348 350  
349 351 try:
... ...
test.py
... ... @@ -34,21 +34,24 @@ class TestFactory(dict):
34 34 # set defaults and sanity checks
35 35 self.sanity_checks()
36 36  
37   - # loads question_factory
38   - self.question_factory = questions.QuestionFactory()
39   - self.question_factory.load_files(files=self['files'], questions_dir=self['questions_dir'])
40   -
41   - # check if all questions exist ('ref' keys are correct?)
42   - for q in self['questions']:
43   - for r in q['ref']:
44   - logger.info(f'Checking question "{r}".')
45   - try:
46   - self.question_factory.generate(r)
47   - except questions.QuestionFactoryException:
48   - logger.critical(f'Can\'t generate question "{r}".')
49   - raise TestFactoryException()
50   -
51   - logger.info(f'Test factory ready for "{self["ref"]}".')
  37 + if conf['review']:
  38 + logger.info('Review mode. No questions loaded.')
  39 + else:
  40 + # loads question_factory
  41 + self.question_factory = questions.QuestionFactory()
  42 + self.question_factory.load_files(files=self['files'], questions_dir=self['questions_dir'])
  43 +
  44 + # check if all questions exist ('ref' keys are correct?)
  45 + for q in self['questions']:
  46 + for r in q['ref']:
  47 + logger.info(f'Checking question "{r}".')
  48 + try:
  49 + self.question_factory.generate(r)
  50 + except questions.QuestionFactoryException:
  51 + logger.critical(f'Can\'t generate question "{r}".')
  52 + raise TestFactoryException()
  53 +
  54 + logger.info(f'Test factory ready for "{self["ref"]}".')
52 55  
53 56  
54 57 # -----------------------------------------------------------------------
... ...