Repository: oppia/oppia

Issue:
Add translation for 'lessons' in classroom page
This is a tracking issue to add the word 'lessons', which occurs in the classroom page to translations.
Add translation for 'lessons' in classroom page
This is a tracking issue to add the word 'lessons', which occurs in the classroom page to translations.
Add translation for 'lessons' in classroom page
This is a tracking issue to add the word 'lessons', which occurs in the classroom page to translations.


Discussion:
Hi @aks681 -- just a note, this also applies in general to any English strings in the classroom page. Thanks!
Hi @aks681 -- just a note, this also applies in general to any English strings in the classroom page. Thanks!
Hi @aks681 -- just a note, this also applies in general to any English strings in the classroom page. Thanks!

Resolving patch:
diff --git a/core/domain/prod_validation_jobs_one_off.py b/core/domain/prod_validation_jobs_one_off.py
--- a/core/domain/prod_validation_jobs_one_off.py
+++ b/core/domain/prod_validation_jobs_one_off.py
@@ -3616,16 +3616,17 @@ def _validate_canonical_story_count(cls, item):
             # function.
             if topic_model is None or topic_model.deleted:
                 continue
-            canonical_story_ids = [
+            pubished_canonical_story_ids = [
                 reference['story_id']
-                for reference in topic_model.canonical_story_references]
-            if item.canonical_story_count != len(canonical_story_ids):
+                for reference in topic_model.canonical_story_references
+                if reference['story_is_published']]
+            if item.canonical_story_count != len(pubished_canonical_story_ids):
                 cls.errors['canonical story count check'].append((
                     'Entity id %s: Canonical story count: %s does not '
                     'match the number of story ids in canonical_story_ids in '
                     'topic model: %s') % (
                         item.id, item.canonical_story_count,
-                        canonical_story_ids))
+                        pubished_canonical_story_ids))
 
     @classmethod
     def _validate_additional_story_count(cls, item):
@@ -3645,16 +3646,19 @@ def _validate_additional_story_count(cls, item):
             # function.
             if topic_model is None or topic_model.deleted:
                 continue
-            additional_story_ids = [
+            published_additional_story_ids = [
                 reference['story_id']
-                for reference in topic_model.additional_story_references]
-            if item.additional_story_count != len(additional_story_ids):
+                for reference in topic_model.additional_story_references
+                if reference['story_is_published']]
+            if (
+                    item.additional_story_count !=
+                    len(published_additional_story_ids)):
                 cls.errors['additional story count check'].append((
                     'Entity id %s: Additional story count: %s does not '
                     'match the number of story ids in additional_story_ids in '
                     'topic model: %s') % (
                         item.id, item.additional_story_count,
-                        additional_story_ids))
+                        published_additional_story_ids))
 
     @classmethod
     def _validate_uncategorized_skill_count(cls, item):
diff --git a/core/domain/topic_services.py b/core/domain/topic_services.py
--- a/core/domain/topic_services.py
+++ b/core/domain/topic_services.py
@@ -177,7 +177,7 @@ def _create_topic(committer_id, topic, commit_message, commit_cmds):
     commit_cmd_dicts = [commit_cmd.to_dict() for commit_cmd in commit_cmds]
     model.commit(committer_id, commit_message, commit_cmd_dicts)
     topic.version += 1
-    create_topic_summary(topic.id)
+    generate_topic_summary(topic.id)
 
 
 def save_new_topic(committer_id, topic):
