Spaces:
Running
Running
File size: 10,165 Bytes
a013fbc 841c63e a013fbc 6bddf8a 1a4bc5e a013fbc 1a4bc5e a013fbc 841c63e a013fbc 841c63e a013fbc |
1 2 3 4 5 6 7 8 9 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 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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# New Graysheet
import warnings
warnings.simplefilter('default', DeprecationWarning)
from fpdf import FPDF
import pandas as pd
import streamlit as st
from datetime import datetime
def generate_pdf(df):
num_students = df.shape[0]
page_body_list = []
for i in range(num_students):
if(df.at[i, 'Exam Status'] == "Approved"): # only generates for students who are approved
# get the data
studentName = df.at[i, 'Student']
course = df.at[i, 'Course']
date = df.at[i, 'Date']
loc = df.at[i, 'Exam_Location']
scheduled_start_time = df.at[i, 'Time_Start']
scheduled_end_time = df.at[i, 'Time_End']
# format data with labels
studentName = " ".join(["Student's Name:", studentName])
course = " ".join(["Course:", course])
date = " ".join(["Date:", date])
if loc == loc:
loc = " ".join(["Location:", loc])
else:
loc = "Location: __________________"
scheduled_start_time = " ".join(["Scheduled Start Time:", scheduled_start_time])
scheduled_end_time = " ".join(["Scheduled End Time:", scheduled_end_time])
# add additional text about exam conditions
exam_conditions = ("\nThis exam is proctored under the specified conditions and expectations set by your faculty and Student Access. "
"Subverting the testing conditions or violating the Honor Code by utilizing unauthorized forms of assistance during "
"this exam will result in Student Access stopping your exam and reporting the incident.")
# put grouped info together
student_info = "\n".join([studentName, course, date, loc])
scheduled_time = "\n".join([scheduled_start_time, scheduled_end_time])
student_info_and_scheduled_time = "\n".join([student_info, scheduled_time, exam_conditions])
notes = "Additional Information:\n____________________________________________________________________\n____________________________________________________________________\n____________________________________________________________________\n____________________________________________________________________"
actual_time = "\n".join(["Actual Start Time: _____________________________________________________",
"Estimated/Adjusted End Time: ___________________________________________",
"Actual End Time: ______________________________________________________"])
proctor = "Proctor Signature: _______________________ Date: _______________________"
student = "Student Signature: ______________________ Date: _______________________"
# construct the body of the pdf
body = "\n\n".join([student_info_and_scheduled_time, notes, actual_time, proctor, student])
# add this student's info to the list
page_body_list.append(body)
pdf = FPDF()
for i in range(len(page_body_list)):
pdf.add_page()
pdf.image("VandyStudentAccessLogo.png", 40, 10, w=120)
pdf.set_font('helvetica', 'B', size=16)
pdf.cell(w=210, h=9, txt="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
pdf.set_font('helvetica', 'B', size=16)
pdf.cell(w=210, h=9, txt="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
pdf.set_font('helvetica', 'B', size=8)
pdf.cell(w=210, h=9, txt="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
pdf.set_font('helvetica', 'B', size=14)
pdf.cell(w=210, h=9, txt="Exam Check-in Form", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
pdf.set_font('helvetica', 'B', size=10)
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,
new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
pdf.set_font('helvetica', 'B', size=10)
pdf.cell(w=210, h=9, txt="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
pdf.set_font('helvetica', size=13)
pdf.multi_cell(0, 7, page_body_list[i])
pdf.set_font('helvetica', 'B', size=10)
pdf.set_xy(145, 255)
pdf.cell(w=0, h=7, txt="# of Exam Pages _________")
pdf.set_xy(145, 260)
pdf.cell(w=0, h=7, txt="Cover Sheets +2")
pdf.set_xy(145, 265)
pdf.cell(w=0, h=7, txt="Notes, Notecards, etc. ____")
pdf.set_xy(170, 270)
pdf.cell(w=0, h=7, txt="Total ______")
pdf.output("/tmp/GraySheets.pdf")
return "/tmp/GraySheets.pdf"
def main():
st.title("Gray Sheet Generator")
# File upload
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
if uploaded_file is not None:
# Process the file
df = pd.read_csv(uploaded_file)
pdf_path = generate_pdf(df)
todays_date = datetime.now().strftime("%m_%d_%Y")
filename = f"GraySheets_{todays_date}.pdf"
# Download button
with open(pdf_path, "rb") as file:
btn = st.download_button(
label="Download Gray Sheet",
data=file,
file_name=filename,
mime="application/octet-stream"
)
if __name__ == "__main__":
main()
# Old GraySheet
# import warnings
# warnings.simplefilter('default', DeprecationWarning)
# from fpdf import FPDF
# import pandas as pd
# import streamlit as st
# from datetime import datetime
# def generate_pdf(df):
# num_students = df.shape[0]
# page_body_list = []
# for i in range(num_students):
# if(df.at[i, 'Exam Status'] == "Approved"): # only generates for students who are approved, not for those who are "processing" or "cancelled"
# # get the data
# studentName = df.at[i, 'Student']
# course = df.at[i, 'Course']
# date = df.at[i, 'Date']
# loc = df.at[i, 'Exam_Location']
# scheduled_start_time = df.at[i, 'Time_Start']
# scheduled_end_time = df.at[i, 'Time_End']
# # format data with labels
# studentName = " ".join(["Student's Name:", studentName])
# course = " ".join(["Course:", course])
# date = " ".join(["Date:", date])
# if loc == loc:
# loc = " ".join(["Location:", loc])
# else:
# loc = "Location: __________________"
# scheduled_start_time = " ".join(["Scheduled Start Time:", scheduled_start_time])
# scheduled_end_time = " ".join(["Scheduled End Time:", scheduled_end_time])
# # put grouped info together
# student_info = "\n".join([studentName, course, date, loc])
# scheduled_time = "\n".join([scheduled_start_time, scheduled_end_time])
# student_info_and_scheduled_time = "\n".join([student_info, scheduled_time])
# notes = "Additional Information:\n____________________________________________________________________\n____________________________________________________________________\n____________________________________________________________________\n____________________________________________________________________"
# actual_time = "\n\n\n".join(["Actual Start Time: _____________________________________________________", "Estimated/Adjusted End Time: ___________________________________________", "Actual End Time: ______________________________________________________"])
# proctor = "\n\nProctor's Signature: _______________________ Date: _______________________"
# # construct the body of the pdf
# body = "\n\n\n".join([student_info_and_scheduled_time, notes, actual_time, proctor])
# # add this student's info to the list
# page_body_list.append(body)
# pdf = FPDF()
# for i in range(len(page_body_list)):
# pdf.add_page()
# pdf.image("VandyStudentAccessLogo.png", 40, 10, w=120)
# pdf.set_font('helvetica', 'B', size=16)
# pdf.cell(w=210, h=9, text="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
# pdf.set_font('helvetica', 'B', size=16)
# pdf.cell(w=210, h=9, text="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
# pdf.set_font('helvetica', 'B', size=8)
# pdf.cell(w=210, h=9, text="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
# pdf.set_font('helvetica', 'B', size=14)
# pdf.cell(w=210, h=9, text="Exam Check-in Form", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
# pdf.set_font('helvetica', 'B', size=10)
# 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,
# new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
# pdf.set_font('helvetica', 'B', size=10)
# pdf.cell(w=210, h=9, text="\n", border=0, new_x="LMARGIN", new_y="NEXT", align='C', fill=False)
# pdf.set_font('helvetica', size=13)
# pdf.multi_cell(0, 7, page_body_list[i])
# pdf.set_font('helvetica', 'B', size=10)
# pdf.set_xy(145, 270)
# pdf.cell(w=0, h=5, text="# of Exam Pages: _____")
# pdf.output("/tmp/GraySheets.pdf")
# return "/tmp/GraySheets.pdf"
# def main():
# st.title("Gray Sheet Generator")
# # File upload
# uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
# if uploaded_file is not None:
# # Process the file
# df = pd.read_csv(uploaded_file)
# pdf_path = generate_pdf(df)
# todays_date = datetime.now().strftime("%m_%d_%Y")
# filename = f"GraySheets_{todays_date}.pdf"
# # Download button
# with open(pdf_path, "rb") as file:
# btn = st.download_button(
# label="Download Gray Sheet",
# data=file,
# file_name=filename,
# mime="application/octet-stream"
# )
# if __name__ == "__main__":
# main() |