Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -251,40 +251,46 @@ Click "Generate Report" to download your detailed results!""", True
|
|
| 251 |
)
|
| 252 |
|
| 253 |
# Header with candidate photo
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
(
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
story.append(Paragraph("CCC Plus - Computer Concepts Plus", title_style))
|
| 285 |
story.append(Paragraph("Quiz Assessment Report", subtitle_style))
|
| 286 |
-
|
| 287 |
-
|
|
|
|
| 288 |
story.append(Paragraph("CCC Plus - Computer Concepts Plus", title_style))
|
| 289 |
story.append(Paragraph("Quiz Assessment Report", subtitle_style))
|
| 290 |
|
|
@@ -601,32 +607,35 @@ def create_app():
|
|
| 601 |
border: 1px solid #e9ecef;
|
| 602 |
margin-top: 20px;
|
| 603 |
}
|
|
|
|
| 604 |
/* Logo */
|
| 605 |
-
#logo-img img {
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
}
|
| 610 |
"""
|
| 611 |
|
| 612 |
with gr.Blocks(title="CCC Plus Quiz App", css=custom_css, theme=gr.themes.Soft()) as app:
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
<
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
|
|
|
|
|
|
| 630 |
with gr.Row():
|
| 631 |
# Left Panel - Controls
|
| 632 |
with gr.Column(scale=1, elem_classes="control-panel"):
|
|
@@ -778,5 +787,4 @@ if __name__ == "__main__":
|
|
| 778 |
app.launch(share=True, show_error=True)
|
| 779 |
|
| 780 |
# For production use:
|
| 781 |
-
# exit(main())
|
| 782 |
-
|
|
|
|
| 251 |
)
|
| 252 |
|
| 253 |
# Header with candidate photo
|
| 254 |
+
try:
|
| 255 |
+
from reportlab.platypus import Image
|
| 256 |
+
header_data = []
|
| 257 |
+
|
| 258 |
+
if photo_path and os.path.exists(photo_path):
|
| 259 |
+
try:
|
| 260 |
+
# Create header table with photo
|
| 261 |
+
photo_img = Image(photo_path, width=60, height=60)
|
| 262 |
+
header_info = [
|
| 263 |
+
"CCC Plus - Computer Concepts Plus",
|
| 264 |
+
"Quiz Assessment Report",
|
| 265 |
+
f"Candidate: {self.user_name}",
|
| 266 |
+
datetime.now().strftime('%d %B %Y at %H:%M:%S')
|
| 267 |
+
]
|
| 268 |
+
|
| 269 |
+
header_table = Table([
|
| 270 |
+
[photo_img, Paragraph("<br/>".join(header_info), styles['Normal'])]
|
| 271 |
+
], colWidths=[80, 400])
|
| 272 |
+
|
| 273 |
+
header_table.setStyle(TableStyle([
|
| 274 |
+
('ALIGN', (0, 0), (0, 0), 'CENTER'),
|
| 275 |
+
('VALIGN', (0, 0), (-1, -1), 'TOP'),
|
| 276 |
+
('FONTSIZE', (1, 0), (1, 0), 12),
|
| 277 |
+
('BOTTOMPADDING', (0, 0), (-1, -1), 12),
|
| 278 |
+
]))
|
| 279 |
+
|
| 280 |
+
story.append(header_table)
|
| 281 |
+
|
| 282 |
+
except Exception as e:
|
| 283 |
+
logger.warning(f"Could not add photo to PDF: {e}")
|
| 284 |
+
# Fallback to text header
|
| 285 |
+
story.append(Paragraph("CCC Plus - Computer Concepts Plus", title_style))
|
| 286 |
+
story.append(Paragraph("Quiz Assessment Report", subtitle_style))
|
| 287 |
+
else:
|
| 288 |
+
# Text-only header
|
| 289 |
story.append(Paragraph("CCC Plus - Computer Concepts Plus", title_style))
|
| 290 |
story.append(Paragraph("Quiz Assessment Report", subtitle_style))
|
| 291 |
+
|
| 292 |
+
except ImportError:
|
| 293 |
+
# If reportlab Image is not available, use text header
|
| 294 |
story.append(Paragraph("CCC Plus - Computer Concepts Plus", title_style))
|
| 295 |
story.append(Paragraph("Quiz Assessment Report", subtitle_style))
|
| 296 |
|
|
|
|
| 607 |
border: 1px solid #e9ecef;
|
| 608 |
margin-top: 20px;
|
| 609 |
}
|
| 610 |
+
|
| 611 |
/* Logo */
|
| 612 |
+
#logo-img img {
|
| 613 |
+
max-height: 70px;
|
| 614 |
+
width: auto;
|
| 615 |
+
border-radius: 8px;
|
| 616 |
+
}
|
| 617 |
"""
|
| 618 |
|
| 619 |
with gr.Blocks(title="CCC Plus Quiz App", css=custom_css, theme=gr.themes.Soft()) as app:
|
| 620 |
+
with gr.Row(elem_classes="quiz-header"):
|
| 621 |
+
with gr.Column(scale=1):
|
| 622 |
+
# Check if logo exists before trying to load it
|
| 623 |
+
logo_path = "nielit_logo.png" if os.path.exists("nielit_logo.png") else None
|
| 624 |
+
logo_img = gr.Image(
|
| 625 |
+
value=logo_path,
|
| 626 |
+
elem_id="logo-img",
|
| 627 |
+
interactive=False,
|
| 628 |
+
show_label=False
|
| 629 |
+
)
|
| 630 |
+
with gr.Column(scale=6):
|
| 631 |
+
gr.HTML("""
|
| 632 |
+
<div class="quiz-header-text">
|
| 633 |
+
<h1>🖥️ CCC Plus Quiz App</h1>
|
| 634 |
+
<p>Computer Concepts Plus - Interactive Quiz Platform</p>
|
| 635 |
+
<p>NIELIT Chandigarh • National Institute of Electronics & Information Technology</p>
|
| 636 |
+
</div>
|
| 637 |
+
""")
|
| 638 |
+
|
| 639 |
with gr.Row():
|
| 640 |
# Left Panel - Controls
|
| 641 |
with gr.Column(scale=1, elem_classes="control-panel"):
|
|
|
|
| 787 |
app.launch(share=True, show_error=True)
|
| 788 |
|
| 789 |
# For production use:
|
| 790 |
+
# exit(main())
|
|
|