Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,16 +36,7 @@ image_file = st.file_uploader("Upload Image for Attendance", type=['jpg', 'png',
|
|
36 |
# Initialize present_students outside the button condition
|
37 |
present_students = []
|
38 |
|
39 |
-
# Define the possible roll numbers
|
40 |
-
roll_numbers = [str(i) for i in range(1, 27)] # Roll numbers 1 to 26
|
41 |
|
42 |
-
# Allow user to select roll numbers to add manually
|
43 |
-
selected_roll_numbers = st.multiselect("Select Roll Numbers to Add", options=roll_numbers, key="roll_number_selector")
|
44 |
-
|
45 |
-
# Display the selected roll numbers
|
46 |
-
if selected_roll_numbers:
|
47 |
-
st.write("Selected Roll Numbers to Add:", selected_roll_numbers)
|
48 |
-
|
49 |
if st.button("Take Attendance"):
|
50 |
if image_file is not None and selected_course and attendance_date:
|
51 |
image_path = os.path.join(UPLOAD_FOLDER, image_file.name)
|
@@ -56,32 +47,19 @@ if st.button("Take Attendance"):
|
|
56 |
# Display the count of present students
|
57 |
length = len(present_students)
|
58 |
ty = type(present_students).__name__ # Get the name of the type as a string
|
59 |
-
st.success(f"{length} students' attendance completed successfully.
|
60 |
st.json(present_students)
|
61 |
-
|
62 |
-
# Mark attendance section
|
63 |
-
st.subheader("Mark Attendance")
|
64 |
-
# Combine the present students with the selected roll numbers
|
65 |
-
present_students_str = [str(student) for student in present_students]
|
66 |
-
if selected_roll_numbers:
|
67 |
-
combined_students = list(set(present_students_str) | set(selected_roll_numbers))
|
68 |
-
# Optionally, show final list of students
|
69 |
-
st.write("Final List of Present Students:", combined_students)
|
70 |
-
st.success(f"{len(combined_students)} students' attendance after combining automatic and manual lists.")
|
71 |
-
else:
|
72 |
-
combined_students = present_students_str
|
73 |
-
|
74 |
-
if st.button("Mark Attendance"):
|
75 |
# Convert combined_students back to integers for record_attendance_new function
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
|
86 |
# Add to database
|
87 |
st.subheader("Add Student to Database")
|
|
|
36 |
# Initialize present_students outside the button condition
|
37 |
present_students = []
|
38 |
|
|
|
|
|
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)
|
|
|
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.")
|
51 |
st.json(present_students)
|
52 |
+
if st.button("Mark Attendance"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# Convert combined_students back to integers for record_attendance_new function
|
54 |
+
record_attendance_new(present_students_students_int, selected_course)
|
55 |
+
st.success("Attendance marked successfully")
|
56 |
+
|
57 |
+
st.download_button(
|
58 |
+
label="Download updated attendance file",
|
59 |
+
data=csv_contents,
|
60 |
+
file_name=csv_file_path,
|
61 |
+
mime='text/csv'
|
62 |
+
)
|
63 |
|
64 |
# Add to database
|
65 |
st.subheader("Add Student to Database")
|