Skip to content

Commit

Permalink
feat: include owners and longer descriptions for degreed2 content met…
Browse files Browse the repository at this point in the history
…adata transmissions (openedx#1736)
  • Loading branch information
bcitro authored Apr 11, 2023
1 parent b5a8dc7 commit 68f55aa
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 13 deletions.
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.61.11]
---------
feat: include owners and longer descriptions for degreed2 content metadata transmissions

[3.61.10]
---------
feat: new tagging orphaned content tast for integrated channels
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.61.10"
__version__ = "3.61.11"

default_app_config = "enterprise.apps.EnterpriseConfig"
28 changes: 21 additions & 7 deletions integrated_channels/degreed2/exporters/content_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Degreed2ContentMetadataExporter(ContentMetadataExporter):
CHUNK_PAGE_LENGTH = 1000
SHORT_STRING_LIMIT = 255
LONG_STRING_LIMIT = 2000
ELLIPSIS = '...'

DATA_TRANSFORM_MAPPING = {
'title': 'title',
Expand Down Expand Up @@ -84,19 +85,32 @@ def transform_description(self, content_metadata_item):
Return the transformed version of the course description.
We choose one value out of the course's full description, short description, and title
depending on availability and length limits.
depending on availability.
"""
course_runs = content_metadata_item.get('course_runs')

duration_info = get_course_run_duration_info(
get_closest_course_run(course_runs)
) if course_runs else ''
full_description = content_metadata_item.get('full_description') or ''
if full_description and 0 < len(full_description + duration_info) <= self.LONG_STRING_LIMIT:
description = full_description
else:
description = content_metadata_item.get('short_description') or content_metadata_item.get('title') or ''

owner_names = ''
owners = content_metadata_item.get('owners')
if owners:
owner_names = ', '.join([owner['name'] for owner in owners])
if owner_names:
owner_names = "[{}]: ".format(owner_names)

description = (
content_metadata_item.get('full_description')
or content_metadata_item.get('short_description')
or content_metadata_item.get('title')
or '')

if description:
description = "{duration_info}{description}".format(duration_info=duration_info, description=description)
description = "{}{}{}".format(owner_names, duration_info, description)
if len(description) > self.LONG_STRING_LIMIT:
description = description[:self.LONG_STRING_LIMIT - len(self.ELLIPSIS)] + self.ELLIPSIS

return strip_html_tags(description)

def transform_courserun_content_language(self, content_metadata_item):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,41 @@ def setUp(self):

@ddt.data(
(
# full description under length limit
{
'title': 'edX Demonstration Course',
'short_description': 'Some short description.',
'full_description': 'Detailed description of edx demo course.',
'owners': [
{
'name': 'edX'
}
],
'course_runs': [
{
'start': '2018-02-05T05:00:00Z',
'min_effort': 2,
'max_effort': 4,
'weeks_to_complete': 10
},
{
'start': '2017-02-05T05:00:00Z',
'min_effort': 9,
'max_effort': 10,
'weeks_to_complete': 12
}
]
},
'[edX]: 2-4 hours a week for 10 weeks. Detailed description of edx demo course.',
),
(
# no owners
{
'title': 'edX Demonstration Course',
'short_description': 'Some short description.',
'full_description': 'Detailed description of edx demo course.',
'owners': [],
'course_runs': [
{
'start': '2018-02-05T05:00:00Z',
Expand All @@ -50,13 +81,52 @@ def setUp(self):
}
]
},
'2-4 hours a week for 10 weeks. Detailed description of edx demo course.',
),
(
# multiple owners
{
'title': 'edX Demonstration Course',
'short_description': 'Some short description.',
'full_description': 'Detailed description of edx demo course.',
'owners': [
{
'name': 'edX'
},
{
'name': 'MIT'
}
],
'course_runs': [
{
'start': '2018-02-05T05:00:00Z',
'min_effort': 2,
'max_effort': 4,
'weeks_to_complete': 10
},
{
'start': '2017-02-05T05:00:00Z',
'min_effort': 9,
'max_effort': 10,
'weeks_to_complete': 12
}
]
},
'[edX, MIT]: 2-4 hours a week for 10 weeks. Detailed description of edx demo course.',
),
(
# empty full description
{
'title': 'edX Demonstration Course',
'short_description': 'Some short description.',
'full_description': '',
'owners': [
{
'name': 'edX'
}
],
'course_runs': [
{
'start': '2018-02-05T05:00:00Z',
Expand All @@ -66,13 +136,19 @@ def setUp(self):
}
]
},
'2-4 hours a week for 10 weeks. Some short description.',
'[edX]: 2-4 hours a week for 10 weeks. Some short description.',
),
(
# empty full and short description
{
'title': 'edX Demonstration Course',
'short_description': '',
'full_description': '',
'owners': [
{
'name': 'edX'
}
],
'course_runs': [
{
'start': '2018-02-05T05:00:00Z',
Expand All @@ -82,13 +158,19 @@ def setUp(self):
}
]
},
'2-4 hours a week for 10 weeks. edX Demonstration Course',
'[edX]: 2-4 hours a week for 10 weeks. edX Demonstration Course',
),
(
# empty everything
{
'title': '',
'short_description': '',
'full_description': '',
'owners': [
{
'name': 'edX'
}
],
'course_runs': [
{
'start': '2018-02-05T05:00:00Z',
Expand All @@ -101,15 +183,43 @@ def setUp(self):
'',
),
(
# full_description over limit, with tags
{
'title': '',
'short_description': '',
'full_description': '<p>This course is part of the '
'full_description': '<p>This description is very long and over the long string limit. This course is '
'part of the '
'<a href=\"../../../../microsoft-professional-program-certficate-data-science\">'
'<em>&#8804;Professional Program Certificate in Data Science</em></a>'
'&nbsp;That doesn&rsquo;t<em> '
'only teach us how to build a cloud data science solution using Microsoft Azure '
'Machine Learning platform',
'Machine Learning platform'
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel blandit est. '
'Sed a justo maximus, hendrerit tortor quis, dictum purus. Morbi rutrum vitae '
'neque at suscipit. Vestibulum sollicitudin porttitor neque sit amet sodales. '
'Integer egestas elit sagittis interdum euismod. Maecenas tincidunt, urna ut '
'vehicula egestas, urna nisl ultricies felis, sed dignissim orci nisl vel turpis. '
'Vivamus efficitur tempus auctor. Nunc mattis, nisi quis gravida vehicula,'
'massa nisi gravida sapien, vitae interdum sapien erat nec eros. Proin augue elit,'
'placerat quis sapien eu, gravida auctor orci. Phasellus et mollis neque, congue'
'tempor ipsum. Morbi dignissim venenatis est. Integer lobortis massa vel aliquet'
'aliquam. Fusce a lectus mi. Vivamus non commodo libero. Sed bibendum commodo ex'
'sodales facilisis. Aliquam ac euismod elit, a fringilla enim. Suspendisse ante'
'erat, malesuada non libero ut, iaculis fermentum nisl. Proin non quam in risus'
'feugiat facilisis. Pellentesque habitant morbi tristique senectus et netus et'
'malesuada fames ac turpis egestas. Nulla ac leo massa. Nulla faucibus diam quis'
'arcu euismod, vel volutpat nulla blandit. In vel consectetur ipsum, in congue'
'nibh. Mauris fringilla commodo justo. Nullam et placerat velit. Sed in commodo'
'sapien. Nam non risus congue, rhoncus neque ac, facilisis tortor. Aenean nulla'
'lacus, pharetra non felis porttitor, scelerisque sagittis magna. Cras tristique,'
'ante a ultricies gravida, purus orci pulvinar nisi, quis fermentum libero metus'
'nec mauris. Praesent lectus lectus, condimentum eget augue nec, volutpat rutrum'
'lacus. Vivamus eget tincidunto',
'owners': [
{
'name': 'edX'
}
],
'course_runs': [
{
'start': '2018-02-05T05:00:00Z',
Expand All @@ -120,9 +230,31 @@ def setUp(self):
]
},
'2-4 hours a week for 10 weeks. '
'[edX]: 2-4 hours a week for 10 weeks. '
'This description is very long and over the long string limit. '
'This course is part of the Professional Program Certificate in Data ScienceThat doesnt '
'only teach us how to build a cloud data science solution using Microsoft Azure Machine Learning platform'
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel blandit est. '
'Sed a justo maximus, hendrerit tortor quis, dictum purus. Morbi rutrum vitae '
'neque at suscipit. Vestibulum sollicitudin porttitor neque sit amet sodales. '
'Integer egestas elit sagittis interdum euismod. Maecenas tincidunt, urna ut '
'vehicula egestas, urna nisl ultricies felis, sed dignissim orci nisl vel turpis. '
'Vivamus efficitur tempus auctor. Nunc mattis, nisi quis gravida vehicula,'
'massa nisi gravida sapien, vitae interdum sapien erat nec eros. Proin augue elit,'
'placerat quis sapien eu, gravida auctor orci. Phasellus et mollis neque, congue'
'tempor ipsum. Morbi dignissim venenatis est. Integer lobortis massa vel aliquet'
'aliquam. Fusce a lectus mi. Vivamus non commodo libero. Sed bibendum commodo ex'
'sodales facilisis. Aliquam ac euismod elit, a fringilla enim. Suspendisse ante'
'erat, malesuada non libero ut, iaculis fermentum nisl. Proin non quam in risus'
'feugiat facilisis. Pellentesque habitant morbi tristique senectus et netus et'
'malesuada fames ac turpis egestas. Nulla ac leo massa. Nulla faucibus diam quis'
'arcu euismod, vel volutpat nulla blandit. In vel consectetur ipsum, in congue'
'nibh. Mauris fringilla commodo justo. Nullam et placerat velit. Sed in commodo'
'sapien. Nam non risus congue, rhoncus neque ac, facilisis tortor. Aenean nulla'
'lacus, pharetra non felis porttitor, scelerisque sagittis magna. Cras tristique,'
'ante a ultricies gravida, purus orci pulvinar nisi, quis fermentum libero metus'
'nec mauris. Praesent lectus lectus, condimentum eget augue nec, volutpat rutrum'
'lacus. Vivamus eget tinci...'
),
)
@responses.activate
Expand Down

0 comments on commit 68f55aa

Please sign in to comment.