diff --git a/kolibri/core/exams/serializers.py b/kolibri/core/exams/serializers.py index 3e8bfe5c053..f3de2931040 100644 --- a/kolibri/core/exams/serializers.py +++ b/kolibri/core/exams/serializers.py @@ -172,12 +172,6 @@ def validate(self, attrs): code=error_constants.INVALID, ) - if "learners_see_fixed_order" in attrs and is_non_draft_exam: - raise ValidationError( - "Cannot update learners_see_fixed_order on an Exam object", - code=error_constants.INVALID, - ) - return attrs def create(self, validated_data): @@ -273,6 +267,9 @@ def update(self, instance, validated_data): # noqa instance_is_draft = False # Update the scalar fields instance.title = validated_data.pop("title", instance.title) + instance.learners_see_fixed_order = validated_data.pop( + "learners_see_fixed_order", instance.learners_see_fixed_order + ) if not instance_is_draft: # Update the non-draft specific fields instance.active = validated_data.pop("active", instance.active) @@ -286,9 +283,6 @@ def update(self, instance, validated_data): # noqa instance.question_sources = validated_data.pop( "question_sources", instance.question_sources ) - instance.learners_see_fixed_order = validated_data.pop( - "learners_see_fixed_order", instance.learners_see_fixed_order - ) # Add/delete any new/removed Assignments if "assignments" in validated_data: diff --git a/kolibri/core/exams/test/test_exam_api.py b/kolibri/core/exams/test/test_exam_api.py index 740aaef652e..8e7d42fe9b7 100644 --- a/kolibri/core/exams/test/test_exam_api.py +++ b/kolibri/core/exams/test/test_exam_api.py @@ -495,6 +495,14 @@ def test_exam_question_max_length(self): response = self.post_new_exam(exam) self.assertEqual(response.status_code, 400) + def test_admin_can_update_learner_sees_fixed_order(self): + self.login_as_admin() + response = self.patch_updated_exam( + self.exam.id, {"learners_see_fixed_order": True} + ) + self.assertEqual(response.status_code, 200) + self.assertExamExists(id=self.exam.id, learners_see_fixed_order=True) + class ExamAPITestCase(BaseExamTest, APITestCase): class_object = models.Exam @@ -578,19 +586,6 @@ def test_logged_in_admin_exam_update_cannot_update_question_sources(self): self.exam.refresh_from_db() self.assertEqual(self.exam.question_sources, previous_sections) - def test_logged_in_admin_exam_update_cannot_update_learners_see_fixed_order(self): - self.login_as_admin() - previous_learners_see_fixed_order = self.exam.learners_see_fixed_order - response = self.patch_updated_exam( - self.exam.id, - {"learners_see_fixed_order": not previous_learners_see_fixed_order}, - ) - self.assertEqual(response.status_code, 400) - self.exam.refresh_from_db() - self.assertEqual( - self.exam.learners_see_fixed_order, previous_learners_see_fixed_order - ) - def test_logged_in_admin_exam_can_create_and_publish_remove_empty_sections(self): self.login_as_admin() exam = self.make_basic_exam()