Skip to content

Commit

Permalink
feat: add grade value to degreed v2 (#1827)
Browse files Browse the repository at this point in the history
* feat: add grade value to degreed v2

* fix: update tests and refactor code per reviewer feedback

* chore: version bump
  • Loading branch information
katrinan029 authored Jul 27, 2023
1 parent e7c94f4 commit 514f898
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Change Log
Unreleased
----------
[4.0.7]
--------
feat: add grade value to learner transmission for degreed v2

[4.0.6]
--------
fix: variable name conflicts in monthly_impact_report command
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Your project description goes here.
"""

__version__ = "4.0.6"
__version__ = "4.0.7"

default_app_config = "enterprise.apps.EnterpriseConfig"
3 changes: 3 additions & 0 deletions integrated_channels/degreed2/exporters/learner_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def get_learner_data_records(
If no remote ID can be found, return None.
"""
percent_grade = kwargs.get('grade_percent') * 100 if kwargs.get('grade_percent') else None
# Degreed expects completion dates of the form 'yyyy-mm-ddTHH:MM:SS'.
degreed_completed_timestamp = completed_date.strftime('%Y-%m-%dT%H:%M:%S') if isinstance(
completed_date, datetime
Expand All @@ -54,6 +55,7 @@ def get_learner_data_records(
completed_timestamp=completed_date,
degreed_completed_timestamp=degreed_completed_timestamp,
course_completed=course_completed,
grade=percent_grade,
enterprise_customer_uuid=enterprise_enrollment.enterprise_customer_user.enterprise_customer.uuid,
plugin_configuration_id=self.enterprise_configuration.id,
),
Expand All @@ -65,6 +67,7 @@ def get_learner_data_records(
completed_timestamp=completed_date,
degreed_completed_timestamp=degreed_completed_timestamp,
course_completed=course_completed,
grade=percent_grade,
enterprise_customer_uuid=enterprise_enrollment.enterprise_customer_user.enterprise_customer.uuid,
plugin_configuration_id=self.enterprise_configuration.id,
)
Expand Down
1 change: 1 addition & 0 deletions integrated_channels/degreed2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def serialize(self, *args, **kwargs):
"content-id-type": "externalId",
"content-type": "course",
"completed-at": self.degreed_completed_timestamp,
"percentile": self.grade,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def test_create_course_completion(self):
"content-id-type": "externalId",
"content-type": "course",
"completed-at": NOW_TIMESTAMP_FORMATTED,
"percentile": 80,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def setUp(self):
super().setUp()

@ddt.data(
(None,),
(NOW,),
(None, None,),
(NOW, .83),
)
@ddt.unpack
@freeze_time(NOW)
def test_get_learner_data_record(self, completed_date):
def test_get_learner_data_record(self, completed_date, grade_percent):
"""
The base ``get_learner_data_record`` method returns a ``LearnerDataTransmissionAudit`` with appropriate values.
"""
Expand All @@ -80,6 +80,7 @@ def test_get_learner_data_record(self, completed_date):
learner_data_records = exporter.get_learner_data_records(
enterprise_course_enrollment,
completed_date=completed_date,
grade_percent=grade_percent,
)
assert len(learner_data_records) == 2
assert learner_data_records[0].course_id == self.course_key
Expand All @@ -91,6 +92,7 @@ def test_get_learner_data_record(self, completed_date):
assert learner_data_record.degreed_completed_timestamp == (
self.NOW.strftime('%Y-%m-%dT%H:%M:%S') if completed_date is not None else None
)
assert learner_data_record.grade == (grade_percent * 100 if grade_percent else None)

def test_no_remote_id(self):
"""
Expand Down

0 comments on commit 514f898

Please sign in to comment.