Repository: oppia/oppia

Issue:
Feedback emails should include a direct link to the exploration feedback tab.
I recently got this email from Oppia (which was nice :smile: ):

---

![email](https://cloud.githubusercontent.com/assets/10575562/23014600/7d3e7054-f3e4-11e6-94f8-1e0dfafeea13.png)

---

However, I haven't acted on it yet. This is because it's cognitively rather burdensome to click to the dashboard, find the exploration in the list, click to the exploration, click to the feedback tab, and _finally_ address the feedback. It would be nicer if there was a direct link I could go to that takes me to the feedback tab of each exploration, so that I could click on the message and respond to it.

/cc @prasanna08 
(Also /cc @jaredsilver @jblair87: do you have any suggestions for improving the text of this email? I think there's probably room for improvement here but I'm not sure what it is.)


Discussion:

Resolving patch:
diff --git a/core/domain/email_manager.py b/core/domain/email_manager.py
--- a/core/domain/email_manager.py
+++ b/core/domain/email_manager.py
@@ -615,10 +615,8 @@ def send_feedback_message_email(recipient_id, feedback_messages):
                 }
             }
     """
-
-    email_subject = (
-        'You\'ve received %s new message%s on your explorations' %
-        (len(feedback_messages), 's' if len(feedback_messages) > 1 else ''))
+    email_subject_template = (
+        'You\'ve received %s new message%s on your explorations')
 
     email_body_template = (
         'Hi %s,<br>'
@@ -628,7 +626,7 @@ def send_feedback_message_email(recipient_id, feedback_messages):
         'You can view and reply to your messages from your '
         '<a href="https://www.oppia.org/dashboard">dashboard</a>.'
         '<br>'
-        'Thanks, and happy teaching!<br>'
+        '<br>Thanks, and happy teaching!<br>'
         '<br>'
         'Best wishes,<br>'
         'The Oppia Team<br>'
@@ -648,15 +646,23 @@ def send_feedback_message_email(recipient_id, feedback_messages):
     recipient_user_settings = user_services.get_user_settings(recipient_id)
 
     messages_html = ''
-    for _, reference in feedback_messages.iteritems():
+    count_messages = 0
+    for exp_id, reference in feedback_messages.iteritems():
+        messages_html += (
+            '<li><a href="https://www.oppia.org/create/%s#/feedback">'
+            '%s</a>:<br><ul>' % (exp_id, reference['title']))
         for message in reference['messages']:
-            messages_html += (
-                '<li>%s: %s<br></li>' % (reference['title'], message))
+            messages_html += ('<li>%s<br></li>' % message)
+            count_messages += 1
+        messages_html += '</ul></li>'
+
+    email_subject = email_subject_template % (
+        (count_messages, 's') if count_messages > 1 else ('a', ''))
 
     email_body = email_body_template % (
-        recipient_user_settings.username, len(feedback_messages),
-        's' if len(feedback_messages) > 1 else '',
-        messages_html, EMAIL_FOOTER.value)
+        recipient_user_settings.username, count_messages if count_messages > 1
+        else 'a', 's' if count_messages > 1 else '', messages_html,
+        EMAIL_FOOTER.value)
 
     _send_email(
         recipient_id, feconf.SYSTEM_COMMITTER_ID,


Test patch:
diff --git a/core/domain/email_manager_test.py b/core/domain/email_manager_test.py
--- a/core/domain/email_manager_test.py
+++ b/core/domain/email_manager_test.py
@@ -1087,7 +1087,7 @@ def setUp(self):
             'A', self.editor_id, 'Title')
 
         self.expected_email_subject = (
-            'You\'ve received 1 new message on your explorations')
+            'You\'ve received 3 new messages on your explorations')
 
         self.can_send_emails_ctx = self.swap(
             feconf, 'CAN_SEND_EMAILS', True)
@@ -1098,12 +1098,18 @@ def test_correct_email_body_is_sent(self):
         expected_email_html_body = (
             'Hi editor,<br>'
             '<br>'
-            'You\'ve received 1 new message on your Oppia explorations:<br>'
-            '<ul><li>Title: A message<br></li></ul>'
+            'You\'ve received 3 new messages on your Oppia explorations:<br>'
+            '<ul>'
+            '<li><a href="https://www.oppia.org/create/A#/feedback">Title</a>:'
+            '<br>'
+            '<ul><li>Message 1.1<br></li>'
+            '<li>Message 1.2<br></li>'
+            '<li>Message 1.3<br></li>'
+            '</ul></li></ul>'
             'You can view and reply to your messages from your '
             '<a href="https://www.oppia.org/dashboard">dashboard</a>.'
             '<br>'
-            'Thanks, and happy teaching!<br>'
+            '<br>Thanks, and happy teaching!<br>'
             '<br>'
             'Best wishes,<br>'
             'The Oppia Team<br>'
@@ -1114,9 +1120,12 @@ def test_correct_email_body_is_sent(self):
         expected_email_text_body = (
             'Hi editor,\n'
             '\n'
-            'You\'ve received 1 new message on your Oppia explorations:\n'
-            '- Title: A message\n'
-            'You can view and reply to your messages from your dashboard.'
+            'You\'ve received 3 new messages on your Oppia explorations:\n'
+            '- Title:\n'
+            '- Message 1.1\n'
+            '- Message 1.2\n'
+            '- Message 1.3\n'
+            'You can view and reply to your messages from your dashboard.\n'
             '\n'
             'Thanks, and happy teaching!\n'
             '\n'
@@ -1128,7 +1137,7 @@ def test_correct_email_body_is_sent(self):
         feedback_messages = {
             self.exploration.id : {
                 'title': self.exploration.title,
-                'messages': ['A message']}
+                'messages': ['Message 1.1', 'Message 1.2', 'Message 1.3']}
         }
 
         with self.can_send_emails_ctx, self.can_send_feedback_email_ctx:
diff --git a/core/domain/feedback_services_test.py b/core/domain/feedback_services_test.py
--- a/core/domain/feedback_services_test.py
+++ b/core/domain/feedback_services_test.py
@@ -692,12 +692,16 @@ def test_that_emails_are_sent(self):
         expected_email_html_body = (
             'Hi editor,<br>'
             '<br>'
-            'You\'ve received 1 new message on your Oppia explorations:<br>'
-            '<ul><li>Title: some text<br></li></ul>'
+            'You\'ve received a new message on your Oppia explorations:<br>'
+            '<ul>'
+            '<li><a href="https://www.oppia.org/create/A#/feedback">Title</a>:'
+            '<br>'
+            '<ul><li>some text<br></li>'
+            '</ul></li></ul>'
             'You can view and reply to your messages from your '
             '<a href="https://www.oppia.org/dashboard">dashboard</a>.'
             '<br>'
-            'Thanks, and happy teaching!<br>'
+            '<br>Thanks, and happy teaching!<br>'
             '<br>'
             'Best wishes,<br>'
             'The Oppia Team<br>'
@@ -708,9 +712,10 @@ def test_that_emails_are_sent(self):
         expected_email_text_body = (
             'Hi editor,\n'
             '\n'
-            'You\'ve received 1 new message on your Oppia explorations:\n'
-            '- Title: some text\n'
-            'You can view and reply to your messages from your dashboard.'
+            'You\'ve received a new message on your Oppia explorations:\n'
+            '- Title:\n'
+            '- some text\n'
+            'You can view and reply to your messages from your dashboard.\n'
             '\n'
             'Thanks, and happy teaching!\n'
             '\n'
@@ -747,13 +752,17 @@ def test_that_correct_emails_are_sent_for_multiple_feedback(self):
         expected_email_html_body = (
             'Hi editor,<br>'
             '<br>'
-            'You\'ve received 1 new message on your Oppia explorations:<br>'
-            '<ul><li>Title: some text<br></li>'
-            '<li>Title: more text<br></li></ul>'
+            'You\'ve received 2 new messages on your Oppia explorations:<br>'
+            '<ul>'
+            '<li><a href="https://www.oppia.org/create/A#/feedback">Title</a>:'
+            '<br>'
+            '<ul><li>some text<br></li>'
+            '<li>more text<br></li>'
+            '</ul></li></ul>'
             'You can view and reply to your messages from your '
             '<a href="https://www.oppia.org/dashboard">dashboard</a>.'
             '<br>'
-            'Thanks, and happy teaching!<br>'
+            '<br>Thanks, and happy teaching!<br>'
             '<br>'
             'Best wishes,<br>'
             'The Oppia Team<br>'
@@ -764,10 +773,11 @@ def test_that_correct_emails_are_sent_for_multiple_feedback(self):
         expected_email_text_body = (
             'Hi editor,\n'
             '\n'
-            'You\'ve received 1 new message on your Oppia explorations:\n'
-            '- Title: some text\n'
-            '- Title: more text\n'
-            'You can view and reply to your messages from your dashboard.'
+            'You\'ve received 2 new messages on your Oppia explorations:\n'
+            '- Title:\n'
+            '- some text\n'
+            '- more text\n'
+            'You can view and reply to your messages from your dashboard.\n'
             '\n'
             'Thanks, and happy teaching!\n'
             '\n'