def login(): stu_id = request.get_json()['stuId'] password = request.get_json()['password'] try: zf_session, name, board_msg = s_login(stu_id, password, url) except Exception as e: print(e) raise APIException("error", str(e), 401) return jsonify({'name': name, 'board_msg': board_msg})
def teaching_evaluate(): stu_id = request.get_json()['stuId'] password = request.get_json()['password'] try: zf_session, name, board_msg = s_login(stu_id, password, url) except Exception as e: print(e) raise APIException("error", str(e), 403) from ZfQueryMod.teaching_evaluate import evaluate evaluate(stu_id, zf_session, url) return "ossas"
def get_course_table(): stu_id = request.get_json()['stuId'] password = request.get_json()['password'] try: zf_session, name, board_msg = s_login(stu_id, password, url) except Exception as e: print(e) raise APIException("error", str(e), 403) from ZfQueryMod.query import course_table table = course_table(stu_id, zf_session, url) return jsonify(table)
def get_exams(): stu_id = request.get_json()['stuId'] password = request.get_json()['password'] try: zf_session, name, board_msg = s_login(stu_id, password, url) except Exception as e: print(e) raise APIException("error", str(e), 403) from ZfQueryMod.query import query_exam table = query_exam(stu_id, zf_session, url) data = {'msg': table[0], 'exams': table[1]} return jsonify(data)
def history_scores(): stu_id = request.get_json()['stuId'] password = request.get_json()['password'] try: zf_session, name, board_msg = s_login(stu_id, password, url) except Exception as e: print(e) raise APIException("error", str(e), 401) from ZfQueryMod.query import query_score from ZfQueryMod.gpa import average scores_list = query_score(stu_id, zf_session, url) if not scores_list: raise APIException("oops", "未进行教学评价", 403) data = {"scores": scores_list, "avg": average(scores_list)} return jsonify(data)