Update app.py
Browse files7 unmodified lines8910111112131473 unmodified lines8889909192939426 unmodified lines1211221231231241251261271281291301311321331341351361371381391401411426 unmodified lines1491501511381521531541551567 unmodified linesCOMPLETED_GRADES = {"GM", "RI", "RU", "RG", "RB", "RU+", "R1", "R2", "R3", "S"}PROGRESS_GRADE = "MP"
def process_files(course_files, crn_file):def process_files(course_files, crn_file, session_name): # Validate files exist if not course_files or not crn_file: return None, "Please upload both course roster files and a CRN mapping file."73 unmodified lines both_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 lines worksheet.row_dimensions[idx + 2].height = max(15 * max_lines, 15) # +2 because of header and 1-based indexing # Enable text wrapping for these columns for col_idx in [2, 3]: # Columns B and C (0-indexed would be 1 and 2) for 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 widths for column in worksheet.columns: max_length = 0 column_letter = column[0].column_letter for cell in column: try: if len(str(cell.value)) > max_length: max_length = len(str(cell.value)) except: pass adjusted_width = (max_length + 2) worksheet.column_dimensions[column_letter].width = min(adjusted_width, 50) # Cap width at 50 # Return the path to the temporary file return temp_file.name, "Summary generated successfully!"6 unmodified lines fn=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.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