Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,27 +38,35 @@ role = st.selectbox("Chọn vai trò", ["Master", "Học sinh"])
|
|
| 38 |
# ==========================
|
| 39 |
if role == "Master":
|
| 40 |
st.subheader("Đăng nhập Master")
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# ==========================
|
| 64 |
# STUDENT SECTION
|
|
|
|
| 38 |
# ==========================
|
| 39 |
if role == "Master":
|
| 40 |
st.subheader("Đăng nhập Master")
|
| 41 |
+
|
| 42 |
+
if not st.session_state.master_logged_in:
|
| 43 |
+
username = st.text_input("Tài khoản")
|
| 44 |
+
password = st.text_input("Mật khẩu", type="password")
|
| 45 |
+
|
| 46 |
+
if st.button("Đăng nhập"):
|
| 47 |
+
if username == "master" and password == "master":
|
| 48 |
+
st.session_state.master_logged_in = True
|
| 49 |
+
st.success("Đăng nhập thành công!")
|
| 50 |
+
else:
|
| 51 |
+
st.error("Sai tài khoản hoặc mật khẩu")
|
| 52 |
+
st.stop()
|
| 53 |
+
|
| 54 |
+
# Nếu đã đăng nhập thì hiển thị giao diện tạo quiz
|
| 55 |
+
st.success("Bạn đang đăng nhập với quyền Master")
|
| 56 |
+
|
| 57 |
+
st.subheader("Tạo Quiz mới")
|
| 58 |
+
quiz_name = st.text_input("Tên Quiz (ví dụ: Quiz1)")
|
| 59 |
+
question = st.text_area("Câu hỏi")
|
| 60 |
+
correct_answer = st.text_input("Đáp án đúng")
|
| 61 |
+
|
| 62 |
+
if st.button("Lưu Quiz"):
|
| 63 |
+
url = f"{FIREBASE_URL}/quiz_definitions/{quiz_name}.json"
|
| 64 |
+
requests.put(url, json={
|
| 65 |
+
"question": question,
|
| 66 |
+
"answer": correct_answer,
|
| 67 |
+
})
|
| 68 |
+
st.success("Đã lưu quiz!")
|
| 69 |
+
|
| 70 |
|
| 71 |
# ==========================
|
| 72 |
# STUDENT SECTION
|