Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -32,23 +32,20 @@ if uploaded_file is not None:
|
|
32 |
# Take Attendance
|
33 |
st.subheader("Record Attendance")
|
34 |
attendance_date = st.date_input("Select Date")
|
35 |
-
image_file = st.file_uploader("Upload Image for Attendance", type=['jpg', 'png', 'jpeg'])
|
36 |
-
|
37 |
-
# Initialize present_students outside the button condition
|
38 |
-
present_students = []
|
39 |
|
40 |
if st.button("Take Attendance"):
|
41 |
if image_file is not None and selected_course and attendance_date:
|
42 |
image_path = os.path.join(UPLOAD_FOLDER, image_file.name)
|
43 |
with open(image_path, "wb") as f:
|
44 |
f.write(image_file.getbuffer())
|
45 |
-
present_students = attendance_system.record_attendance(selected_course, attendance_date, image_path)
|
46 |
|
47 |
# Display the count of present students
|
48 |
-
length = len(present_students)
|
49 |
-
ty = type(present_students).__name__ # Get the name of the type as a string
|
50 |
st.success(f"{length} students' attendance completed successfully. This is a {ty}.")
|
51 |
-
st.json(present_students)
|
52 |
|
53 |
# Mark attendance section
|
54 |
st.subheader("Mark Attendance")
|
@@ -64,7 +61,7 @@ if selected_roll_numbers:
|
|
64 |
st.write("Selected Roll Numbers to Add:", selected_roll_numbers)
|
65 |
|
66 |
# Combine the present students with the selected roll numbers
|
67 |
-
present_students_str = [str(student) for student in present_students]
|
68 |
combined_students = list(set(present_students_str) | set(selected_roll_numbers))
|
69 |
|
70 |
# Optionally, show final list of students
|
@@ -75,7 +72,9 @@ if st.button("Mark Attendance"):
|
|
75 |
# Convert combined_students back to integers for record_attendance_new function
|
76 |
combined_students_int = [int(student) for student in combined_students]
|
77 |
record_attendance_new(combined_students_int, selected_course)
|
78 |
-
st.success("
|
|
|
|
|
79 |
# Add to database
|
80 |
st.subheader("Add Student to Database")
|
81 |
roll_number = st.text_input("Enter Roll Number")
|
|
|
32 |
# Take Attendance
|
33 |
st.subheader("Record Attendance")
|
34 |
attendance_date = st.date_input("Select Date")
|
35 |
+
image_file = st.file_uploader("Upload Image for Attendance", type=['jpg', 'png', 'jpeg'])
|
|
|
|
|
|
|
36 |
|
37 |
if st.button("Take Attendance"):
|
38 |
if image_file is not None and selected_course and attendance_date:
|
39 |
image_path = os.path.join(UPLOAD_FOLDER, image_file.name)
|
40 |
with open(image_path, "wb") as f:
|
41 |
f.write(image_file.getbuffer())
|
42 |
+
st.session_state.present_students = attendance_system.record_attendance(selected_course, attendance_date, image_path)
|
43 |
|
44 |
# Display the count of present students
|
45 |
+
length = len(st.session_state.present_students)
|
46 |
+
ty = type(st.session_state.present_students).__name__ # Get the name of the type as a string
|
47 |
st.success(f"{length} students' attendance completed successfully. This is a {ty}.")
|
48 |
+
st.json(st.session_state.present_students)
|
49 |
|
50 |
# Mark attendance section
|
51 |
st.subheader("Mark Attendance")
|
|
|
61 |
st.write("Selected Roll Numbers to Add:", selected_roll_numbers)
|
62 |
|
63 |
# Combine the present students with the selected roll numbers
|
64 |
+
present_students_str = [str(student) for student in st.session_state.present_students]
|
65 |
combined_students = list(set(present_students_str) | set(selected_roll_numbers))
|
66 |
|
67 |
# Optionally, show final list of students
|
|
|
72 |
# Convert combined_students back to integers for record_attendance_new function
|
73 |
combined_students_int = [int(student) for student in combined_students]
|
74 |
record_attendance_new(combined_students_int, selected_course)
|
75 |
+
st.success(f"{len(combined_students_int)} students' attendance is going to record.")
|
76 |
+
st.success(f"{len(combined_students_int)} students' roll number is going to record. Students present in combined_student: {combined_students_int}")
|
77 |
+
|
78 |
# Add to database
|
79 |
st.subheader("Add Student to Database")
|
80 |
roll_number = st.text_input("Enter Roll Number")
|