dschandra commited on
Commit
7709e14
·
verified ·
1 Parent(s): 6a086d3

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +41 -0
utils.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # utils.py
2
+ import matplotlib.pyplot as plt
3
+ import uuid
4
+ import os
5
+
6
+ def plot_engagement_graph(score):
7
+ days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
8
+ values = [randomize(score) for _ in days]
9
+
10
+ plt.figure(figsize=(5, 3))
11
+ plt.plot(days, values, marker='o')
12
+ plt.title("Engagement Score Trend")
13
+ plt.ylim(50, 100)
14
+ plt.xlabel("Day")
15
+ plt.ylabel("Score")
16
+
17
+ path = f"engagement_{uuid.uuid4().hex}.png"
18
+ plt.savefig(path)
19
+ plt.close()
20
+ return path
21
+
22
+ def randomize(base):
23
+ import random
24
+ return round(base + random.uniform(-5, 5), 2)
25
+
26
+ def generate_pdf_summary(role, project_id):
27
+ from fpdf import FPDF
28
+ file_path = f"summary_{uuid.uuid4().hex}.pdf"
29
+
30
+ pdf = FPDF()
31
+ pdf.add_page()
32
+ pdf.set_font("Arial", size=12)
33
+ pdf.cell(200, 10, txt="Weekly Summary Report", ln=True, align="C")
34
+ pdf.ln(10)
35
+ pdf.cell(200, 10, txt=f"Supervisor Role: {role}", ln=True)
36
+ pdf.cell(200, 10, txt=f"Project ID: {project_id}", ln=True)
37
+ pdf.ln(10)
38
+ pdf.multi_cell(0, 10, txt="Engagement and coaching logs for the week will appear here.")
39
+
40
+ pdf.output(file_path)
41
+ return file_path