Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 771 |
question_block_pattern = re.compile(
|
| 772 |
-
r"### Question
|
| 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
|
| 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 |
|