Exemplo n.º 1
0
 def post(self):
     files = self.request.files.get("file", None)
     exam_name = str(*self.request.body_arguments.get("exam_name"),
                     encoding="utf-8")
     start_time = str(*self.request.body_arguments.get("start_time"),
                      encoding="utf-8")
     end_time = str(*self.request.body_arguments.get("end_time"),
                    encoding="utf-8")
     last = str(*self.request.body_arguments.get("last"), encoding="utf-8")
     score = str(*self.request.body_arguments.get("score"),
                 encoding="utf-8")
     author = str(*self.request.body_arguments.get("author"),
                  encoding="utf-8")
     if exam_name and start_time and end_time and last and score and author:
         start_timestamp = TimeProcess.save_to_table(start_time)
         end_timestamp = TimeProcess.save_to_table(end_time)
         if files:
             for file in files:
                 filename = file['filename']
                 name, exp = os.path.splitext(filename)
                 file_control = FileManager()
                 result = file_control.add_files(file['body'], exp,
                                                 exam_name, author,
                                                 filename, start_timestamp,
                                                 end_timestamp, last, score)
                 if result:
                     self.finish(Result.success(message="试卷上传成功!"))
                 else:
                     self.finish(Result.params_error(message="信息写入错误!"))
         else:
             self.finish(Result.not_this_message(message="文件上传错误!请重试!"))
     else:
         self.finish(Result.params_error(message="参数信息不全, 请修改后重新上传"))
Exemplo n.º 2
0
 def get(self):
     exam_no = self.get_argument("exam_no")
     student_no = self.get_argument("student_no")
     if StudentToExam.is_exists(student_no, exam_no):
         result = StudentToExam.get_content(student_no, exam_no)
         if result:
             self.finish(Result.success(message=result))
         else:
             self.finish(Result.params_error(message="您不能参加本次考试!"))
     else:
         result = StudentToExam.add_content(student_no, exam_no)
         if result:
             self.finish(Result.success(message=str([*result])))
         else:
             self.finish(Result.params_error(message="数据错误,请重试!"))
Exemplo n.º 3
0
 def get(self):
     student_no = self.get_argument("student_no")
     result = StudentToExam.get_attend_exam(student_no)
     if result:
         self.finish(Result.success(message=str(*result)))
     else:
         self.finish(Result.params_error(message="获取失败!"))
Exemplo n.º 4
0
 def delete(self):
     exam_no = self.get_argument("exam_no")
     result = Exams.delete_exam(exam_no)
     if result:
         self.finish(Result.success(message="删除成功!"))
     else:
         self.finish(Result.params_error(message="删除错误,请刷新后重试!"))
Exemplo n.º 5
0
 def get(self):
     author = self.get_argument("username")
     result = Exams.get_exam(author)
     if result:
         self.finish(Result.success(message=json.loads(result)))
     else:
         self.finish(Result.params_error(message="出现错误!"))
Exemplo n.º 6
0
 def get(self):
     no = self.get_argument("student_no")
     result = Students.active_email(no)
     if result:
         self.finish(
             Result.success(message="尊敬的{},您的邮箱已经激活!感谢您的使用!".format(no)))
     else:
         self.finish(Result.params_error(message="激活失败,请检查您的信息是否正确!"))
Exemplo n.º 7
0
 def post(self):
     message = json.loads(self.request.body)
     auth_no = message['auth_no']
     detail = message['detail']
     result = AuthInformation.change_base_information(auth_no,
                                                      detail=detail)
     if result:
         self.finish(Result.success(message="信息修改成功!"))
     else:
         self.finish(Result.params_error(message="参数错误,请重试!"))
Exemplo n.º 8
0
 def put(self):
     message = json.loads(self.request.body)
     student_no = message['student_no']
     exam_no = message['exam_no']
     content = message['content']
     if StudentToExam.is_exists(student_no=student_no, exam_no=exam_no):
         result = StudentToExam.temp_save(student_no=student_no,
                                          exam_no=exam_no,
                                          content=content)
         if result:
             self.finish(Result.success(message="提交成功!"))
         else:
             self.finish(Result.params_error(message="提交错误,请重试!"))
Exemplo n.º 9
0
 def post(self):
     message = json.loads(self.request.body)
     no = message['student_no']
     email = message['email']
     result = Students.add_email(no, email)
     if result:
         email_send = student_check(email, no)
         if email_send:
             self.finish(Result.success(message="信息发出成功!邮箱添加成功!"))
         else:
             self.finish(
                 Result.not_this_message(message="邮箱服务出现错误,不能提供服务,请谅解!"))
     else:
         self.finish(Result.params_error(message="邮箱已添加不必重复操作!"))
Exemplo n.º 10
0
 def post(self):
     message = json.loads(self.request.body)
     teacher_no = message['teacher_no']
     teacher_name = message['teacher_name']
     password = message['password']
     email = message['email']
     if Teachers.is_exists(teacher_no):
         self.finish(Result.already_register(message="该用户已经注册"))
     else:
         result = Teachers.add_teacher(teacher_no, teacher_name,
                                       hashed(password), email)
         if result:
             self.finish(Result.success(message="信息添加成功!"))
         else:
             self.finish(Result.params_error(message="注册失败!参数出现错误,请重试!"))