AI-RESEARCHER-2024 commited on
Commit
1a5108c
·
verified ·
1 Parent(s): 3192546

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -53
app.py CHANGED
@@ -238,62 +238,62 @@ Overall Performance Level: [Exemplary (85-100%)/Proficient (70-84%)/Developing (
238
  return summary
239
 
240
  def parse_assessment_scores(self, assessment_text):
241
- """Parse assessment text to extract scores"""
242
-
243
- # Method 1: Look for "Status: OBSERVED" vs "Status: NOT OBSERVED" patterns
244
- import re
245
-
246
- # Find all status lines
247
- status_pattern = r'Status:\s*(OBSERVED|NOT OBSERVED)'
248
- matches = re.findall(status_pattern, assessment_text, re.IGNORECASE)
249
-
250
- # Count only "OBSERVED" (not "NOT OBSERVED")
251
- observed_count = sum(1 for match in matches if match.upper() == "OBSERVED")
252
-
253
- # If no matches found with Status: pattern, try alternative parsing
254
- if len(matches) == 0:
255
- # Alternative: Look for competency lines with OBSERVED/NOT OBSERVED
256
- lines = assessment_text.split('\n')
257
- observed_count = 0
258
 
259
- for i, line in enumerate(lines):
260
- # Look for competency indicators followed by status
261
- if 'Competency' in line and i + 1 < len(lines):
262
- next_line = lines[i + 1]
263
- # Check if the status line indicates OBSERVED (not NOT OBSERVED)
264
- if 'OBSERVED' in next_line.upper() and 'NOT OBSERVED' not in next_line.upper():
265
- observed_count += 1
266
 
267
- # If still no matches, use a more robust pattern
268
- if observed_count == 0:
269
- # Count lines that say "OBSERVED" but not "NOT OBSERVED"
270
- for line in lines:
271
- # Clean line for better matching
272
- clean_line = line.strip().upper()
273
- if clean_line.startswith('STATUS:'):
274
- if 'NOT OBSERVED' in clean_line:
275
- continue
276
- elif 'OBSERVED' in clean_line:
 
 
 
 
 
 
 
 
 
277
  observed_count += 1
278
-
279
- total_competencies = 18
280
- percentage = (observed_count / total_competencies) * 100 if total_competencies > 0 else 0
281
-
282
- # Professional color scheme with better contrast
283
- if percentage >= 85:
284
- level = "Exemplary"
285
- color = "#0F766E" # Deep teal
286
- elif percentage >= 70:
287
- level = "Proficient"
288
- color = "#1E40AF" # Professional blue
289
- elif percentage >= 50:
290
- level = "Developing"
291
- color = "#EA580C" # Professional orange
292
- else:
293
- level = "Needs Improvement"
294
- color = "#B91C1C" # Deep red
295
-
296
- return observed_count, total_competencies, percentage, level, color
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
  def generate_pdf_report(self, assessment_text):
299
  """Generate a PDF report from the assessment text"""
 
238
  return summary
239
 
240
  def parse_assessment_scores(self, assessment_text):
241
+ """Parse assessment text to extract scores"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
 
243
+ # Method 1: Look for "Status: OBSERVED" vs "Status: NOT OBSERVED" patterns
244
+ import re
 
 
 
 
 
245
 
246
+ # Find all status lines
247
+ status_pattern = r'Status:\s*(OBSERVED|NOT OBSERVED)'
248
+ matches = re.findall(status_pattern, assessment_text, re.IGNORECASE)
249
+
250
+ # Count only "OBSERVED" (not "NOT OBSERVED")
251
+ observed_count = sum(1 for match in matches if match.upper() == "OBSERVED")
252
+
253
+ # If no matches found with Status: pattern, try alternative parsing
254
+ if len(matches) == 0:
255
+ # Alternative: Look for competency lines with OBSERVED/NOT OBSERVED
256
+ lines = assessment_text.split('\n')
257
+ observed_count = 0
258
+
259
+ for i, line in enumerate(lines):
260
+ # Look for competency indicators followed by status
261
+ if 'Competency' in line and i + 1 < len(lines):
262
+ next_line = lines[i + 1]
263
+ # Check if the status line indicates OBSERVED (not NOT OBSERVED)
264
+ if 'OBSERVED' in next_line.upper() and 'NOT OBSERVED' not in next_line.upper():
265
  observed_count += 1
266
+
267
+ # If still no matches, use a more robust pattern
268
+ if observed_count == 0:
269
+ # Count lines that say "OBSERVED" but not "NOT OBSERVED"
270
+ for line in lines:
271
+ # Clean line for better matching
272
+ clean_line = line.strip().upper()
273
+ if clean_line.startswith('STATUS:'):
274
+ if 'NOT OBSERVED' in clean_line:
275
+ continue
276
+ elif 'OBSERVED' in clean_line:
277
+ observed_count += 1
278
+
279
+ total_competencies = 18
280
+ percentage = (observed_count / total_competencies) * 100 if total_competencies > 0 else 0
281
+
282
+ # Professional color scheme with better contrast
283
+ if percentage >= 85:
284
+ level = "Exemplary"
285
+ color = "#0F766E" # Deep teal
286
+ elif percentage >= 70:
287
+ level = "Proficient"
288
+ color = "#1E40AF" # Professional blue
289
+ elif percentage >= 50:
290
+ level = "Developing"
291
+ color = "#EA580C" # Professional orange
292
+ else:
293
+ level = "Needs Improvement"
294
+ color = "#B91C1C" # Deep red
295
+
296
+ return observed_count, total_competencies, percentage, level, color
297
 
298
  def generate_pdf_report(self, assessment_text):
299
  """Generate a PDF report from the assessment text"""