Jekyll2000 commited on
Commit
5cabe17
·
verified ·
1 Parent(s): df0afa1

Create utils/report_generator.py

Browse files
Files changed (1) hide show
  1. utils/report_generator.py +47 -0
utils/report_generator.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fpdf import FPDF
2
+ from datetime import datetime
3
+
4
+ def generate_report(job_role, cv_summary, answers, final_evaluation):
5
+ pdf = FPDF()
6
+ pdf.add_page()
7
+
8
+ # Set font and title
9
+ pdf.set_font("Arial", 'B', 16)
10
+ pdf.cell(0, 10, f"Interview Report for {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_similarity']*100:.1f}%")
18
+ pdf.ln(5)
19
+
20
+ # Interview Results
21
+ pdf.set_font("Arial", 'B', 12)
22
+ pdf.cell(0, 10, "Interview Results:", 0, 1)
23
+ pdf.set_font("Arial", '', 10)
24
+ pdf.cell(0, 7, f"Overall Score: {final_evaluation['score']}/10", 0, 1)
25
+ pdf.cell(0, 7, f"Band: {final_evaluation['band']}", 0, 1)
26
+ pdf.ln(5)
27
+
28
+ # Detailed Feedback
29
+ pdf.set_font("Arial", 'B', 12)
30
+ pdf.cell(0, 10, "Question-by-Question Feedback:", 0, 1)
31
+ pdf.set_font("Arial", '', 10)
32
+
33
+ for i, answer in enumerate(answers):
34
+ pdf.set_fill_color(200, 220, 255)
35
+ pdf.cell(0, 7, f"Question {i+1}: {answer['question']['text']}", 0, 1, fill=True)
36
+ pdf.cell(0, 7, f"Your Answer: {answer['answer']}", 0, 1)
37
+ pdf.cell(0, 7, f"Score: {answer['evaluation']['score']}/10", 0, 1)
38
+ pdf.multi_cell(0, 7, f"Feedback: {answer['evaluation']['feedback']}")
39
+ pdf.ln(3)
40
+
41
+ # Save the report
42
+ os.makedirs("data/interviews", exist_ok=True)
43
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
44
+ report_path = f"data/interviews/report_{timestamp}.pdf"
45
+ pdf.output(report_path)
46
+
47
+ return report_path