Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- Diemthi2024_processed_csl.json +0 -0
- app.py +40 -0
Diemthi2024_processed_csl.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import gradio as gr
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
# Đọc dữ liệu từ file JSON
|
6 |
+
with open('Diemthi2024_processed_csl.json', 'r', encoding='utf-8') as file:
|
7 |
+
data = json.load(file)
|
8 |
+
|
9 |
+
# Hàm tra cứu điểm thi
|
10 |
+
def tra_cuu_diem_thi(sbd):
|
11 |
+
if sbd in data:
|
12 |
+
columns_diem = data["columns điểm"]
|
13 |
+
columns_tohop = data["columns tổ hợp"]
|
14 |
+
ket_qua = data[sbd]
|
15 |
+
diem_thi = [ket_qua["Điểm thi"]]
|
16 |
+
to_hop_list = ket_qua["Tổ hợp"]
|
17 |
+
to_hop_list_str = []
|
18 |
+
for s1, d2, d3, s4, s5 in to_hop_list:
|
19 |
+
to_hop_list_str.append([s1, f"{d2:0.2f}", f"{d3:0.2f}", s4, s5])
|
20 |
+
df_diem = pd.DataFrame(diem_thi, columns=columns_diem)
|
21 |
+
df_tohop = pd.DataFrame(to_hop_list_str, columns=columns_tohop)
|
22 |
+
return df_diem, df_tohop
|
23 |
+
else:
|
24 |
+
return "Không tìm thấy kết quả cho SBD này.", None
|
25 |
+
|
26 |
+
# Tạo giao diện Gradio
|
27 |
+
with gr.Blocks() as demo:
|
28 |
+
gr.Markdown("# Tra cứu điểm thi TN 2024 (Trường THPT Chuyên - Tỉnh Sơn La)")
|
29 |
+
|
30 |
+
sbd_input = gr.Textbox(label="Nhập SBD")
|
31 |
+
tra_cuu_btn = gr.Button("Tra cứu")
|
32 |
+
# out_diem = gr.Textbox(label="Điểm các môn thi", elem_classes="large-font")
|
33 |
+
#out_diem = gr.Markdown(label="Điềm các môn thi")
|
34 |
+
out_diem = gr.DataFrame(label="Điềm các môn thi", col_count=(9, "fixed"), row_count=(1, "fixed"))
|
35 |
+
out_tohop = gr.DataFrame(label="Các tổ hợp xét tuyển", col_count=(5, "fixed"), row_count=(15, "fixed"))
|
36 |
+
|
37 |
+
tra_cuu_btn.click(tra_cuu_diem_thi, inputs=sbd_input, outputs=[out_diem, out_tohop])
|
38 |
+
|
39 |
+
# Chạy ứng dụng
|
40 |
+
demo.launch()
|