Spaces:
Sleeping
Sleeping
fixed iterate till first empty row
Browse files- app.py +1 -1
- src/main.py +15 -4
app.py
CHANGED
@@ -55,7 +55,7 @@ grading_criteria = st.text_area("Enter grading criteria or relevant marking info
|
|
55 |
|
56 |
|
57 |
# Path to the example Excel file in the repository
|
58 |
-
st.subheader("Specify
|
59 |
example_file_path ="example.xlsx"
|
60 |
serve_excel_for_download(example_file_path)
|
61 |
st.text("Please download the example Excel file to see the expected format. You will need to adjust the student IDs and page counts. Note that if you provide a grade and reason for a student, the system will not reassess that student's essay. Further, this will help te system make better assessments by calibrating it to your style of grading. Note that grade and reason must both be specified.")
|
|
|
55 |
|
56 |
|
57 |
# Path to the example Excel file in the repository
|
58 |
+
st.subheader("Specify student IDs and page count")
|
59 |
example_file_path ="example.xlsx"
|
60 |
serve_excel_for_download(example_file_path)
|
61 |
st.text("Please download the example Excel file to see the expected format. You will need to adjust the student IDs and page counts. Note that if you provide a grade and reason for a student, the system will not reassess that student's essay. Further, this will help te system make better assessments by calibrating it to your style of grading. Note that grade and reason must both be specified.")
|
src/main.py
CHANGED
@@ -17,10 +17,21 @@ def process_essays(images, question, guidelines, workbook):
|
|
17 |
for col in range(1, sheet.max_column + 1):
|
18 |
new_sheet.cell(row=1, column=col).value = sheet.cell(row=1, column=col).value
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
|
|
22 |
# First Pass: Transcribe missing texts
|
23 |
-
for row in range(2,
|
24 |
student_id = sheet.cell(row=row, column=1).value
|
25 |
num_pages = sheet.cell(row=row, column=2).value
|
26 |
transcribed_text = sheet.cell(row=row, column=3).value
|
@@ -47,7 +58,7 @@ def process_essays(images, question, guidelines, workbook):
|
|
47 |
|
48 |
# Collect graded examples and initialize list
|
49 |
examples = []
|
50 |
-
for row in range(2,
|
51 |
student_id = sheet.cell(row=row, column=1).value
|
52 |
transcribed_text = sheet.cell(row=row, column=3).value
|
53 |
mark = sheet.cell(row=row, column=4).value
|
@@ -59,7 +70,7 @@ def process_essays(images, question, guidelines, workbook):
|
|
59 |
examples.append({"essay": transcribed_text, "mark": mark, "reason": reason})
|
60 |
|
61 |
# Second Pass: Grade missing grades/reasons
|
62 |
-
for row in range(2,
|
63 |
student_id = sheet.cell(row=row, column=1).value
|
64 |
transcribed_text = new_sheet.cell(row=row, column=3).value
|
65 |
mark = sheet.cell(row=row, column=4).value
|
|
|
17 |
for col in range(1, sheet.max_column + 1):
|
18 |
new_sheet.cell(row=1, column=col).value = sheet.cell(row=1, column=col).value
|
19 |
|
20 |
+
# Find the first empty row in the student ID column
|
21 |
+
first_empty_row = None
|
22 |
+
for row in range(2, sheet.max_row + 1):
|
23 |
+
student_id = sheet.cell(row=row, column=1).value
|
24 |
+
if student_id is None:
|
25 |
+
first_empty_row = row
|
26 |
+
break
|
27 |
+
else:
|
28 |
+
# If no empty cell was found, set first_empty_row to max_row + 1 to process all rows
|
29 |
+
first_empty_row = sheet.max_row + 1
|
30 |
+
|
31 |
|
32 |
+
img_index = 0
|
33 |
# First Pass: Transcribe missing texts
|
34 |
+
for row in range(2, first_empty_row + 1):
|
35 |
student_id = sheet.cell(row=row, column=1).value
|
36 |
num_pages = sheet.cell(row=row, column=2).value
|
37 |
transcribed_text = sheet.cell(row=row, column=3).value
|
|
|
58 |
|
59 |
# Collect graded examples and initialize list
|
60 |
examples = []
|
61 |
+
for row in range(2, first_empty_row):
|
62 |
student_id = sheet.cell(row=row, column=1).value
|
63 |
transcribed_text = sheet.cell(row=row, column=3).value
|
64 |
mark = sheet.cell(row=row, column=4).value
|
|
|
70 |
examples.append({"essay": transcribed_text, "mark": mark, "reason": reason})
|
71 |
|
72 |
# Second Pass: Grade missing grades/reasons
|
73 |
+
for row in range(2, first_empty_row):
|
74 |
student_id = sheet.cell(row=row, column=1).value
|
75 |
transcribed_text = new_sheet.cell(row=row, column=3).value
|
76 |
mark = sheet.cell(row=row, column=4).value
|