Skip to content

Commit 37b4dfb

Browse files
ihalaij1markkuriekkinen
authored andcommitted
Set error and empty feedback file if it is too large
If the grading container tries to send a massive feedback dump back to the MOOC-Grader, the /container-post view fails to receive it due to settings.DATA_UPLOAD_MAX_MEMORY_SIZE. This fix sets the feedback_size_error field to true and empties the feedback file when it is too large. MOOC-Grader can then detect these cases and provide informative feedback to the students. Part of apluslms/mooc-grader#146
1 parent 65aedfe commit 37b4dfb

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

bin/grade

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/bin/sh
2+
3+
# MOOC-Grader has the Django variable settings.DATA_UPLOAD_MAX_MEMORY_SIZE set to 10*1024*1024 (10MB).
4+
# Therefore, the grading containers have a maximum feedback size of 9*1024*1024 (9MB).
5+
# The remaining 1MB is allocated for data, such as sid, points, max_points, and grading_data (errors visible to staff).
6+
MAX_FEEDBACK_SIZE=$((9*1024*1024))
7+
28
feedback_file=/dev/shm/feedback
39
grading_data_file=/dev/shm/grading_data
410
opts=""
@@ -84,6 +90,15 @@ collect_feedback() {
8490
echo '</div>'
8591
fi
8692
) > $feedback_file
93+
94+
feedback_size=$(stat -c%s "$feedback_file")
95+
96+
# Empty the feedback file if it is too large
97+
if [ $feedback_size -gt $MAX_FEEDBACK_SIZE ]; then
98+
> $feedback_file
99+
opts="$opts -F feedback_size_error=true"
100+
fi
101+
87102
opts="$opts -F feedback=<$feedback_file"
88103
}
89104

0 commit comments

Comments
 (0)