api-datamanager/Modules/Questions/QuestionsObj.py

82 lines
3.1 KiB
Python
Raw Normal View History

2022-07-12 10:28:05 +08:00
from Utils.ObjUtil import SpecObject
from Utils.ValidateUtil import ValidateAttr, Validate
class QuestionObj(SpecObject):
"""问题"""
class Options(SpecObject):
"""题目选项"""
percentage = ValidateAttr(field="percentage", type=[int, float])
correct = ValidateAttr(field="correct", type=int, in_list=[0, 1])
describe = ValidateAttr(field="describe", type=str)
fields_map = {
"percentage": "得分比",
"correct": "正确",
"describe": "描述"
}
class DecisionSetting(SpecObject):
"""判定设置"""
2022-07-18 19:59:11 +08:00
interval = ValidateAttr(field="interval", type=list)
2022-07-12 10:28:05 +08:00
contain = ValidateAttr(field="contain", type=list)
score = ValidateAttr(field="score", type=list)
answer = ValidateAttr(field="answer", type=str)
assigned = ValidateAttr(field="assigned", type=str)
fields_map = {
"interval": "区间",
"contain": "包含",
"score": "得分比",
"answer": "正确答案",
"assigned": "指定处理"
}
class InputSetting(SpecObject):
"""输入设置"""
input = ValidateAttr(field="input", type=[str, int, float])
type = ValidateAttr(field="type", type=str)
mark = ValidateAttr(field="mark", type=str)
fields_map = {
"input": "输入",
"type": "类型",
"mark": "备注"
}
2022-07-18 19:59:11 +08:00
class Tags(SpecObject):
"""标签"""
tag_name = ValidateAttr(field='tag_name', type=str)
tag_id = ValidateAttr(field='tag_id', type=str)
fields_map = {
"tag_name": "标签名称",
"tag_id": "标签ID"
}
2022-07-12 10:28:05 +08:00
question_id = ValidateAttr(field="question_id", type=str)
question_name = ValidateAttr(field="question_name", type=str)
question_type = ValidateAttr(field="question_type", type=str, in_list=['单选题-多解', '多选题-多解', '单选题-单解',
'多选题-单解', '填空题-单解', '填空题-包含多解',
'填空题-档位多解', '填空题-指定处理', '自定义问题'])
describe = ValidateAttr(field="describe", type=str)
options = ValidateAttr(field="options", instance_list=Options)
decision_setting = ValidateAttr(field="decision_setting", type=DecisionSetting)
input_setting = ValidateAttr(field="input_setting", instance_list=InputSetting)
author = ValidateAttr(field="author", type=str)
date = ValidateAttr(field="date", func=Validate.date_format)
2022-07-18 19:59:11 +08:00
tags = ValidateAttr(field="tags", instance_list=Tags)
2022-07-12 10:28:05 +08:00
fields_map = {
"question_id": "问题ID",
"question_name": "问题名称",
"question_type": "问题类型",
"describe": "题目描述",
"options": "题目选项",
"decision_setting": "判定设置",
"input_setting": "输入设置",
"author": "作者",
"date": "日期",
"tags": "标签"
}