|
|
@@ -0,0 +1,96 @@
|
|
|
+import ujson
|
|
|
+import time
|
|
|
+from typing import Dict, List, Any
|
|
|
+from random import sample,random
|
|
|
+
|
|
|
+
|
|
|
+def encapsulate(op_type: int, data: Dict[str, Any]) -> str:
|
|
|
+ e_log = {
|
|
|
+ "target": 1, # 暂时只有smart这一个target
|
|
|
+ "source": 0, # 暂时只有eval这一个source
|
|
|
+ "op_type": op_type,
|
|
|
+ "created_time": "2021-12-29 17:15:00",
|
|
|
+ "data": ujson.dumps(data),
|
|
|
+ "message": ""
|
|
|
+ }
|
|
|
+ return ujson.dumps(e_log)
|
|
|
+
|
|
|
+
|
|
|
+def get_question_list() -> List[str]:
|
|
|
+ return ['d8009eb4-5833-424d-91c3-7dbc160a2a0a', 'b58e18a6-18f5-42b6-ab45-3ecbcb4c97ca', '290dc9de58cd4a37b9a7a52847ccd1ce',
|
|
|
+ '742fa61f-8c6f-4f62-a997-e5900263f77b', '724eddaa-9414-4803-8920-579416eccccc', '27019', '21016', '3026', '19037', '19035', '19033', '19031',
|
|
|
+ '19030', 'JL-56nwBGvo2WgFx-3pf', 'I7-56nwBGvo2WgFx-3pf', 'Ir-56nwBGvo2WgFx-3pf', 'Ib-56nwBGvo2WgFx-3pf', 'Hb-u5nwBGvo2WgFxV3ps', 'Hr-u5nwBGvo2WgFxV3pt']
|
|
|
+
|
|
|
+
|
|
|
+class Exam(object):
|
|
|
+ def __init__(self, exam_id, exam_score, questions):
|
|
|
+ self.exam_id = exam_id
|
|
|
+ self.exam_score = exam_score
|
|
|
+ self.questions = questions
|
|
|
+ self.difficulty = 1
|
|
|
+ self.update_time = "2021-09-29 17:15:00"
|
|
|
+ self.start_time = "2021-09-29 17:15:00"
|
|
|
+ self.end_time = "2021-09-29 19:15:00"
|
|
|
+
|
|
|
+
|
|
|
+class Question(object):
|
|
|
+ def __init__(self, question_id, question_score):
|
|
|
+ self.question_id = question_id
|
|
|
+ self.question_score = question_score
|
|
|
+
|
|
|
+
|
|
|
+class Answer(object):
|
|
|
+ def __init__(self, exam_id, student_id, score, error_ques):
|
|
|
+ self.exam_id = exam_id
|
|
|
+ self.student_id = student_id
|
|
|
+ self.submit_time = "2021-11-03 00:58:03"
|
|
|
+ self.score = score
|
|
|
+ self.error_ques = error_ques
|
|
|
+
|
|
|
+
|
|
|
+class ErrorQuestion(object):
|
|
|
+ def __init__(self, question_id, actual_score):
|
|
|
+ self.question_id = question_id
|
|
|
+ self.actual_score = actual_score
|
|
|
+
|
|
|
+
|
|
|
+def mock():
|
|
|
+ # 教师提交试题A
|
|
|
+ j0 = '{"exam_id":1,"exam_score":100,"questions":[{"question_id":"d8009eb4-5833-424d-91c3-7dbc160a2a0a","question_score":12.5},{"question_id":"b58e18a6-18f5-42b6-ab45-3ecbcb4c97ca","question_score":12.5},{"question_id":"290dc9de58cd4a37b9a7a52847ccd1ce","question_score":12.5},{"question_id":"742fa61f-8c6f-4f62-a997-e5900263f77b","question_score":12.5},{"question_id":"724eddaa-9414-4803-8920-579416eccccc","question_score":12.5},{"question_id":"27019","question_score":12.5},{"question_id":"21016","question_score":12.5},{"question_id":"3026","question_score":12.5}],"difficulty":0,"update_time":"2021-09-29 17:15:00","start_time":"2021-09-29 17:15:00","end_time":"2021-09-29 19:15:00"}'
|
|
|
+ # 教师提交试题A的修改
|
|
|
+ j1 = '{"exam_id":1,"exam_score":100,"questions":[{"question_id":"d8009eb4-5833-424d-91c3-7dbc160a2a0a","question_score":12.5},{"question_id":"b58e18a6-18f5-42b6-ab45-3ecbcb4c97ca","question_score":12.5},{"question_id":"290dc9de58cd4a37b9a7a52847ccd1ce","question_score":12.5},{"question_id":"742fa61f-8c6f-4f62-a997-e5900263f77b","question_score":12.5},{"question_id":"724eddaa-9414-4803-8920-579416eccccc","question_score":12.5},{"question_id":"27019","question_score":12.5},{"question_id":"21016","question_score":12.5},{"question_id":"3026","question_score":12.5}],"difficulty":0,"update_time":"2021-09-29 18:15:00","start_time":"2021-11-03 0:15:00","end_time":"2021-11-03 19:15:00"}'
|
|
|
+ # 学生1提交试题A的解答
|
|
|
+ j2 = '{"exam_id":1,"student_id":1032,"submit_time":"2021-11-03 10:25:38","score":62.5,"error_ques":[{"question_id":"290dc9de58cd4a37b9a7a52847ccd1ce","actual_score":0.0},{"question_id":"21016","actual_score":0.0},{"question_id":"3026","actual_score":0.0}]}'
|
|
|
+ # 学生2提交试题A的解答
|
|
|
+ j3 = '{"exam_id":1,"student_id":1458,"submit_time":"2021-11-03 00:58:03","score":62.5,"error_ques":[{"question_id":"27019","actual_score":0.0},{"question_id":"21016","actual_score":0.0}]}'
|
|
|
+
|
|
|
+ j_strs = [j0, j1, j2, j3]
|
|
|
+ op_types = [0,1,2,2]
|
|
|
+ for i in range(4):
|
|
|
+ with open("mock{}.log".format(i), "w") as f:
|
|
|
+ f.write(encapsulate(op_types[i], ujson.loads(j_strs[i])))
|
|
|
+
|
|
|
+
|
|
|
+def main():
|
|
|
+ question_list = get_question_list()
|
|
|
+
|
|
|
+ total_count = 0
|
|
|
+ for i in range(2, 20): # randomly generate exams
|
|
|
+ ques = sample(question_list, int(8*random())+4)
|
|
|
+ e = Exam(i, len(ques), [Question(q, 1).__dict__ for q in ques])
|
|
|
+
|
|
|
+ with open("gen{}.log".format(total_count), "w") as f:
|
|
|
+ f.write(encapsulate(0, e.__dict__))
|
|
|
+ total_count += 1
|
|
|
+
|
|
|
+ for j in ["1032", "1458"]:
|
|
|
+ error_ques = sample(ques, int(len(ques)*random()))
|
|
|
+ a = Answer(i, j, e.exam_score - len(error_ques), [ErrorQuestion(e, 0).__dict__ for e in error_ques])
|
|
|
+
|
|
|
+ with open("gen{}.log".format(total_count), "w") as f:
|
|
|
+ f.write(encapsulate(2, a.__dict__))
|
|
|
+ total_count += 1
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ mock()
|
|
|
+ main()
|