Finished quiz and debugging
This commit is contained in:
@ -20,7 +20,7 @@ def generate_questions(dataset:list):
|
||||
'text': block['text']
|
||||
}
|
||||
if block['q_type'] == 'Multiple Choice': question['options'] = randomise_list([*enumerate(block['options'])])
|
||||
else: question['options'] = block['options'].copy()
|
||||
else: question['options'] = [*enumerate(block['options'])]
|
||||
output.append(question)
|
||||
elif block['type'] == 'block':
|
||||
for key, _question in enumerate(randomise_list(block['questions'])):
|
||||
@ -33,7 +33,7 @@ def generate_questions(dataset:list):
|
||||
'text': _question['text']
|
||||
}
|
||||
if _question['q_type'] == 'Multiple Choice': question['options'] = randomise_list([*enumerate(_question['options'])])
|
||||
else: question['options'] = _question['options'].copy()
|
||||
else: question['options'] = [*enumerate(_question['options'])]
|
||||
output.append(question)
|
||||
return output
|
||||
|
||||
@ -66,6 +66,14 @@ def evaluate_answers(answers:dict, key:list):
|
||||
'max': 1
|
||||
}
|
||||
else: tags[tag]['max'] += 1
|
||||
else:
|
||||
for tag in block['tags']:
|
||||
if tag not in tags:
|
||||
tags[tag] = {
|
||||
'scored': 0,
|
||||
'max': 1
|
||||
}
|
||||
else: tags[tag]['max'] += 1
|
||||
elif block['type'] == 'block':
|
||||
for question in block['questions']:
|
||||
max += 1
|
||||
@ -91,6 +99,14 @@ def evaluate_answers(answers:dict, key:list):
|
||||
'max': 1
|
||||
}
|
||||
else: tags[tag]['max'] += 1
|
||||
else:
|
||||
for tag in question['tags']:
|
||||
if tag not in tags:
|
||||
tags[tag] = {
|
||||
'scored': 0,
|
||||
'max': 1
|
||||
}
|
||||
else: tags[tag]['max'] += 1
|
||||
grade = 'merit' if score/max >= .85 else 'pass' if score/max >= .70 else 'fail'
|
||||
return {
|
||||
'grade': grade,
|
||||
@ -103,10 +119,10 @@ def get_correct_answers(dataset:list):
|
||||
output = {}
|
||||
for block in dataset:
|
||||
if block['type'] == 'question':
|
||||
output[str(block['q_no'])] = block['options'][block['correct']]
|
||||
output[str(block['q_no'])] = block['correct']
|
||||
if block['type'] == 'block':
|
||||
for question in block['questions']:
|
||||
output[str(question['q_no'])] = question['options'][question['correct']]
|
||||
output[str(question['q_no'])] = question['correct']
|
||||
return output
|
||||
|
||||
def redirect_if_started(function):
|
||||
@ -117,3 +133,15 @@ def redirect_if_started(function):
|
||||
return redirect(url_for('quiz._quiz'))
|
||||
return function(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
def answer_options(dataset:list):
|
||||
output = []
|
||||
for block in dataset:
|
||||
if block['type'] == 'question':
|
||||
question = block['options'].copy()
|
||||
output.append(question)
|
||||
elif block['type'] == 'block':
|
||||
for _question in block['questions']:
|
||||
question = _question['options'].copy()
|
||||
output.append(question)
|
||||
return output
|
Reference in New Issue
Block a user