diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0a797f562e..230caa29d6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,10 @@ Unreleased ---------- * nothing +[3.40.12] +--------- +fix: Degreed2 Missing Learner Data Audit Records + [3.40.11] --------- feat: New integrated channels Blackboard api endpoint to fetch global config creds diff --git a/enterprise/__init__.py b/enterprise/__init__.py index 68dd0cbd98..9bb50e4505 100644 --- a/enterprise/__init__.py +++ b/enterprise/__init__.py @@ -2,6 +2,6 @@ Your project description goes here. """ -__version__ = "3.40.11" +__version__ = "3.40.12" default_app_config = "enterprise.apps.EnterpriseConfig" diff --git a/integrated_channels/degreed2/client.py b/integrated_channels/degreed2/client.py index 73891a39a3..47b4a36000 100644 --- a/integrated_channels/degreed2/client.py +++ b/integrated_channels/degreed2/client.py @@ -109,22 +109,11 @@ def create_course_completion(self, user_id, payload): } Returns: status_code, response_text """ - completion_audit_item = json.loads(payload) - json_payload = { - "data": { - "attributes": { - "user-id": user_id, - "user-identifier-type": "Email", - "content-id": completion_audit_item.get('course_id'), - "content-id-type": "externalId", - "content-type": "course", - "completed-at": completion_audit_item.get('completed_timestamp'), - } - } - } + json_payload = json.loads(payload) LOGGER.info(self.make_log_msg( - completion_audit_item.get('course_id'), - f'Attempting find course via url: {self.get_completions_url()}') + json_payload.get('data').get('attributes').get('content-id'), + f'Attempting find course via url: {self.get_completions_url()}'), + user_id ) return self._post( self.get_completions_url(), diff --git a/integrated_channels/degreed2/models.py b/integrated_channels/degreed2/models.py index fe24a9854a..424882c33d 100644 --- a/integrated_channels/degreed2/models.py +++ b/integrated_channels/degreed2/models.py @@ -3,6 +3,7 @@ Database models for Enterprise Integrated Channel Degreed. """ +import json from logging import getLogger from simple_history.models import HistoricalRecords @@ -209,3 +210,26 @@ def __repr__(self): Return uniquely identifying string representation. """ return self.__str__() + + def serialize(self, *args, **kwargs): + """ + Return a JSON-serialized representation. + + Sort the keys so the result is consistent and testable. + + Can take the following keyword arguments: + - `enterprise_configuration` + """ + json_payload = { + "data": { + "attributes": { + "user-id": self.degreed_user_email, + "user-identifier-type": "Email", + "content-id": self.course_id, + "content-id-type": "externalId", + "content-type": "course", + "completed-at": self.completed_timestamp, + } + } + } + return json.dumps(json_payload, sort_keys=True) diff --git a/tests/test_integrated_channels/test_degreed2/test_client.py b/tests/test_integrated_channels/test_degreed2/test_client.py index 7b2a79978b..802878b7b3 100644 --- a/tests/test_integrated_channels/test_degreed2/test_client.py +++ b/tests/test_integrated_channels/test_degreed2/test_client.py @@ -103,13 +103,18 @@ def test_create_course_completion(self): ) payload = { - 'completions': [{ - 'employeeId': 'abc123', - 'id': "course-v1:ColumbiaX+DS101X+1T2016", - 'completionDate': NOW_TIMESTAMP_FORMATTED, - }] + "data": { + "attributes": { + "user-id": 'test-learner@example.com', + "user-identifier-type": "Email", + "content-id": 'DemoX', + "content-id-type": "externalId", + "content-type": "course", + "completed-at": NOW_TIMESTAMP_FORMATTED, + } + } } - output = degreed_api_client.create_course_completion('fake-user', json.dumps(payload)) + output = degreed_api_client.create_course_completion('test-learner@example.com', json.dumps(payload)) assert output == (200, '"{}"') assert len(responses.calls) == 2