diff --git a/lms/djangoapps/ora_staff_grader/serializers.py b/lms/djangoapps/ora_staff_grader/serializers.py index bf34897c6d..56edb1ff89 100644 --- a/lms/djangoapps/ora_staff_grader/serializers.py +++ b/lms/djangoapps/ora_staff_grader/serializers.py @@ -167,12 +167,14 @@ class InitializeSerializer(serializers.Serializer): courseMetadata = CourseMetadataSerializer() oraMetadata = OpenResponseMetadataSerializer() submissions = serializers.DictField(child=SubmissionMetadataSerializer()) + isEnabled = serializers.BooleanField() class Meta: fields = [ "courseMetadata", "oraMetadata", "submissions", + "isEnabled" ] read_only_fields = fields diff --git a/lms/djangoapps/ora_staff_grader/tests/test_serializers.py b/lms/djangoapps/ora_staff_grader/tests/test_serializers.py index 648f053772..8edfa607e8 100644 --- a/lms/djangoapps/ora_staff_grader/tests/test_serializers.py +++ b/lms/djangoapps/ora_staff_grader/tests/test_serializers.py @@ -347,6 +347,7 @@ class TestInitializeSerializer(TestCase): "courseMetadata": self.mock_course_metadata, "oraMetadata": self.mock_ora_instance, "submissions": self.mock_submissions_data, + "isEnabled": True, } output_data = InitializeSerializer(input_data).data @@ -364,7 +365,7 @@ class TestInitializeSerializer(TestCase): assert output_data["courseMetadata"] == expected_course_data assert output_data["oraMetadata"] == expected_ora_data assert output_data["submissions"] == expected_submissions_data - + assert output_data["isEnabled"] == True class TestRubricConfigSerializer(TestCase): """Tests for RubricConfigSerializer""" diff --git a/lms/djangoapps/ora_staff_grader/tests/test_views.py b/lms/djangoapps/ora_staff_grader/tests/test_views.py index e50c56a1fb..e86ae1a15d 100644 --- a/lms/djangoapps/ora_staff_grader/tests/test_views.py +++ b/lms/djangoapps/ora_staff_grader/tests/test_views.py @@ -116,7 +116,7 @@ class TestInitializeView(BaseViewTest): self.api_url, {PARAM_ORA_LOCATION: self.ora_usage_key} ) - expected_keys = set(["courseMetadata", "oraMetadata", "submissions"]) + expected_keys = set(["courseMetadata", "oraMetadata", "submissions", "isEnabled"]) assert response.status_code == 200 assert response.data.keys() == expected_keys diff --git a/lms/djangoapps/ora_staff_grader/views.py b/lms/djangoapps/ora_staff_grader/views.py index bdad314699..503a76a0dd 100644 --- a/lms/djangoapps/ora_staff_grader/views.py +++ b/lms/djangoapps/ora_staff_grader/views.py @@ -14,6 +14,7 @@ from edx_rest_framework_extensions.auth.session.authentication import ( ) from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import UsageKey +from openassessment.xblock.config_mixin import WAFFLE_NAMESPACE, ENHANCED_STAFF_GRADER from rest_framework.generics import RetrieveAPIView from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response @@ -53,6 +54,7 @@ from lms.djangoapps.ora_staff_grader.utils import require_params from openedx.core.djangoapps.content.course_overviews.api import ( get_course_overview_or_none, ) +from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser log = logging.getLogger(__name__) @@ -80,6 +82,7 @@ class InitializeView(StaffGraderBaseView): courseMetadata oraMetadata submissions + isEnabled } Errors: @@ -89,6 +92,15 @@ class InitializeView(StaffGraderBaseView): - UnknownError (HTTP 500) for other errors """ + def _is_staff_grader_enabled(self, course_key): + """ Helper to evaluate if the staff grader flag / overrides are enabled """ + enhanced_staff_grader_flag = CourseWaffleFlag( + WAFFLE_NAMESPACE, + ENHANCED_STAFF_GRADER, + module_name='openassessment.xblock.config_mixin' + ) + return enhanced_staff_grader_flag.is_enabled(course_key) + @require_params([PARAM_ORA_LOCATION]) def get(self, request, ora_location, *args, **kwargs): try: @@ -105,6 +117,9 @@ class InitializeView(StaffGraderBaseView): # Get list of submissions for this ORA init_data["submissions"] = get_submissions(request, ora_location) + # Is the Staff Grader enabled for this course? + init_data["isEnabled"] = self._is_staff_grader_enabled(ora_usage_key.course_key) + response_data = InitializeSerializer(init_data).data log.info(response_data) return Response(response_data)