Spaces:
Running
Running
update
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import warnings
|
2 |
warnings.simplefilter('default', DeprecationWarning)
|
3 |
|
@@ -7,99 +8,219 @@ import streamlit as st
|
|
7 |
from datetime import datetime
|
8 |
|
9 |
def generate_pdf(df):
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
pdf
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
def main():
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
|
104 |
if __name__ == "__main__":
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# New Graysheet
|
2 |
import warnings
|
3 |
warnings.simplefilter('default', DeprecationWarning)
|
4 |
|
|
|
8 |
from datetime import datetime
|
9 |
|
10 |
def generate_pdf(df):
|
11 |
+
num_students = df.shape[0]
|
12 |
+
page_body_list = []
|
13 |
+
for i in range(num_students):
|
14 |
+
if(df.at[i, 'Exam Status'] == "Approved"): # only generates for students who are approved
|
15 |
+
# get the data
|
16 |
+
studentName = df.at[i, 'Student']
|
17 |
+
course = df.at[i, 'Course']
|
18 |
+
date = df.at[i, 'Date']
|
19 |
+
loc = df.at[i, 'Exam_Location']
|
20 |
+
scheduled_start_time = df.at[i, 'Time_Start']
|
21 |
+
scheduled_end_time = df.at[i, 'Time_End']
|
22 |
+
|
23 |
+
# format data with labels
|
24 |
+
studentName = " ".join(["Student's Name:", studentName])
|
25 |
+
course = " ".join(["Course:", course])
|
26 |
+
date = " ".join(["Date:", date])
|
27 |
+
if loc == loc:
|
28 |
+
loc = " ".join(["Location:", loc])
|
29 |
+
else:
|
30 |
+
loc = "Location: __________________"
|
31 |
+
scheduled_start_time = " ".join(["Scheduled Start Time:", scheduled_start_time])
|
32 |
+
scheduled_end_time = " ".join(["Scheduled End Time:", scheduled_end_time])
|
33 |
+
|
34 |
+
# add additional text about exam conditions
|
35 |
+
exam_conditions = ("\nThis exam is proctored under the specified conditions and expectations set by your faculty and Student Access. "
|
36 |
+
"Subverting the testing conditions or violating the Honor Code by utilizing unauthorized forms of assistance during "
|
37 |
+
"this exam will result in Student Access stopping your exam and reporting the incident.")
|
38 |
+
|
39 |
+
# put grouped info together
|
40 |
+
student_info = "\n".join([studentName, course, date, loc])
|
41 |
+
scheduled_time = "\n".join([scheduled_start_time, scheduled_end_time])
|
42 |
+
student_info_and_scheduled_time = "\n".join([student_info, scheduled_time, exam_conditions])
|
43 |
+
notes = "Additional Information:\n____________________________________________________________________\n____________________________________________________________________\n____________________________________________________________________\n____________________________________________________________________"
|
44 |
+
actual_time = "\n".join(["Actual Start Time: _____________________________________________________",
|
45 |
+
"Estimated/Adjusted End Time: ___________________________________________",
|
46 |
+
"Actual End Time: ______________________________________________________"])
|
47 |
+
proctor = "Proctor's Signature: _______________________ Date: _______________________"
|
48 |
+
|
49 |
+
# construct the body of the pdf
|
50 |
+
body = "\n\n".join([student_info_and_scheduled_time, notes, actual_time, proctor])
|
51 |
+
|
52 |
+
# add this student's info to the list
|
53 |
+
page_body_list.append(body)
|
54 |
+
|
55 |
+
pdf = FPDF()
|
56 |
+
for i in range(len(page_body_list)):
|
57 |
+
pdf.add_page()
|
58 |
+
|
59 |
+
pdf.image("VandyStudentAccessLogo.png", 40, 10, w=120)
|
60 |
+
|
61 |
+
pdf.set_font('helvetica', 'B', size=16)
|
62 |
+
pdf.cell(w=210, h=9, txt="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
63 |
+
|
64 |
+
pdf.set_font('helvetica', 'B', size=16)
|
65 |
+
pdf.cell(w=210, h=9, txt="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
66 |
+
|
67 |
+
pdf.set_font('helvetica', 'B', size=8)
|
68 |
+
pdf.cell(w=210, h=9, txt="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
69 |
+
|
70 |
+
pdf.set_font('helvetica', 'B', size=14)
|
71 |
+
pdf.cell(w=210, h=9, txt="Exam Check-in Form", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
72 |
+
|
73 |
+
pdf.set_font('helvetica', 'B', size=10)
|
74 |
+
pdf.multi_cell(w=0, h=7, txt="This form is to be completed by the proctor. The student must return this \nform along with their reminder ticket and all exam materials.\n", border=0,
|
75 |
+
new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
76 |
+
|
77 |
+
pdf.set_font('helvetica', 'B', size=10)
|
78 |
+
pdf.cell(w=210, h=9, txt="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
79 |
+
|
80 |
+
pdf.set_font('helvetica', size=13)
|
81 |
+
pdf.multi_cell(0, 7, page_body_list[i])
|
82 |
+
|
83 |
+
pdf.set_font('helvetica', 'B', size=10)
|
84 |
+
pdf.set_xy(145, 255)
|
85 |
+
pdf.cell(w=0, h=7, txt="# of Exam Pages _________")
|
86 |
+
pdf.set_xy(145, 260)
|
87 |
+
pdf.cell(w=0, h=7, txt="Cover Sheets +2")
|
88 |
+
pdf.set_xy(145, 265)
|
89 |
+
pdf.cell(w=0, h=7, txt="Notes, Notecards, etc. ____")
|
90 |
+
pdf.set_xy(170, 270)
|
91 |
+
pdf.cell(w=0, h=7, txt="Total ______")
|
92 |
+
|
93 |
+
pdf.output("/tmp/GraySheets.pdf")
|
94 |
+
return "/tmp/GraySheets.pdf"
|
95 |
|
96 |
def main():
|
97 |
+
st.title("Gray Sheet Generator")
|
98 |
+
|
99 |
+
# File upload
|
100 |
+
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
101 |
+
if uploaded_file is not None:
|
102 |
+
# Process the file
|
103 |
+
df = pd.read_csv(uploaded_file)
|
104 |
+
pdf_path = generate_pdf(df)
|
105 |
+
todays_date = datetime.now().strftime("%m_%d_%Y")
|
106 |
+
filename = f"GraySheets_{todays_date}.pdf"
|
107 |
+
|
108 |
+
# Download button
|
109 |
+
with open(pdf_path, "rb") as file:
|
110 |
+
btn = st.download_button(
|
111 |
+
label="Download Gray Sheet",
|
112 |
+
data=file,
|
113 |
+
file_name=filename,
|
114 |
+
mime="application/octet-stream"
|
115 |
+
)
|
|
|
116 |
|
117 |
if __name__ == "__main__":
|
118 |
+
main()
|
119 |
+
|
120 |
+
|
121 |
+
# Old GraySheet
|
122 |
+
# import warnings
|
123 |
+
# warnings.simplefilter('default', DeprecationWarning)
|
124 |
+
|
125 |
+
# from fpdf import FPDF
|
126 |
+
# import pandas as pd
|
127 |
+
# import streamlit as st
|
128 |
+
# from datetime import datetime
|
129 |
+
|
130 |
+
# def generate_pdf(df):
|
131 |
+
# num_students = df.shape[0]
|
132 |
+
# page_body_list = []
|
133 |
+
# for i in range(num_students):
|
134 |
+
# if(df.at[i, 'Exam Status'] == "Approved"): # only generates for students who are approved, not for those who are "processing" or "cancelled"
|
135 |
+
# # get the data
|
136 |
+
# studentName = df.at[i, 'Student']
|
137 |
+
# course = df.at[i, 'Course']
|
138 |
+
# date = df.at[i, 'Date']
|
139 |
+
# loc = df.at[i, 'Exam_Location']
|
140 |
+
# scheduled_start_time = df.at[i, 'Time_Start']
|
141 |
+
# scheduled_end_time = df.at[i, 'Time_End']
|
142 |
+
|
143 |
+
# # format data with labels
|
144 |
+
# studentName = " ".join(["Student's Name:", studentName])
|
145 |
+
# course = " ".join(["Course:", course])
|
146 |
+
# date = " ".join(["Date:", date])
|
147 |
+
# if loc == loc:
|
148 |
+
# loc = " ".join(["Location:", loc])
|
149 |
+
# else:
|
150 |
+
# loc = "Location: __________________"
|
151 |
+
# scheduled_start_time = " ".join(["Scheduled Start Time:", scheduled_start_time])
|
152 |
+
# scheduled_end_time = " ".join(["Scheduled End Time:", scheduled_end_time])
|
153 |
+
|
154 |
+
# # put grouped info together
|
155 |
+
# student_info = "\n".join([studentName, course, date, loc])
|
156 |
+
# scheduled_time = "\n".join([scheduled_start_time, scheduled_end_time])
|
157 |
+
# student_info_and_scheduled_time = "\n".join([student_info, scheduled_time])
|
158 |
+
# notes = "Additional Information:\n____________________________________________________________________\n____________________________________________________________________\n____________________________________________________________________\n____________________________________________________________________"
|
159 |
+
# actual_time = "\n\n\n".join(["Actual Start Time: _____________________________________________________", "Estimated/Adjusted End Time: ___________________________________________", "Actual End Time: ______________________________________________________"])
|
160 |
+
# proctor = "\n\nProctor's Signature: _______________________ Date: _______________________"
|
161 |
+
|
162 |
+
# # construct the body of the pdf
|
163 |
+
# body = "\n\n\n".join([student_info_and_scheduled_time, notes, actual_time, proctor])
|
164 |
+
|
165 |
+
# # add this student's info to the list
|
166 |
+
# page_body_list.append(body)
|
167 |
+
|
168 |
+
# pdf = FPDF()
|
169 |
+
# for i in range(len(page_body_list)):
|
170 |
+
# pdf.add_page()
|
171 |
+
|
172 |
+
# pdf.image("VandyStudentAccessLogo.png", 40, 10, w=120)
|
173 |
+
|
174 |
+
# pdf.set_font('helvetica', 'B', size=16)
|
175 |
+
# pdf.cell(w=210, h=9, text="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
176 |
+
|
177 |
+
# pdf.set_font('helvetica', 'B', size=16)
|
178 |
+
# pdf.cell(w=210, h=9, text="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
179 |
+
|
180 |
+
# pdf.set_font('helvetica', 'B', size=8)
|
181 |
+
# pdf.cell(w=210, h=9, text="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
182 |
+
|
183 |
+
# pdf.set_font('helvetica', 'B', size=14)
|
184 |
+
# pdf.cell(w=210, h=9, text="Exam Check-in Form", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
185 |
+
|
186 |
+
# pdf.set_font('helvetica', 'B', size=10)
|
187 |
+
# pdf.multi_cell(w=0, h=7, text="This form is to be completed by the proctor. The student must return this \nform along with their seat ticket and all exam materials.\n", border=0,
|
188 |
+
# new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
189 |
+
|
190 |
+
# pdf.set_font('helvetica', 'B', size=10)
|
191 |
+
# pdf.cell(w=210, h=9, text="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
|
192 |
+
|
193 |
+
# pdf.set_font('helvetica', size=13)
|
194 |
+
# pdf.multi_cell(0, 7, page_body_list[i])
|
195 |
+
|
196 |
+
# pdf.set_font('helvetica', 'B', size=10)
|
197 |
+
# pdf.set_xy(145, 270)
|
198 |
+
# pdf.cell(w=0, h=5, text="# of Exam Pages: _____")
|
199 |
+
|
200 |
+
# pdf.output("/tmp/GraySheets.pdf")
|
201 |
+
# return "/tmp/GraySheets.pdf"
|
202 |
+
|
203 |
+
# def main():
|
204 |
+
# st.title("Gray Sheet Generator")
|
205 |
+
|
206 |
+
# # File upload
|
207 |
+
# uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
208 |
+
# if uploaded_file is not None:
|
209 |
+
# # Process the file
|
210 |
+
# df = pd.read_csv(uploaded_file)
|
211 |
+
# pdf_path = generate_pdf(df)
|
212 |
+
# todays_date = datetime.now().strftime("%m_%d_%Y")
|
213 |
+
# filename = f"GraySheets_{todays_date}.pdf"
|
214 |
+
|
215 |
+
# # Download button
|
216 |
+
# with open(pdf_path, "rb") as file:
|
217 |
+
# btn = st.download_button(
|
218 |
+
# label="Download Gray Sheet",
|
219 |
+
# data=file,
|
220 |
+
# file_name=filename,
|
221 |
+
# mime="application/octet-stream"
|
222 |
+
# )
|
223 |
+
|
224 |
+
|
225 |
+
# if __name__ == "__main__":
|
226 |
+
# main()
|