diff --git a/openassessment/__init__.py b/openassessment/__init__.py index ee34f700de..0eea6b16d1 100644 --- a/openassessment/__init__.py +++ b/openassessment/__init__.py @@ -2,4 +2,4 @@ Initialization Information for Open Assessment Module """ -__version__ = '6.0.2' +__version__ = '6.0.3' diff --git a/openassessment/xblock/ui_mixins/mfe/ora_config_serializer.py b/openassessment/xblock/ui_mixins/mfe/ora_config_serializer.py index db26b92642..f68252b244 100644 --- a/openassessment/xblock/ui_mixins/mfe/ora_config_serializer.py +++ b/openassessment/xblock/ui_mixins/mfe/ora_config_serializer.py @@ -117,6 +117,15 @@ class SelfSettingsSerializer(Serializer): endDatetime = DateTimeField(source="due") +class StudentTrainingSettingsSerializer(Serializer): + required = BooleanField(default=True) + + numberOfExamples = SerializerMethodField(source="*", default=0) + + def get_numberOfExamples(self, assessment): + return len(assessment["examples"]) + + class PeerSettingsSerializer(Serializer): required = BooleanField(default=True) @@ -158,6 +167,8 @@ def to_representation(self, instance): return PeerSettingsSerializer(assessment_step).data elif assessment_step and self.step_name == "self-assessment": return SelfSettingsSerializer(assessment_step).data + elif assessment_step and self.step_name == "student-training": + return StudentTrainingSettingsSerializer(assessment_step).data # If we didn't find a step, it is not required if assessment_step is None: diff --git a/openassessment/xblock/ui_mixins/mfe/page_context_serializer.py b/openassessment/xblock/ui_mixins/mfe/page_context_serializer.py index 268879ccb6..3bb623682b 100644 --- a/openassessment/xblock/ui_mixins/mfe/page_context_serializer.py +++ b/openassessment/xblock/ui_mixins/mfe/page_context_serializer.py @@ -140,25 +140,23 @@ def get_expectedRubricSelections(self, instance): WARN: It is critical we do not hit this if we are not on the student training step, as loading an example will create a workflow. - Returns: List of criterion names and matched selections - [ - { - name: (String) Criterion name, - selection: (String) Option name that should be selected, - } - ] + Returns: { + : (Number) Selected criterion option index + : (Number) Selected criterion option index + ... etc. + } """ - example = instance.example + criteria = instance.example["rubric"]['criteria'] + options_selected = instance.example["options_selected"] - options_selected = [] - for criterion in example["options_selected"]: - criterion_selection = { - "name": criterion, - "selection": example["options_selected"][criterion], - } - options_selected.append(criterion_selection) + expected_rubric_selections = {} + for criterion in criteria: + for option in criterion['options']: + if option['name'] == options_selected[criterion['name']]: + expected_rubric_selections[criterion['order_num']] = option['order_num'] + break - return options_selected + return expected_rubric_selections class PeerStepInfoSerializer(StepInfoBaseSerializer): diff --git a/openassessment/xblock/ui_mixins/mfe/test_page_context_serializer.py b/openassessment/xblock/ui_mixins/mfe/test_page_context_serializer.py index f839c5e97c..7919ebf86e 100644 --- a/openassessment/xblock/ui_mixins/mfe/test_page_context_serializer.py +++ b/openassessment/xblock/ui_mixins/mfe/test_page_context_serializer.py @@ -336,13 +336,10 @@ def test_student_training(self, xblock): "closed": False, "closedReason": None, "numberOfAssessmentsCompleted": 0, - "expectedRubricSelections": [ - { - "name": "Vocabulary", - "selection": "Good", - }, - {"name": "Grammar", "selection": "Excellent"}, - ], + "expectedRubricSelections": { + 0: 1, + 1: 2, + } }, "peer": None, }, @@ -376,13 +373,10 @@ def test_student_training_due(self, xblock): "closed": True, "closedReason": "pastDue", "numberOfAssessmentsCompleted": 0, - "expectedRubricSelections": [ - { - "name": "Vocabulary", - "selection": "Good", - }, - {"name": "Grammar", "selection": "Excellent"}, - ], + "expectedRubricSelections": { + 0: 1, + 1: 2, + } }, "peer": None, }, @@ -416,13 +410,10 @@ def test_student_training_not_yet_available(self, xblock): "closed": True, "closedReason": "notAvailableYet", "numberOfAssessmentsCompleted": 0, - "expectedRubricSelections": [ - { - "name": "Vocabulary", - "selection": "Good", - }, - {"name": "Grammar", "selection": "Excellent"}, - ], + "expectedRubricSelections": { + 0: 1, + 1: 2, + }, }, "peer": None, }, diff --git a/openassessment/xblock/ui_mixins/mfe/test_serializers.py b/openassessment/xblock/ui_mixins/mfe/test_serializers.py index 5d782589b8..163e370c08 100644 --- a/openassessment/xblock/ui_mixins/mfe/test_serializers.py +++ b/openassessment/xblock/ui_mixins/mfe/test_serializers.py @@ -322,9 +322,9 @@ def test_flex_grading(self, xblock): self.assertTrue(peer_config["enableFlexibleGrading"]) -class TestTrainingSettingsSerializer(XBlockHandlerTestCase): +class TestStudentTrainingSettingsSerializer(XBlockHandlerTestCase): """ - Test for TrainingSettingsSerializer + Test for StudentTrainingSettingsSerializer """ step_config_key = "studentTraining" @@ -339,8 +339,9 @@ def test_enabled(self, xblock): # Then I get the right config self.assertTrue(step_config["required"]) + self.assertEqual(step_config["numberOfExamples"], 2) - @scenario("data/basic_scenario.xml") + @scenario("data/peer_only_scenario.xml") def test_disabled(self, xblock): # Given an ORA without a training step # When I ask for step config @@ -350,6 +351,7 @@ def test_disabled(self, xblock): # Then I get the right config self.assertFalse(step_config["required"]) + self.assertNotIn("numberOfExamples", step_config) class TestSelfSettingsSerializer(XBlockHandlerTestCase): diff --git a/package-lock.json b/package-lock.json index 8369bf26be..0bbdd5d5f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "edx-ora2", - "version": "6.0.2", + "version": "6.0.3", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index cded8cf7ba..8e96f53867 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edx-ora2", - "version": "6.0.2", + "version": "6.0.3", "repository": "https://github.com/openedx/edx-ora2.git", "dependencies": { "@edx/frontend-build": "^6.1.1",