atz21 commited on
Commit
8188efa
·
verified ·
1 Parent(s): 630855b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -767,10 +767,14 @@ def check_and_correct_total_marks(grading_text):
767
  calculated_total_awarded = 0
768
  calculated_total_possible = 0
769
 
770
- # Extract marks from each question block
 
 
 
 
771
  question_block_pattern = re.compile(
772
- r"### Question (\d+\.?[a-z]?.*?)[\s\S]*?\*\*Total: (\d+)/(\d+)\*\*",
773
- re.DOTALL
774
  )
775
 
776
  matches = question_block_pattern.finditer(grading_text)
@@ -782,7 +786,7 @@ def check_and_correct_total_marks(grading_text):
782
  calculated_total_awarded += awarded
783
  calculated_total_possible += possible
784
 
785
- print(f"\n📊 Extracted marks from {len(question_marks)} questions:")
786
  for q_id, marks in question_marks.items():
787
  print(f" Question {q_id}: {marks['awarded']}/{marks['possible']}")
788
 
 
767
  calculated_total_awarded = 0
768
  calculated_total_possible = 0
769
 
770
+ # Updated pattern to match BOTH formats:
771
+ # ### Question <1.a> (with angle brackets)
772
+ # ### Question 1.a (without angle brackets)
773
+ # The <? makes the opening bracket optional
774
+ # The >? makes the closing bracket optional
775
  question_block_pattern = re.compile(
776
+ r"### Question\s*<?([0-9]+(?:[.()][a-z0-9]+)*)>?\s*[\s\S]*?\*\*Total:\s*(\d+)/(\d+)\*\*",
777
+ re.DOTALL | re.IGNORECASE
778
  )
779
 
780
  matches = question_block_pattern.finditer(grading_text)
 
786
  calculated_total_awarded += awarded
787
  calculated_total_possible += possible
788
 
789
+ print(f"\n Exltracted marks from {len(question_marks)} questions:")
790
  for q_id, marks in question_marks.items():
791
  print(f" Question {q_id}: {marks['awarded']}/{marks['possible']}")
792