diff --git a/ref-test/app/tools/data.py b/ref-test/app/tools/data.py index 778c05a..7eab4d9 100644 --- a/ref-test/app/tools/data.py +++ b/ref-test/app/tools/data.py @@ -18,12 +18,10 @@ def check_is_json(file): if not '.' in file.filename or not file.filename.rsplit('.',1)[-1] == 'json': return False return True -def validate_json(file): - file.stream.seek(0) - data = json.loads(file.read()) +def validate_json(data): if not isinstance(data, list): return False for block in data: - block_type = block.pop('type', None) + block_type = block.get('type', None) if block_type not in ['block', 'question']: return False if block_type == 'question': if not all (key in block for key in ['q_no', 'text', 'options', 'correct', 'q_type', 'tags']): return False