Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,37 +74,40 @@ if role == "Quiz Creator":
|
|
| 74 |
if role == "Student Evaluation":
|
| 75 |
st.subheader("Bảng đánh giá học sinh")
|
| 76 |
|
| 77 |
-
# Lấy
|
| 78 |
res = requests.get(f"{FIREBASE_URL}/student_quizzes.json?auth={FIREBASE_AUTH}")
|
| 79 |
students = res.json() if res.status_code == 200 else {}
|
| 80 |
-
|
| 81 |
if not students:
|
| 82 |
st.info("Chưa có học sinh nào.")
|
| 83 |
else:
|
| 84 |
-
#
|
| 85 |
rows = []
|
| 86 |
for student_id, data in students.items():
|
| 87 |
-
quiz = data.get("Quiz", "")
|
| 88 |
-
score = data.get("Score", "")
|
| 89 |
-
time = data.get("Time", "")
|
| 90 |
name = data.get("Name", "")
|
| 91 |
class_ = data.get("Class", "")
|
| 92 |
-
|
| 93 |
-
"
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
df = pd.DataFrame(rows)
|
| 101 |
st.dataframe(df)
|
| 102 |
-
|
| 103 |
-
st.subheader("Nhập Feedback")
|
| 104 |
for student_id, data in students.items():
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
| 74 |
if role == "Student Evaluation":
|
| 75 |
st.subheader("Bảng đánh giá học sinh")
|
| 76 |
|
| 77 |
+
# Lấy tất cả học sinh
|
| 78 |
res = requests.get(f"{FIREBASE_URL}/student_quizzes.json?auth={FIREBASE_AUTH}")
|
| 79 |
students = res.json() if res.status_code == 200 else {}
|
| 80 |
+
|
| 81 |
if not students:
|
| 82 |
st.info("Chưa có học sinh nào.")
|
| 83 |
else:
|
| 84 |
+
# Tạo danh sách các dòng cho DataFrame
|
| 85 |
rows = []
|
| 86 |
for student_id, data in students.items():
|
|
|
|
|
|
|
|
|
|
| 87 |
name = data.get("Name", "")
|
| 88 |
class_ = data.get("Class", "")
|
| 89 |
+
for key, quiz_data in data.items():
|
| 90 |
+
if key.startswith("Quiz"): # Chỉ lấy các quiz
|
| 91 |
+
score = quiz_data.get("Score", "")
|
| 92 |
+
time = quiz_data.get("Time", "")
|
| 93 |
+
rows.append({
|
| 94 |
+
"ID": student_id,
|
| 95 |
+
"Name": name,
|
| 96 |
+
"Class": class_,
|
| 97 |
+
"Quiz": key,
|
| 98 |
+
"Score": score,
|
| 99 |
+
"Time": time
|
| 100 |
+
})
|
| 101 |
df = pd.DataFrame(rows)
|
| 102 |
st.dataframe(df)
|
| 103 |
+
|
| 104 |
+
st.subheader("Nhập Feedback cho từng quiz")
|
| 105 |
for student_id, data in students.items():
|
| 106 |
+
for key, quiz_data in data.items():
|
| 107 |
+
if key.startswith("Quiz"):
|
| 108 |
+
st.markdown(f"**ID: {student_id} - {data.get('Name','')} - {key}**")
|
| 109 |
+
feedback = st.text_area("Feedback", key=f"fb_{student_id}_{key}")
|
| 110 |
+
if st.button(f"Gửi Feedback cho {student_id} - {key}", key=f"submit_fb_{student_id}_{key}"):
|
| 111 |
+
url_fb = f"{FIREBASE_URL}/student_quizzes/{student_id}/{key}/feedback.json?auth={FIREBASE_AUTH}"
|
| 112 |
+
requests.put(url_fb, json=feedback)
|
| 113 |
+
st.success(f"Đã gửi feedback cho {student_id} - {key}")
|