update 问题模块bug

This commit is contained in:
P3ngSaM 2022-08-15 15:30:47 +08:00
parent fee9404567
commit c45e9e7262
1 changed files with 35 additions and 24 deletions

View File

@ -31,6 +31,11 @@ class QuestionImpl(object):
question_type = data['question_type']
if question_type == '单选题-多解' or question_type == '多选题-多解':
if question_type == '多选题-多解':
total = [item['percentage'] for item in data['options']]
if sum(total) > 100:
return '多选多解类型得分比合计不应超过100%'
quest.options = list()
for option in data['options']:
options = quest.Options()
@ -132,7 +137,7 @@ class QuestionImpl(object):
else:
score = 0
desc = [des['描述'] for des in quest_data['题目选项']]
if set(answer) < set(desc):
if set(answer) < set(desc) or set(answer) == set(desc):
for option_ in quest_data['题目选项']:
if option_['描述'] in answer:
if option_['得分比'] == 0:
@ -164,7 +169,7 @@ class QuestionImpl(object):
else:
desc = [des['描述'] for des in quest_data['题目选项']]
right = [des['描述'] for des in quest_data['题目选项'] if des['正确'] == 1]
if set(answer) < set(desc):
if set(answer) < set(desc) or set(answer) == set(desc):
if right == answer:
score = 1
else:
@ -202,6 +207,7 @@ class QuestionImpl(object):
return score
elif question_type == '填空题-档位多解':
# 校验数据格式
if isinstance(answer, (int, float)):
decision = data['decision_setting']
setting = quest.DecisionSetting()
setting.interval = decision['interval']
@ -214,8 +220,11 @@ class QuestionImpl(object):
if eval(quest_data['判定设置']['区间'][index].replace('x', str(answer))):
score = quest_data['判定设置']['得分比'][index] * 0.01
return score
else:
return 'answer类型不能为string'
elif question_type == '填空题-指定处理':
# 校验数据格式
if isinstance(answer, (int, float)):
decision = data['decision_setting']
setting = quest.DecisionSetting()
setting.assigned = decision['assigned']
@ -227,6 +236,8 @@ class QuestionImpl(object):
else:
score = 0
return score
else:
return 'answer类型不能为string'
elif question_type == '自定义问题':
# 校验数据格式
input_setting = data['input_setting']