Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions FusionIIIT/applications/examination/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3537,15 +3537,18 @@ def post(self, request):
story.append(Spacer(1, 12))

# Student Information Table
# Wrap long names in Paragraph to enable word wrapping
student_name = student_info.get('name', 'N/A')
if len(student_name) > 25: # If name is too long, wrap it
student_name = Paragraph(student_name, ParagraphStyle('NameStyle', parent=styles['Normal'], fontSize=10, fontName='Times-Roman'))

cell_style = ParagraphStyle(
'CellStyle',
parent=styles['Normal'],
fontSize=10,
fontName='Times-Roman',
wordWrap='CJK'
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wordWrap parameter is not a standard parameter for ReportLab's ParagraphStyle class. ReportLab's Paragraph class automatically handles word wrapping based on the available width without needing a wordWrap parameter in the style definition. This parameter will likely be ignored, but could cause confusion or issues if the library behavior changes.

Consider removing this line as word wrapping is automatically handled by the Paragraph class when it's constrained by the table column width.

Suggested change
wordWrap='CJK'

Copilot uses AI. Check for mistakes.
)

student_data = [
['Name of Student:', student_name, 'Roll No.:', student_info.get('rollNumber', student_info.get('roll_number', 'N/A'))],
['Programme:', student_info.get('programme', 'N/A'), 'Branch:', student_info.get('branch', student_info.get('department', 'N/A'))],
['Semester:', formatted_semester, 'Academic Year:', student_info.get('academicYear', student_info.get('academic_year', 'N/A'))]
[Paragraph('Name of Student:', cell_style), Paragraph(student_info.get('name', 'N/A'), cell_style), Paragraph('Roll No.:', cell_style), Paragraph(student_info.get('rollNumber', student_info.get('roll_number', 'N/A')), cell_style)],
[Paragraph('Programme:', cell_style), Paragraph(student_info.get('programme', 'N/A'), cell_style), Paragraph('Branch:', cell_style), Paragraph(student_info.get('branch', student_info.get('department', 'N/A')), cell_style)],
[Paragraph('Semester:', cell_style), Paragraph(formatted_semester, cell_style), Paragraph('Academic Year:', cell_style), Paragraph(student_info.get('academicYear', student_info.get('academic_year', 'N/A')), cell_style)]
Comment on lines +3549 to +3551
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are excessively long (over 200 characters each) and significantly impact code readability. Consider breaking them into multiple lines by extracting the Paragraph creation into variables or using temporary variables for the dictionary .get() calls.

Example refactoring for line 3549:

student_name = Paragraph(student_info.get('name', 'N/A'), cell_style)
roll_number = Paragraph(student_info.get('rollNumber', student_info.get('roll_number', 'N/A')), cell_style)
student_data = [
    [Paragraph('Name of Student:', cell_style), student_name, Paragraph('Roll No.:', cell_style), roll_number],
    # ... remaining rows
]

Copilot uses AI. Check for mistakes.
]

student_table = Table(student_data, colWidths=[1.75*inch, 1.75*inch, 1.75*inch, 1.75*inch])
Expand Down