Commit 98e647fa by Nimisha Asthagiri

Schedule-based Highlights email update

parent 81461610
...@@ -27,6 +27,9 @@ def course_has_highlights(course_key): ...@@ -27,6 +27,9 @@ def course_has_highlights(course_key):
def get_week_highlights(user, course_key, week_num): def get_week_highlights(user, course_key, week_num):
""" """
Get highlights (list of unicode strings) for a given week. Get highlights (list of unicode strings) for a given week.
week_num starts at 1.
Raises CourseUpdateDoesNotExist if highlights do not exist for
the requested week_num.
""" """
if not COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_key): if not COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_key):
raise CourseUpdateDoesNotExist( raise CourseUpdateDoesNotExist(
...@@ -75,12 +78,12 @@ def _get_sections_with_highlights(course_module): ...@@ -75,12 +78,12 @@ def _get_sections_with_highlights(course_module):
def _get_highlights_for_week(sections, week_num, course_key): def _get_highlights_for_week(sections, week_num, course_key):
# assume each provided section maps to a single week # assume each provided section maps to a single week
num_sections = len(sections) num_sections = len(sections)
if not (0 <= week_num < num_sections): if not (1 <= week_num <= num_sections):
raise CourseUpdateDoesNotExist( raise CourseUpdateDoesNotExist(
"Requested week {} but {} has only {} sections.".format( "Requested week {} but {} has only {} sections.".format(
week_num + 1, course_key, num_sections week_num, course_key, num_sections
) )
) )
section = sections[week_num] section = sections[week_num - 1]
return section.highlights return section.highlights
{% load i18n %} {% load i18n %}
{% if show_upsell %} {% if show_upsell %}
{% blocktrans trimmed %} {% blocktrans trimmed %}
Don't miss the opportunity to highlight your new knowledge and skills by earning a verified Don't miss the opportunity to highlight your new knowledge and skills by earning a verified
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
{% block preview_text %} {% block preview_text %}
{% blocktrans trimmed %} {% blocktrans trimmed %}
Welcome to week {{ week_num }} of our {{ course_name }} course! Welcome to week {{ week_num }} of {{ course_name }}!
{% endblocktrans %} {% endblocktrans %}
{% endblock %} {% endblock %}
...@@ -14,18 +14,21 @@ ...@@ -14,18 +14,21 @@
<td> <td>
<p> <p>
{% blocktrans trimmed %} {% blocktrans trimmed %}
Welcome to week {{ week_num }} of <strong>{{ course_name }}</strong>! We hope you're enjoying <strong>{{ course_name }}</strong>!
We want to let you know what you can look forward to in week {{ week_num }}:
{% endblocktrans %} {% endblocktrans %}
<ul>
{% for highlight in week_highlights %}
<li>{{ highlight }}</li>
{% endfor %}
</ul>
</p> </p>
<p> <p>
{% blocktrans trimmed %} {% blocktrans trimmed %}
Here is what you can look forward to learning this week: With self-paced courses, you learn on your own schedule.
We encourage you to spend time with the course each week.
Your focused attention will pay off in the end!
{% endblocktrans %} {% endblocktrans %}
<ul>
{% for highlight in week_highlights %}
<li>{{ highlight }}</li>
{% endfor %}
</ul>
</p> </p>
{% trans "Resume your course now" as course_cta_text %} {% trans "Resume your course now" as course_cta_text %}
......
{% load i18n %} {% load i18n %}
{% blocktrans trimmed %} {% blocktrans trimmed %}
Welcome to week {{ week_num }} of our {{ course_name }} course! We hope you're enjoying {{ course_name }}!
We want to let you know what you can look forward to in week {{ week_num }}:
Here is what you can look forward to learning this week:
{% endblocktrans %} {% endblocktrans %}
{% for highlight in week_highlights %} {% for highlight in week_highlights %}
* {{ highlight }} * {{ highlight }}
{% endfor %} {% endfor %}
{% blocktrans trimmed %}
With self-paced courses, you learn on your own schedule. We encourage you to spend time with the course each week.
Your focused attention will pay off in the end!
{% endblocktrans %}
{% include "schedules/edx_ace/common/upsell_cta.txt"%} {% include "schedules/edx_ace/common/upsell_cta.txt"%}
{% load i18n %} {% load i18n %}
{% blocktrans %}{{ course_name }} - Welcome to Week {{ week_num }} {% endblocktrans %} {% blocktrans %}Welcome to week {{ week_num }} {% endblocktrans %}
...@@ -12,5 +12,4 @@ ...@@ -12,5 +12,4 @@
{% endblocktrans %} {% endblocktrans %}
{% trans "Keep learning" %} <{{course_url}}> {% trans "Keep learning" %} <{{course_url}}>
{% endif %} {% endif %}
{% include "schedules/edx_ace/common/upsell_cta.txt"%} {% include "schedules/edx_ace/common/upsell_cta.txt"%}
...@@ -15,5 +15,4 @@ ...@@ -15,5 +15,4 @@
{% trans "Start learning now" %} <{{ course_url }}> {% trans "Start learning now" %} <{{ course_url }}>
{% endif %} {% endif %}
{% include "schedules/edx_ace/common/upsell_cta.txt"%} {% include "schedules/edx_ace/common/upsell_cta.txt"%}
...@@ -39,12 +39,12 @@ class TestContentHighlights(ModuleStoreTestCase): ...@@ -39,12 +39,12 @@ class TestContentHighlights(ModuleStoreTestCase):
def test_non_existent_course_raises_exception(self): def test_non_existent_course_raises_exception(self):
nonexistent_course_key = self.course_key.replace(run='no_such_run') nonexistent_course_key = self.course_key.replace(run='no_such_run')
with self.assertRaises(CourseUpdateDoesNotExist): with self.assertRaises(CourseUpdateDoesNotExist):
get_week_highlights(self.user, nonexistent_course_key, 0) get_week_highlights(self.user, nonexistent_course_key, week_num=1)
@override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True) @override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True)
def test_empty_course_raises_exception(self): def test_empty_course_raises_exception(self):
with self.assertRaises(CourseUpdateDoesNotExist): with self.assertRaises(CourseUpdateDoesNotExist):
get_week_highlights(self.user, self.course_key, 0) get_week_highlights(self.user, self.course_key, week_num=1)
@override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, False) @override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, False)
def test_flag_disabled(self): def test_flag_disabled(self):
...@@ -53,7 +53,7 @@ class TestContentHighlights(ModuleStoreTestCase): ...@@ -53,7 +53,7 @@ class TestContentHighlights(ModuleStoreTestCase):
self.assertFalse(course_has_highlights(self.course_key)) self.assertFalse(course_has_highlights(self.course_key))
with self.assertRaises(CourseUpdateDoesNotExist): with self.assertRaises(CourseUpdateDoesNotExist):
get_week_highlights(self.user, self.course_key, week_num=0) get_week_highlights(self.user, self.course_key, week_num=1)
@override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True) @override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True)
def test_flag_enabled(self): def test_flag_enabled(self):
...@@ -62,7 +62,7 @@ class TestContentHighlights(ModuleStoreTestCase): ...@@ -62,7 +62,7 @@ class TestContentHighlights(ModuleStoreTestCase):
self._create_chapter(highlights=highlights) self._create_chapter(highlights=highlights)
self.assertTrue(course_has_highlights(self.course_key)) self.assertTrue(course_has_highlights(self.course_key))
self.assertEqual( self.assertEqual(
get_week_highlights(self.user, self.course_key, week_num=0), get_week_highlights(self.user, self.course_key, week_num=1),
highlights, highlights,
) )
...@@ -77,7 +77,7 @@ class TestContentHighlights(ModuleStoreTestCase): ...@@ -77,7 +77,7 @@ class TestContentHighlights(ModuleStoreTestCase):
self.assertFalse(course_has_highlights(self.course_key)) self.assertFalse(course_has_highlights(self.course_key))
with self.assertRaises(CourseUpdateDoesNotExist): with self.assertRaises(CourseUpdateDoesNotExist):
get_week_highlights(self.user, self.course_key, week_num=0) get_week_highlights(self.user, self.course_key, week_num=1)
@override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True) @override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True)
def test_course_with_highlights(self): def test_course_with_highlights(self):
...@@ -89,15 +89,15 @@ class TestContentHighlights(ModuleStoreTestCase): ...@@ -89,15 +89,15 @@ class TestContentHighlights(ModuleStoreTestCase):
self.assertTrue(course_has_highlights(self.course_key)) self.assertTrue(course_has_highlights(self.course_key))
self.assertEqual( self.assertEqual(
get_week_highlights(self.user, self.course_key, week_num=0), get_week_highlights(self.user, self.course_key, week_num=1),
[u'a', u'b', u'á'], [u'a', u'b', u'á'],
) )
self.assertEqual( self.assertEqual(
get_week_highlights(self.user, self.course_key, week_num=1), get_week_highlights(self.user, self.course_key, week_num=2),
[u'skipped a week'], [u'skipped a week'],
) )
with self.assertRaises(CourseUpdateDoesNotExist): with self.assertRaises(CourseUpdateDoesNotExist):
get_week_highlights(self.user, self.course_key, week_num=2) get_week_highlights(self.user, self.course_key, week_num=3)
@override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True) @override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True)
def test_staff_only(self): def test_staff_only(self):
...@@ -109,4 +109,4 @@ class TestContentHighlights(ModuleStoreTestCase): ...@@ -109,4 +109,4 @@ class TestContentHighlights(ModuleStoreTestCase):
self.assertTrue(course_has_highlights(self.course_key)) self.assertTrue(course_has_highlights(self.course_key))
with self.assertRaises(CourseUpdateDoesNotExist): with self.assertRaises(CourseUpdateDoesNotExist):
get_week_highlights(self.user, self.course_key, week_num=0) get_week_highlights(self.user, self.course_key, week_num=1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment