Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
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__ = "3.40.11"
__version__ = "3.40.12"

default_app_config = "enterprise.apps.EnterpriseConfig"
19 changes: 4 additions & 15 deletions integrated_channels/degreed2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
24 changes: 24 additions & 0 deletions integrated_channels/degreed2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Database models for Enterprise Integrated Channel Degreed.
"""

import json
from logging import getLogger

from simple_history.models import HistoricalRecords
Expand Down Expand Up @@ -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)
17 changes: 11 additions & 6 deletions tests/test_integrated_channels/test_degreed2/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down