def get_by_project_teacher(teacher_id): result = list() id_std = request.args.get("id_std") try: ma_gv = TeacherModel.get_magvhd_by_id(teacher_id=teacher_id) projects = ProjectModel.get_project_by_teacher(ma_gv) cap = StudentModel.get_level_student_id(id_std) except Exception as e: print(e) return jsonify({ "message": "Có lỗi phát sinh trong server!", "code": 500 }), 500 for project in projects: check = StudentModel.get_data_by_project(project.id) if id_std and str(project.Cap) != str(cap): continue result.append({ "id": project.id, "Ten": project.Ten, "Mota": project.MoTa, "TrangThai": project.TrangThai if not check else "Đã chọn", "GhiChu": project.GhiChu, "Cap": project.Cap }) return jsonify({ "message": "request thành công!", "data": result, "code": 200 }), 200
def get_all_teacher_not_enough_student(): soluong = request.args.get("soluong", SoLuongSV.GVTiepNhan) id_std = request.args.get("id_std") try: cap = StudentModel.get_level_student_id(student_id=id_std) all_code_teachers = list() all_project_teachers = ProjectModel.get_project_by_cap(cap) for project in all_project_teachers: all_code_teachers.append(project.ChiDinh) teachers = TeacherModel.get_teacher_by_lt_soluong_tids( soluong=soluong, codes=all_code_teachers ) except Exception as e: return jsonify({"messgae": str(e), "code": 500}), 500 result = list() for teacher in teachers: data_teacher = { "ten": teacher.Ten, "soluong": teacher.SoLuong, "magv": teacher.MaGV, "email": teacher.Email } result.append(data_teacher) return jsonify({"messgae": "Lấy thông tin thành công!", "code": 200, "data": result}), 200