File size: 1,339 Bytes
858e0f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from fpdf import FPDF
from datetime import datetime

def generate_report(job_role, cv_summary, answers, evaluation):
    pdf = FPDF()
    pdf.add_page()
    
    # Header
    pdf.set_font("Arial", 'B', 16)
    pdf.cell(0, 10, f"Interview Report - {job_role}", 0, 1, 'C')
    pdf.ln(10)
    
    # Candidate Summary
    pdf.set_font("Arial", 'B', 12)
    pdf.cell(0, 10, "Candidate Summary:", 0, 1)
    pdf.set_font("Arial", '', 10)
    pdf.multi_cell(0, 7, f"Experience: {cv_summary['experience']} years\nSkills Match: {cv_summary['skills_match']:.1%}")
    
    # Results
    pdf.ln(5)
    pdf.set_font("Arial", 'B', 12)
    pdf.cell(0, 10, f"Overall Score: {evaluation['score']}/10 ({evaluation['band']})", 0, 1)
    
    # Questions
    pdf.set_font("Arial", 'B', 12)
    pdf.cell(0, 10, "Question Details:", 0, 1)
    pdf.set_font("Arial", '', 10)
    
    for i, ans in enumerate(answers):
        pdf.cell(0, 7, f"Q{i+1}: {ans['question']['text']}", 0, 1)
        pdf.multi_cell(0, 7, f"Answer: {ans['answer']}")
        pdf.multi_cell(0, 7, f"Feedback: {ans['evaluation']['feedback']} (Score: {ans['evaluation']['score']}/10)")
        pdf.ln(3)
    
    # Save
    os.makedirs("data/interviews", exist_ok=True)
    path = f"data/interviews/report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf"
    pdf.output(path)
    return path