-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WL-1939 | Transmitting the learner data to CSOD.
Refined user completion status transmission to cornerstone Further refinements Improved base auth generation to take care of unicode chars refined progress post call code lowercase for status key Fixed broken unit tests Passing list of JSON data Updated change log and version Fixed broken unit test
- Loading branch information
1 parent
3c7683c
commit 71d2cde
Showing
11 changed files
with
398 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Learner data exporter for Enterprise Integrated Channel Cornerstone. | ||
""" | ||
|
||
|
||
from __future__ import absolute_import, unicode_literals | ||
|
||
from logging import getLogger | ||
|
||
from django.apps import apps | ||
|
||
from enterprise.api_client.discovery import get_course_catalog_api_service_client | ||
from integrated_channels.integrated_channel.exporters.learner_data import LearnerExporter | ||
|
||
LOGGER = getLogger(__name__) | ||
|
||
|
||
class CornerstoneLearnerExporter(LearnerExporter): | ||
""" | ||
Class to provide a Cornerstone learner data transmission audit prepared for serialization. | ||
""" | ||
|
||
def get_learner_data_records(self, enterprise_enrollment, completed_date=None, grade=None, is_passing=False): | ||
""" | ||
Return a CornerstoneLearnerDataTransmissionAudit with the given enrollment and course completion data. | ||
If completed_date is None, then course completion has not been met. | ||
CornerstoneLearnerDataTransmissionAudit object should exit already if not then return None. | ||
""" | ||
course_completed = False | ||
if completed_date is not None: | ||
course_completed = True | ||
|
||
CornerstoneLearnerDataTransmissionAudit = apps.get_model( # pylint: disable=invalid-name | ||
'cornerstone', | ||
'CornerstoneLearnerDataTransmissionAudit' | ||
) | ||
|
||
course_catalog_client = get_course_catalog_api_service_client( | ||
site=enterprise_enrollment.enterprise_customer_user.enterprise_customer.site | ||
) | ||
try: | ||
csod_learner_data_transmission = CornerstoneLearnerDataTransmissionAudit.objects.get( | ||
user_id=enterprise_enrollment.enterprise_customer_user.user.id, | ||
course_id=course_catalog_client.get_course_id(enterprise_enrollment.course_id), | ||
) | ||
csod_learner_data_transmission.enterprise_course_enrollment_id = enterprise_enrollment.id | ||
csod_learner_data_transmission.grade = grade | ||
csod_learner_data_transmission.course_completed = course_completed | ||
csod_learner_data_transmission.completed_timestamp = completed_date | ||
return [ | ||
csod_learner_data_transmission | ||
] | ||
except CornerstoneLearnerDataTransmissionAudit.DoesNotExist: | ||
LOGGER.info( | ||
'No learner data was sent for user [%s] because Cornerstone user ID could not be found ' | ||
'for customer [%s]', | ||
enterprise_enrollment.enterprise_customer_user.username, | ||
enterprise_enrollment.enterprise_customer_user.enterprise_customer.name | ||
) |
35 changes: 35 additions & 0 deletions
35
integrated_channels/cornerstone/migrations/0003_auto_20190621_1000.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.21 on 2019-06-21 10:00 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('cornerstone', '0002_cornerstoneglobalconfiguration_subject_mapping'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='cornerstoneglobalconfiguration', | ||
name='key', | ||
field=models.CharField(default='key', help_text='Basic auth username for sending user completion status to cornerstone.', max_length=255, verbose_name='Basic Auth username'), | ||
), | ||
migrations.AddField( | ||
model_name='cornerstoneglobalconfiguration', | ||
name='secret', | ||
field=models.CharField(default='secret', help_text='Basic auth password for sending user completion status to cornerstone.', max_length=255, verbose_name='Basic Auth password'), | ||
), | ||
migrations.AddField( | ||
model_name='cornerstonelearnerdatatransmissionaudit', | ||
name='grade', | ||
field=models.CharField(blank=True, max_length=255, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='cornerstonelearnerdatatransmissionaudit', | ||
name='enterprise_course_enrollment_id', | ||
field=models.PositiveIntegerField(blank=True, db_index=True, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.