ProfessorLeVesseur commited on
Commit
6140c9f
·
verified ·
1 Parent(s): 4b1abd0

Create Report.py

Browse files
Files changed (1) hide show
  1. Report.py +35 -0
Report.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ from reportlab.lib.pagesizes import letter
3
+ from reportlab.platypus import SimpleDocTemplate, Image, Paragraph, Spacer
4
+ from reportlab.lib.styles import getSampleStyleSheet
5
+
6
+ def create_combined_pdf(intervention_fig, student_metrics_fig, recommendations):
7
+ buffer = io.BytesIO()
8
+ doc = SimpleDocTemplate(buffer, pagesize=letter)
9
+ styles = getSampleStyleSheet()
10
+
11
+ # Create a list to hold the PDF elements
12
+ elements = []
13
+
14
+ # Add the intervention statistics chart
15
+ img_buffer = io.BytesIO()
16
+ intervention_fig.write_image(img_buffer, format="png")
17
+ img_buffer.seek(0)
18
+ elements.append(Image(img_buffer, width=500, height=300))
19
+ elements.append(Spacer(1, 12))
20
+
21
+ # Add the student metrics chart
22
+ img_buffer = io.BytesIO()
23
+ student_metrics_fig.write_image(img_buffer, format="png")
24
+ img_buffer.seek(0)
25
+ elements.append(Image(img_buffer, width=500, height=300))
26
+ elements.append(Spacer(1, 12))
27
+
28
+ # Add the AI recommendations
29
+ elements.append(Paragraph("AI Recommendations", styles['Heading1']))
30
+ elements.append(Paragraph(recommendations, styles['BodyText']))
31
+
32
+ # Build the PDF
33
+ doc.build(elements)
34
+ buffer.seek(0)
35
+ return buffer