Jekyll2000 commited on
Commit
858e0f8
·
verified ·
1 Parent(s): 6c961d1

Create utils/report_generator.py

Browse files
Files changed (1) hide show
  1. utils/report_generator.py +39 -0
utils/report_generator.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fpdf import FPDF
2
+ from datetime import datetime
3
+
4
+ def generate_report(job_role, cv_summary, answers, evaluation):
5
+ pdf = FPDF()
6
+ pdf.add_page()
7
+
8
+ # Header
9
+ pdf.set_font("Arial", 'B', 16)
10
+ pdf.cell(0, 10, f"Interview Report - {job_role}", 0, 1, 'C')
11
+ pdf.ln(10)
12
+
13
+ # Candidate Summary
14
+ pdf.set_font("Arial", 'B', 12)
15
+ pdf.cell(0, 10, "Candidate Summary:", 0, 1)
16
+ pdf.set_font("Arial", '', 10)
17
+ pdf.multi_cell(0, 7, f"Experience: {cv_summary['experience']} years\nSkills Match: {cv_summary['skills_match']:.1%}")
18
+
19
+ # Results
20
+ pdf.ln(5)
21
+ pdf.set_font("Arial", 'B', 12)
22
+ pdf.cell(0, 10, f"Overall Score: {evaluation['score']}/10 ({evaluation['band']})", 0, 1)
23
+
24
+ # Questions
25
+ pdf.set_font("Arial", 'B', 12)
26
+ pdf.cell(0, 10, "Question Details:", 0, 1)
27
+ pdf.set_font("Arial", '', 10)
28
+
29
+ for i, ans in enumerate(answers):
30
+ pdf.cell(0, 7, f"Q{i+1}: {ans['question']['text']}", 0, 1)
31
+ pdf.multi_cell(0, 7, f"Answer: {ans['answer']}")
32
+ pdf.multi_cell(0, 7, f"Feedback: {ans['evaluation']['feedback']} (Score: {ans['evaluation']['score']}/10)")
33
+ pdf.ln(3)
34
+
35
+ # Save
36
+ os.makedirs("data/interviews", exist_ok=True)
37
+ path = f"data/interviews/report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf"
38
+ pdf.output(path)
39
+ return path