Update app.py
Browse files7 unmodified lines89101112131473 unmodified lines88899091929326 unmodified lines1201211221231241251261271286 unmodified lines1351361371381391401417 unmodified linesCOMPLETED_GRADES = {"GM", "RI", "RU", "RG", "RB", "RU+", "R1", "R2", "R3", "S"}PROGRESS_GRADE = "MP"def process_files(course_files, crn_file):# Validate files existif not course_files or not crn_file:return None, "Please upload both course roster files and a CRN mapping file."73 unmodified linesboth_types = "Y" if data["progress"] and data["completed"] else ""summary.append({"Name": full_name,"Progress Courses": progress,"Completed Courses": completed,"Both_Types": both_types26 unmodified linesworksheet.row_dimensions[idx + 2].height = max(15 * max_lines, 15) # +2 because of header and 1-based indexing# Enable text wrapping for these columnsfor col_idx in [2, 3]: # Columns B and C (0-indexed would be 1 and 2)for cell in worksheet[chr(65 + col_idx)]:cell.alignment = cell.alignment.copy(wrapText=True)# Return the path to the temporary filereturn temp_file.name, "Summary generated successfully!"6 unmodified linesfn=process_files,inputs=[gr.Files(label="Upload ALL Course Roster Files (.xlsx)", file_count="multiple"),gr.File(label="Upload CRN-to-Course Mapping File (.xlsx)")],outputs=[gr.File(label="Download Student Summary Excel", file_types=[".xlsx"]),7 unmodified lines89101112131473 unmodified lines8889909192939426 unmodified lines1211221231241251261271281291301311321331341351361371381391401411426 unmodified lines1491501511521531541551567 unmodified linesCOMPLETED_GRADES = {"GM", "RI", "RU", "RG", "RB", "RU+", "R1", "R2", "R3", "S"}PROGRESS_GRADE = "MP"def process_files(course_files, crn_file, session_name):# Validate files existif not course_files or not crn_file:return None, "Please upload both course roster files and a CRN mapping file."73 unmodified linesboth_types = "Y" if data["progress"] and data["completed"] else ""summary.append({"Name": full_name,"Session": session_name, # Add the session name here"Progress Courses": progress,"Completed Courses": completed,"Both_Types": both_types26 unmodified linesworksheet.row_dimensions[idx + 2].height = max(15 * max_lines, 15) # +2 because of header and 1-based indexing# Enable text wrapping for these columnsfor col_idx in [2, 3]: # Columns C and D (0-indexed would be 2 and 3)for cell in worksheet[chr(65 + col_idx)]:cell.alignment = cell.alignment.copy(wrapText=True)# Auto-adjust column widthsfor column in worksheet.columns:max_length = 0column_letter = column[0].column_letterfor cell in column:try:if len(str(cell.value)) > max_length:max_length = len(str(cell.value))except:passadjusted_width = (max_length + 2)worksheet.column_dimensions[column_letter].width = min(adjusted_width, 50) # Cap width at 50# Return the path to the temporary filereturn temp_file.name, "Summary generated successfully!"6 unmodified linesfn=process_files,inputs=[gr.Files(label="Upload ALL Course Roster Files (.xlsx)", file_count="multiple"),gr.File(label="Upload CRN-to-Course Mapping File (.xlsx)"),gr.Textbox(label="Session (e.g., Fall 1, Spring 2)", placeholder="Enter session name")],outputs=[gr.File(label="Download Student Summary Excel", file_types=[".xlsx"]),
app.py+18-3