feat: add text response type to ora config (#30721)

For staff grader setup, we want to know the response type to do better
rendering of the response. This derives from ORA's text_response_editor
setting and is either "text" (default) or "tinymce".

Co-authored-by: nsprenkle <nsprenkle@2u.com>
This commit is contained in:
Nathan Sprenkle
2022-07-12 15:44:24 -04:00
committed by GitHub
parent 519bd18571
commit e1c8fb51be
2 changed files with 15 additions and 0 deletions

View File

@@ -87,6 +87,7 @@ class OpenResponseMetadataSerializer(serializers.Serializer):
prompts = serializers.ListField()
type = serializers.SerializerMethodField()
textResponseConfig = serializers.SerializerMethodField()
textResponseEditor = serializers.CharField(source='text_response_editor')
fileUploadResponseConfig = serializers.SerializerMethodField()
rubricConfig = RubricConfigSerializer(source="*")
@@ -105,6 +106,7 @@ class OpenResponseMetadataSerializer(serializers.Serializer):
"prompts",
"type",
"textResponseConfig",
"textResponseEditor",
"fileUploadResponseConfig",
"rubricConfig",
]

View File

@@ -106,6 +106,7 @@ class TestOpenResponseMetadataSerializer(TestCase):
],
"teams_enabled": False,
"text_response": None,
"text_response_editor": "text",
"file_upload_response": None,
**test_data.example_rubric,
}
@@ -121,6 +122,7 @@ class TestOpenResponseMetadataSerializer(TestCase):
"prompts": self.ora_data["prompts"],
"type": "individual",
"textResponseConfig": "none",
"textResponseEditor": "text",
"fileUploadResponseConfig": "none",
"rubricConfig": {
"feedbackPrompt": "How did this student do?",
@@ -155,6 +157,7 @@ class TestOpenResponseMetadataSerializer(TestCase):
"prompts": self.ora_data["prompts"],
"type": "team",
"textResponseConfig": "none",
"textResponseEditor": "text",
"fileUploadResponseConfig": "none",
"rubricConfig": {
"feedbackPrompt": "How did this student do?",
@@ -199,6 +202,16 @@ class TestOpenResponseMetadataSerializer(TestCase):
assert data["textResponseConfig"] == "none"
assert data["fileUploadResponseConfig"] == "none"
@ddt.data("text", "tinymce")
def test_text_response_editor_config(self, text_response_editor):
# Currently allowed types are "text" and "tinymce" for student text responses.
# Text is set as default
self.mock_ora_instance.text_response_editor = text_response_editor
data = OpenResponseMetadataSerializer(self.mock_ora_instance).data
assert data["textResponseEditor"] == text_response_editor
class TestSubmissionMetadataSerializer(TestCase):
"""