AI-RESEARCHER-2024 commited on
Commit
fa303d0
·
verified ·
1 Parent(s): b3c5f65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -19
app.py CHANGED
@@ -261,11 +261,22 @@ Performance Level: [Exemplary (8.5-10)/Proficient (7-8.4)/Developing (5-6.9)/Nee
261
  return summary
262
 
263
  def parse_assessment_scores(self, assessment_text, param1, param2, param3, param4, param5):
264
- """Parse assessment text to extract weighted scores"""
265
 
266
- # Try to extract the weighted score from the text
267
  import re
268
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  # Look for "TOTAL WEIGHTED SCORE: X/10" pattern
270
  score_pattern = r'TOTAL WEIGHTED SCORE:\s*([0-9.]+)/10'
271
  match = re.search(score_pattern, assessment_text, re.IGNORECASE)
@@ -278,21 +289,34 @@ Performance Level: [Exemplary (8.5-10)/Proficient (7-8.4)/Developing (5-6.9)/Nee
278
 
279
  percentage = (weighted_score / 10) * 100
280
 
281
- # Determine performance level and color based on score
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  if weighted_score >= 8.5:
283
- level = "Exemplary"
284
  color = "#0F766E" # Deep teal
285
  elif weighted_score >= 7:
286
- level = "Proficient"
287
  color = "#1E40AF" # Professional blue
288
  elif weighted_score >= 5:
289
- level = "Developing"
290
  color = "#EA580C" # Professional orange
291
  else:
292
- level = "Needs Improvement"
293
  color = "#B91C1C" # Deep red
294
 
295
- return weighted_score, percentage, level, color
296
 
297
  def generate_pdf_report(self, assessment_text, param1, param2, param3, param4, param5):
298
  """Generate a PDF report from the assessment text with parameter information"""
@@ -625,12 +649,21 @@ def process_video_core(video, resize_option, assessor, param1, param2, param3, p
625
  pdf_path = assessor.generate_pdf_report(assessment_result, param1, param2, param3, param4, param5)
626
 
627
  # Parse scores for visual summary
628
- weighted_score, percentage, level, color = assessor.parse_assessment_scores(assessment_result, param1, param2, param3, param4, param5)
 
 
 
629
 
630
  # Create enhanced visual summary HTML with parameter information
631
  summary_html = f"""
632
  <div style="max-width:800px; margin:20px auto; padding:30px; border-radius:15px; box-shadow:0 2px 10px rgba(0,0,0,0.08); background:white;">
633
  <h2 style="text-align:center; color:#111827; margin-bottom:30px; font-weight:600;">Customized Assessment Summary</h2>
 
 
 
 
 
 
634
  <div style="display:flex; justify-content:space-around; margin:30px 0;">
635
  <div style="text-align:center;">
636
  <div style="font-size:48px; font-weight:bold; color:{color};">{weighted_score:.1f}/10</div>
@@ -688,16 +721,6 @@ def process_video_core(video, resize_option, assessor, param1, param2, param3, p
688
  </div>
689
  </div>
690
  </div>
691
- <div style="margin-top:30px;">
692
- <h3 style="color:#111827; margin-bottom:20px; font-weight:600;">Key Assessment Areas:</h3>
693
-
694
- <div style="background:#F8FAFC; padding:15px; border-radius:10px; margin:10px 0; border:1px solid #E2E8F0;">
695
- <p style="color:#374151; line-height:1.8;">
696
- Your assessment focused on the parameters you prioritized. Areas with higher weights
697
- received more detailed evaluation and have greater impact on the final score.
698
- </p>
699
- </div>
700
- </div>
701
  <div style="margin-top:30px; padding:20px; background:#FFF7ED; border-radius:10px; border-left:4px solid #EA580C;">
702
  <p style="text-align:center; color:#431407; margin:0; font-weight:600;">
703
  Listen to the 1-minute audio summary for key findings<br>
 
261
  return summary
262
 
263
  def parse_assessment_scores(self, assessment_text, param1, param2, param3, param4, param5):
264
+ """Parse assessment text to extract weighted scores and overall assessment"""
265
 
 
266
  import re
267
 
268
+ # Extract the OVERALL WEIGHTED ASSESSMENT section
269
+ overall_assessment_match = re.search(
270
+ r'## OVERALL WEIGHTED ASSESSMENT\s*(.*?)(?=##|\Z)',
271
+ assessment_text,
272
+ re.DOTALL | re.IGNORECASE
273
+ )
274
+
275
+ if overall_assessment_match:
276
+ overall_assessment_text = overall_assessment_match.group(1).strip()
277
+ else:
278
+ overall_assessment_text = "Assessment completed. See detailed evaluation below."
279
+
280
  # Look for "TOTAL WEIGHTED SCORE: X/10" pattern
281
  score_pattern = r'TOTAL WEIGHTED SCORE:\s*([0-9.]+)/10'
282
  match = re.search(score_pattern, assessment_text, re.IGNORECASE)
 
289
 
290
  percentage = (weighted_score / 10) * 100
291
 
292
+ # Extract performance level from text if available
293
+ level_pattern = r'Performance Level:\s*(\w+)'
294
+ level_match = re.search(level_pattern, assessment_text, re.IGNORECASE)
295
+
296
+ if level_match:
297
+ level = level_match.group(1)
298
+ else:
299
+ # Determine performance level based on score
300
+ if weighted_score >= 8.5:
301
+ level = "Exemplary"
302
+ elif weighted_score >= 7:
303
+ level = "Proficient"
304
+ elif weighted_score >= 5:
305
+ level = "Developing"
306
+ else:
307
+ level = "Needs Improvement"
308
+
309
+ # Determine color based on score
310
  if weighted_score >= 8.5:
 
311
  color = "#0F766E" # Deep teal
312
  elif weighted_score >= 7:
 
313
  color = "#1E40AF" # Professional blue
314
  elif weighted_score >= 5:
 
315
  color = "#EA580C" # Professional orange
316
  else:
 
317
  color = "#B91C1C" # Deep red
318
 
319
+ return weighted_score, percentage, level, color, overall_assessment_text
320
 
321
  def generate_pdf_report(self, assessment_text, param1, param2, param3, param4, param5):
322
  """Generate a PDF report from the assessment text with parameter information"""
 
649
  pdf_path = assessor.generate_pdf_report(assessment_result, param1, param2, param3, param4, param5)
650
 
651
  # Parse scores for visual summary
652
+ weighted_score, percentage, level, color, overall_assessment_text = assessor.parse_assessment_scores(assessment_result, param1, param2, param3, param4, param5)
653
+
654
+ # Clean the overall assessment text for HTML display
655
+ clean_overall_assessment = overall_assessment_text.replace('\n', '<br>').replace('*', '').replace('#', '')
656
 
657
  # Create enhanced visual summary HTML with parameter information
658
  summary_html = f"""
659
  <div style="max-width:800px; margin:20px auto; padding:30px; border-radius:15px; box-shadow:0 2px 10px rgba(0,0,0,0.08); background:white;">
660
  <h2 style="text-align:center; color:#111827; margin-bottom:30px; font-weight:600;">Customized Assessment Summary</h2>
661
+
662
+ <div style="background:#F0F9FF; padding:20px; border-radius:10px; margin-bottom:30px; border:1px solid #BAE6FD;">
663
+ <h3 style="color:#0369A1; margin-top:0; margin-bottom:15px; font-weight:600;">Overall Weighted Assessment</h3>
664
+ <p style="color:#374151; line-height:1.8; margin:0;">{clean_overall_assessment}</p>
665
+ </div>
666
+
667
  <div style="display:flex; justify-content:space-around; margin:30px 0;">
668
  <div style="text-align:center;">
669
  <div style="font-size:48px; font-weight:bold; color:{color};">{weighted_score:.1f}/10</div>
 
721
  </div>
722
  </div>
723
  </div>
 
 
 
 
 
 
 
 
 
 
724
  <div style="margin-top:30px; padding:20px; background:#FFF7ED; border-radius:10px; border-left:4px solid #EA580C;">
725
  <p style="text-align:center; color:#431407; margin:0; font-weight:600;">
726
  Listen to the 1-minute audio summary for key findings<br>