ProfessorLeVesseur commited on
Commit
a1ba9de
·
verified ·
1 Parent(s): 707a69f

Update report.py

Browse files
Files changed (1) hide show
  1. report.py +3 -58
report.py CHANGED
@@ -1,58 +1,3 @@
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
- # import matplotlib.pyplot as plt
6
-
7
- # class ReportGenerator:
8
- # def __init__(self):
9
- # self.styles = getSampleStyleSheet()
10
-
11
- # def create_combined_pdf(self, intervention_fig, student_metrics_fig, recommendations):
12
- # buffer = io.BytesIO()
13
- # doc = SimpleDocTemplate(buffer, pagesize=letter)
14
-
15
- # elements = []
16
-
17
- # # Add the intervention statistics chart
18
- # elements.extend(self._add_chart(intervention_fig, "Intervention Statistics"))
19
-
20
- # # Add the student metrics chart
21
- # elements.extend(self._add_chart(student_metrics_fig, "Student Metrics"))
22
-
23
- # # Add the AI recommendations
24
- # elements.extend(self._add_recommendations(recommendations))
25
-
26
- # # Build the PDF
27
- # doc.build(elements)
28
- # buffer.seek(0)
29
- # return buffer
30
-
31
- # def _add_chart(self, fig, title):
32
- # elements = []
33
- # elements.append(Paragraph(title, self.styles['Heading2']))
34
- # img_buffer = io.BytesIO()
35
-
36
- # if hasattr(fig, 'write_image'): # Plotly figure
37
- # fig.write_image(img_buffer, format="png")
38
- # elif isinstance(fig, plt.Figure): # Matplotlib figure
39
- # fig.savefig(img_buffer, format='png')
40
- # plt.close(fig) # Close the figure to free up memory
41
- # else:
42
- # raise ValueError(f"Unsupported figure type: {type(fig)}")
43
-
44
- # img_buffer.seek(0)
45
- # elements.append(Image(img_buffer, width=500, height=300))
46
- # elements.append(Spacer(1, 12))
47
- # return elements
48
-
49
- # def _add_recommendations(self, recommendations):
50
- # elements = []
51
- # elements.append(Paragraph("AI Recommendations", self.styles['Heading1']))
52
- # elements.append(Paragraph(recommendations, self.styles['BodyText']))
53
- # return elements
54
-
55
-
56
  import io
57
  from reportlab.lib.pagesizes import letter
58
  from reportlab.platypus import SimpleDocTemplate, Image, Paragraph, Spacer
@@ -77,8 +22,8 @@ class ReportGenerator:
77
 
78
  elements = []
79
 
80
- elements.extend(self._add_chart(intervention_fig, "Intervention Statistics"))
81
- elements.extend(self._add_chart(student_metrics_fig, "Student Metrics"))
82
  elements.extend(self._add_recommendations(recommendations))
83
 
84
  doc.build(elements)
@@ -131,7 +76,7 @@ class ReportGenerator:
131
 
132
  def _add_recommendations(self, recommendations):
133
  elements = []
134
- elements.append(Paragraph("AI Recommendations", self.styles['Heading1']))
135
 
136
  # Convert markdown to HTML
137
  html = markdown.markdown(recommendations)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import io
2
  from reportlab.lib.pagesizes import letter
3
  from reportlab.platypus import SimpleDocTemplate, Image, Paragraph, Spacer
 
22
 
23
  elements = []
24
 
25
+ elements.extend(self._add_chart(intervention_fig, "Intervention Dosage"))
26
+ elements.extend(self._add_chart(student_metrics_fig, "Student Attendance and Engagement"))
27
  elements.extend(self._add_recommendations(recommendations))
28
 
29
  doc.build(elements)
 
76
 
77
  def _add_recommendations(self, recommendations):
78
  elements = []
79
+ elements.append(Paragraph("MTSS.ai Analysis", self.styles['Heading1']))
80
 
81
  # Convert markdown to HTML
82
  html = markdown.markdown(recommendations)