@@ -463,7 +463,7 @@ def update_topic_and_subtopic_pages(
             subtopic_page_services.save_subtopic_page(
                 committer_id, subtopic_page, commit_message,
                 subtopic_page_change_list)
-    create_topic_summary(topic_id)
+    generate_topic_summary(topic_id)
 
     if old_topic.name != updated_topic.name:
         opportunity_services.update_opportunities_with_new_topic_name(
@@ -574,6 +574,7 @@ def _are_nodes_valid_for_publishing(story_nodes):
     _save_topic(
         committer_id, topic, 'Published story with id %s' % story_id,
         change_list)
+    generate_topic_summary(topic.id)
 
 
 def unpublish_story(topic_id, story_id, committer_id):
@@ -607,6 +608,7 @@ def unpublish_story(topic_id, story_id, committer_id):
     _save_topic(
         committer_id, topic, 'Unpublished story with id %s' % story_id,
         change_list)
+    generate_topic_summary(topic.id)
 
 
 def delete_canonical_story(user_id, topic_id, story_id):
@@ -734,7 +736,7 @@ def delete_topic_summary(topic_id):
     topic_models.TopicSummaryModel.get(topic_id).delete()
 
 
-def create_topic_summary(topic_id):
+def generate_topic_summary(topic_id):
     """Creates and stores a summary of the given topic.
 
     Args:
@@ -755,8 +757,16 @@ def compute_summary_of_topic(topic):
     Returns:
         TopicSummary. The computed summary for the given topic.
     """
-    topic_model_canonical_story_count = len(topic.canonical_story_references)
-    topic_model_additional_story_count = len(topic.additional_story_references)
+    canonical_story_count = 0
+    additional_story_count = 0
+    for reference in topic.canonical_story_references:
+        if reference.story_is_published:
+            canonical_story_count += 1
+    for reference in topic.additional_story_references:
+        if reference.story_is_published:
+            additional_story_count += 1
+    topic_model_canonical_story_count = canonical_story_count
+    topic_model_additional_story_count = additional_story_count
     topic_model_uncategorized_skill_count = len(topic.uncategorized_skill_ids)
     topic_model_subtopic_count = len(topic.subtopics)
 


Test patch:
diff --git a/core/domain/prod_validation_jobs_one_off_test.py b/core/domain/prod_validation_jobs_one_off_test.py
--- a/core/domain/prod_validation_jobs_one_off_test.py
+++ b/core/domain/prod_validation_jobs_one_off_test.py
@@ -11881,6 +11881,10 @@ def setUp(self):
             topic.add_uncategorized_skill_id('%s' % (index * 3 + 1))
             topic.add_uncategorized_skill_id('%s' % (index * 3 + 2))
             topic_services.save_new_topic(self.owner_id, topic)
+            topic_services.publish_story(
+                topic.id, '%s' % (index * 2 + 1), self.admin_id)
+            topic_services.publish_story(
+                topic.id, '%s' % (index * 2), self.admin_id)
             topic_services.update_topic_and_subtopic_pages(
                 self.owner_id, '%s' % index, [topic_domain.TopicChange({
                     'cmd': 'add_subtopic',
diff --git a/core/domain/topic_services_test.py b/core/domain/topic_services_test.py
--- a/core/domain/topic_services_test.py
+++ b/core/domain/topic_services_test.py
@@ -86,8 +86,8 @@ def test_compute_summary(self):
 
         self.assertEqual(topic_summary.id, self.TOPIC_ID)
         self.assertEqual(topic_summary.name, 'Name')
-        self.assertEqual(topic_summary.canonical_story_count, 2)
-        self.assertEqual(topic_summary.additional_story_count, 1)
+        self.assertEqual(topic_summary.canonical_story_count, 0)
+        self.assertEqual(topic_summary.additional_story_count, 0)
         self.assertEqual(topic_summary.uncategorized_skill_count, 2)
         self.assertEqual(topic_summary.subtopic_count, 1)
         self.assertEqual(topic_summary.total_skill_count, 2)
@@ -97,8 +97,8 @@ def test_get_all_summaries(self):
 
         self.assertEqual(len(topic_summaries), 1)
         self.assertEqual(topic_summaries[0].name, 'Name')
-        self.assertEqual(topic_summaries[0].canonical_story_count, 2)
-        self.assertEqual(topic_summaries[0].additional_story_count, 1)
+        self.assertEqual(topic_summaries[0].canonical_story_count, 0)
+        self.assertEqual(topic_summaries[0].additional_story_count, 0)
         self.assertEqual(topic_summaries[0].total_skill_count, 2)
         self.assertEqual(topic_summaries[0].uncategorized_skill_count, 2)
         self.assertEqual(topic_summaries[0].subtopic_count, 1)
@@ -109,8 +109,8 @@ def test_get_multi_summaries(self):
 
         self.assertEqual(len(topic_summaries), 2)
         self.assertEqual(topic_summaries[0].name, 'Name')
-        self.assertEqual(topic_summaries[0].canonical_story_count, 2)
-        self.assertEqual(topic_summaries[0].additional_story_count, 1)
+        self.assertEqual(topic_summaries[0].canonical_story_count, 0)
+        self.assertEqual(topic_summaries[0].additional_story_count, 0)
         self.assertEqual(topic_summaries[0].total_skill_count, 2)
         self.assertEqual(topic_summaries[0].uncategorized_skill_count, 2)
         self.assertEqual(topic_summaries[0].subtopic_count, 1)
@@ -196,8 +196,8 @@ def test_get_topic_summary_from_model(self):
 
         self.assertEqual(topic_summary.id, self.TOPIC_ID)
         self.assertEqual(topic_summary.name, 'Name')
-        self.assertEqual(topic_summary.canonical_story_count, 2)
-        self.assertEqual(topic_summary.additional_story_count, 1)
+        self.assertEqual(topic_summary.canonical_story_count, 0)
+        self.assertEqual(topic_summary.additional_story_count, 0)
         self.assertEqual(topic_summary.uncategorized_skill_count, 2)
         self.assertEqual(topic_summary.total_skill_count, 2)
         self.assertEqual(topic_summary.subtopic_count, 1)
@@ -207,8 +207,8 @@ def test_get_topic_summary_by_id(self):
 
         self.assertEqual(topic_summary.id, self.TOPIC_ID)
         self.assertEqual(topic_summary.name, 'Name')
-        self.assertEqual(topic_summary.canonical_story_count, 2)
-        self.assertEqual(topic_summary.additional_story_count, 1)
+        self.assertEqual(topic_summary.canonical_story_count, 0)
+        self.assertEqual(topic_summary.additional_story_count, 0)
         self.assertEqual(topic_summary.uncategorized_skill_count, 2)
         self.assertEqual(topic_summary.subtopic_count, 1)
 
@@ -308,20 +308,26 @@ def test_publish_and_unpublish_story(self):
         topic_services.publish_story(
             self.TOPIC_ID, self.story_id_3, self.user_id_admin)
         topic = topic_fetchers.get_topic_by_id(self.TOPIC_ID)
+        topic_summary = topic_services.get_topic_summary_by_id(self.TOPIC_ID)
         self.assertEqual(
             topic.canonical_story_references[0].story_is_published, True)
         self.assertEqual(
             topic.additional_story_references[0].story_is_published, True)
+        self.assertEqual(topic_summary.canonical_story_count, 1)
+        self.assertEqual(topic_summary.additional_story_count, 1)
 
         topic_services.unpublish_story(
             self.TOPIC_ID, self.story_id_1, self.user_id_admin)
         topic_services.unpublish_story(
             self.TOPIC_ID, self.story_id_3, self.user_id_admin)
         topic = topic_fetchers.get_topic_by_id(self.TOPIC_ID)
+        topic_summary = topic_services.get_topic_summary_by_id(self.TOPIC_ID)
         self.assertEqual(
             topic.canonical_story_references[0].story_is_published, False)
         self.assertEqual(
             topic.additional_story_references[0].story_is_published, False)
+        self.assertEqual(topic_summary.canonical_story_count, 0)
+        self.assertEqual(topic_summary.additional_story_count, 0)
 
     def test_invalid_publish_and_unpublish_story(self):
         with self.assertRaisesRegexp(