Skip to content

Commit

Permalink
feat: send submission ID when removing grade
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Sep 21, 2023
1 parent 1c06c78 commit 9e274d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions mindmap/mindmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def update_student_submission_status(self, student_id, submission_status):
"""
from submissions.api import create_submission
student_submission = self.get_submission(student_id)
mindmap_student_body = student_submission.get("mindmap_student_body", {})
mindmap_student_body = student_submission.get("answer", {}).get("mindmap_student_body", {})
answer = {
"mindmap_student_body": mindmap_student_body,
"submission_status": submission_status,
Expand All @@ -539,20 +539,21 @@ def remove_grade(self, data, _suffix="") -> dict:
dict: A dictionary containing the handler result.
"""
# Lazy import: import here to avoid app not ready errors
from submissions.api import reset_score, create_submission # pylint: disable=import-outside-toplevel
from submissions.api import reset_score # pylint: disable=import-outside-toplevel

require(self.is_instructor())

student_id = data.get("student_id")
if not student_id:
submission_id = data.get("submission_id")
if not student_id or not submission_id:
raise JsonHandlerError(400, "Missing required parameters")

latest_submission = self.update_student_submission_status(
reset_score(submission_id, self.block_course_id, self.block_id)

self.update_student_submission_status(
data.get("student_id"), SubmissionStatus.SUBMITTED.value,
)

reset_score(latest_submission["uuid"], self.block_course_id, self.block_id)

return {
"success": True,
}
Expand Down
3 changes: 2 additions & 1 deletion mindmap/public/js/src/mindmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function MindMapXBlock(runtime, element, context) {
e.preventDefault();
const typeAction = $(this).attr("data-type");
const grade = $("#grade_value").val();
const { student_id } = submissionData;
const { student_id, submission_id } = submissionData;
const invalidGradeMessage = gettext("Invalid grade must be a number");
const maxGradeMessage = gettext("Please enter a lower grade, maximum grade allowed is:");
const gradeParsed = parseInt(grade, 10);
Expand Down Expand Up @@ -261,6 +261,7 @@ function MindMapXBlock(runtime, element, context) {
apiUrl = removeGradeURL;
data = {
student_id: student_id,
submission_id: submission_id,
};
}

Expand Down

0 comments on commit 9e274d6

Please sign in to comment.