Skip to content

Commit

Permalink
fix: when no option selected, the criteria should try to create
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Jun 7, 2023
1 parent cef8c06 commit 40613ae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lms/djangoapps/ora_staff_grader/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ class StaffAssessSerializer(serializers.Serializer):
def get_options_selected(self, instance):
options_selected = {}
for criterion in instance.get("criteria"):
options_selected[criterion["name"]] = criterion["selectedOption"]
if criterion["selectedOption"]:
options_selected[criterion["name"]] = criterion["selectedOption"]

return options_selected

Expand Down
22 changes: 22 additions & 0 deletions lms/djangoapps/ora_staff_grader/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,13 @@ class TestStaffAssessSerializer(TestCase):
],
}

grade_data_no_selected_option = {
"overallFeedback": "was pretty good",
"criteria": [
{"name": "firstCriterion", "selectedOption": None},
],
}

submission_uuid = "foo"

def test_staff_assess_serializer(self):
Expand Down Expand Up @@ -757,3 +764,18 @@ def test_staff_assess_no_feedback(self):
}

assert serializer.data == expected_value

def test_staff_assess_no_selected_option(self):
"""When selected option is None, it should be ignored"""
context = {"submission_uuid": self.submission_uuid}
serializer = StaffAssessSerializer(self.grade_data_no_selected_option, context=context)

expected_value = {
"options_selected": {},
"criterion_feedback": {},
"overall_feedback": "was pretty good",
"submission_uuid": self.submission_uuid,
"assess_type": "full-grade",
}

assert serializer.data == expected_value

0 comments on commit 40613ae

Please sign in to comment.