pk75 commited on
Commit
f441e49
·
verified ·
1 Parent(s): 4fb2f1b

Update modules/report_generator.py

Browse files
Files changed (1) hide show
  1. modules/report_generator.py +6 -7
modules/report_generator.py CHANGED
@@ -1,17 +1,20 @@
1
  # modules/report_generator.py
 
2
  import datetime
3
  import os
4
  import numpy as np
5
  import matplotlib.pyplot as plt
6
  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak, Image, Frame, PageTemplate
7
  from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
8
- from reportlab.lib.enums import TA_JUSTIFY, TA_CENTER
 
9
  from reportlab.lib.units import inch
10
  from reportlab.lib import colors
11
  from modules.llm_handler import generate_holistic_feedback, parse_scores_from_evaluation
12
  import config
13
 
14
- # This class is unchanged
 
15
  class ReportPageTemplate(PageTemplate):
16
  def __init__(self, id, pagesize):
17
  frame = Frame(inch, inch, pagesize[0] - 2 * inch, pagesize[1] - 2 * inch, id='normal')
@@ -25,7 +28,6 @@ class ReportPageTemplate(PageTemplate):
25
  canvas.drawCentredString(doc.width / 2 + inch, 0.75 * inch, footer_text)
26
  canvas.restoreState()
27
 
28
- # This function is unchanged
29
  def create_radar_chart(labels, scores, file_path):
30
  num_vars = len(labels)
31
  angles = np.linspace(0, 2 * np.pi, num_vars, endpoint=False).tolist()
@@ -49,6 +51,7 @@ def generate_pdf_report(interview_data, file_path):
49
  doc.addPageTemplates([ReportPageTemplate('main_template', (8.5 * inch, 11 * inch))])
50
 
51
  styles = getSampleStyleSheet()
 
52
  styles.add(ParagraphStyle(name='ReportTitle', parent=styles['h1'], fontSize=28, alignment=TA_CENTER, spaceAfter=24))
53
  styles.add(ParagraphStyle(name='ReportSubTitle', parent=styles['h2'], fontSize=16, alignment=TA_CENTER, spaceAfter=12, textColor=colors.HexColor('#555555')))
54
  styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY, spaceAfter=12, leading=14))
@@ -58,8 +61,6 @@ def generate_pdf_report(interview_data, file_path):
58
 
59
  story = []
60
 
61
- # --- 1. The Title Page ---
62
- # This section now safely gets the data it needs.
63
  story.append(Paragraph("Interview Performance Report", styles['ReportTitle']))
64
  story.append(Spacer(1, 0.5 * inch))
65
  story.append(Paragraph(f"Prepared for: <b>{interview_data.get('name', 'N/A')}</b>", styles['ReportSubTitle']))
@@ -69,7 +70,6 @@ def generate_pdf_report(interview_data, file_path):
69
  story.append(Paragraph(f"Date of Report: <b>{datetime.datetime.now().strftime('%B %d, %Y')}</b>", styles['ReportSubTitle']))
70
  story.append(PageBreak())
71
 
72
- # --- 2. Overall Performance & Graph Section ---
73
  story.append(Paragraph("Overall Performance Analysis", styles['MainHeader']))
74
  full_log_text = ""
75
  all_scores = []
@@ -90,7 +90,6 @@ def generate_pdf_report(interview_data, file_path):
90
  story.append(Image(chart_path, width=4.5*inch, height=4.5*inch, hAlign='CENTER'))
91
  story.append(PageBreak())
92
 
93
- # --- 3. Detailed Question-by-Question Analysis ---
94
  story.append(Paragraph("Detailed Question Analysis", styles['MainHeader']))
95
  for i, qa in enumerate(interview_data['q_and_a']):
96
  story.append(Paragraph(f"Question {i+1}: {qa['question']}", styles['QuestionTitle']))
 
1
  # modules/report_generator.py
2
+
3
  import datetime
4
  import os
5
  import numpy as np
6
  import matplotlib.pyplot as plt
7
  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak, Image, Frame, PageTemplate
8
  from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
9
+ # --- THIS IS THE FIX: Import TA_LEFT ---
10
+ from reportlab.lib.enums import TA_JUSTIFY, TA_CENTER, TA_LEFT
11
  from reportlab.lib.units import inch
12
  from reportlab.lib import colors
13
  from modules.llm_handler import generate_holistic_feedback, parse_scores_from_evaluation
14
  import config
15
 
16
+ # The rest of the file remains the same...
17
+
18
  class ReportPageTemplate(PageTemplate):
19
  def __init__(self, id, pagesize):
20
  frame = Frame(inch, inch, pagesize[0] - 2 * inch, pagesize[1] - 2 * inch, id='normal')
 
28
  canvas.drawCentredString(doc.width / 2 + inch, 0.75 * inch, footer_text)
29
  canvas.restoreState()
30
 
 
31
  def create_radar_chart(labels, scores, file_path):
32
  num_vars = len(labels)
33
  angles = np.linspace(0, 2 * np.pi, num_vars, endpoint=False).tolist()
 
51
  doc.addPageTemplates([ReportPageTemplate('main_template', (8.5 * inch, 11 * inch))])
52
 
53
  styles = getSampleStyleSheet()
54
+
55
  styles.add(ParagraphStyle(name='ReportTitle', parent=styles['h1'], fontSize=28, alignment=TA_CENTER, spaceAfter=24))
56
  styles.add(ParagraphStyle(name='ReportSubTitle', parent=styles['h2'], fontSize=16, alignment=TA_CENTER, spaceAfter=12, textColor=colors.HexColor('#555555')))
57
  styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY, spaceAfter=12, leading=14))
 
61
 
62
  story = []
63
 
 
 
64
  story.append(Paragraph("Interview Performance Report", styles['ReportTitle']))
65
  story.append(Spacer(1, 0.5 * inch))
66
  story.append(Paragraph(f"Prepared for: <b>{interview_data.get('name', 'N/A')}</b>", styles['ReportSubTitle']))
 
70
  story.append(Paragraph(f"Date of Report: <b>{datetime.datetime.now().strftime('%B %d, %Y')}</b>", styles['ReportSubTitle']))
71
  story.append(PageBreak())
72
 
 
73
  story.append(Paragraph("Overall Performance Analysis", styles['MainHeader']))
74
  full_log_text = ""
75
  all_scores = []
 
90
  story.append(Image(chart_path, width=4.5*inch, height=4.5*inch, hAlign='CENTER'))
91
  story.append(PageBreak())
92
 
 
93
  story.append(Paragraph("Detailed Question Analysis", styles['MainHeader']))
94
  for i, qa in enumerate(interview_data['q_and_a']):
95
  story.append(Paragraph(f"Question {i+1}: {qa['question']}", styles['QuestionTitle']))