Skip to content

Commit

Permalink
chore: update student training shape (#2111)
Browse files Browse the repository at this point in the history
* chore: add numberOfExamples to training assessment step setting

* chore: update expect rubric selections data shape

* chore: version bump
  • Loading branch information
leangseu-edx authored Nov 16, 2023
1 parent fd4bd76 commit 33c7731
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 43 deletions.
2 changes: 1 addition & 1 deletion openassessment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Initialization Information for Open Assessment Module
"""

__version__ = '6.0.2'
__version__ = '6.0.3'
11 changes: 11 additions & 0 deletions openassessment/xblock/ui_mixins/mfe/ora_config_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
30 changes: 14 additions & 16 deletions openassessment/xblock/ui_mixins/mfe/page_context_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
<Criterion Index>: (Number) Selected criterion option index
<Criterion 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):
Expand Down
33 changes: 12 additions & 21 deletions openassessment/xblock/ui_mixins/mfe/test_page_context_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down
8 changes: 5 additions & 3 deletions openassessment/xblock/ui_mixins/mfe/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 33c7731

Please sign in to comment.