Repository: oppia/oppia

Issue:
Complete the classroom page
The frontend files for the classroom page have already been created. This issue is to track the completion of the classroom page. Pages to be created:

- The main directive for the page (which is empty now), has to be filled.
- The navbar directives have to be created.


Discussion:
For this issue, please also address this residual comment: https://github.com/oppia/oppia/pull/7455#discussion_r319305531

Resolving patch:
diff --git a/core/controllers/classroom.py b/core/controllers/classroom.py
--- a/core/controllers/classroom.py
+++ b/core/controllers/classroom.py
@@ -69,7 +69,11 @@ def get(self, classroom_name):
             raise self.PageNotFoundException
 
         topic_summaries = topic_services.get_multi_topic_summaries(topic_ids)
-        topic_summary_dicts = [summary.to_dict() for summary in topic_summaries]
+        topic_rights = topic_services.get_multi_topic_rights(topic_ids)
+        topic_summary_dicts = [
+            summary.to_dict() for ind, summary in enumerate(topic_summaries)
+            if summary is not None and topic_rights[ind].topic_is_published
+        ]
 
         self.values.update({
             'topic_summary_dicts': topic_summary_dicts
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
@@ -66,9 +66,8 @@ def get_multi_topic_summaries(topic_ids):
     """
     topic_summaries_models = topic_models.TopicSummaryModel.get_multi(topic_ids)
     topic_summaries = [
-        get_topic_summary_from_model(summary)
-        for summary in topic_summaries_models
-        if summary is not None]
+        get_topic_summary_from_model(summary) if summary else None
+        for summary in topic_summaries_models]
     return topic_summaries
 
 
@@ -940,6 +939,24 @@ def get_topic_rights(topic_id, strict=True):
     return get_topic_rights_from_model(model)
 
 
+def get_multi_topic_rights(topic_ids):
+    """Returns the rights of all topics whose topic ids are passed in.
+
+    Args:
+        topic_ids: list(str). The IDs of topics for which rights are to be
+            returned.
+
+    Returns:
+        list(TopicRights). The list of rights of all given topics present in
+            the datastore.
+    """
+    topic_rights_models = topic_models.TopicRightsModel.get_multi(topic_ids)
+    topic_rights = [
+        get_topic_rights_from_model(rights) if rights else None
+        for rights in topic_rights_models]
+    return topic_rights
+
+
 def get_topic_rights_with_user(user_id):
     """Retrieves the rights object for all topics assigned to given user.
 


Test patch:
diff --git a/core/controllers/classroom_test.py b/core/controllers/classroom_test.py
--- a/core/controllers/classroom_test.py
+++ b/core/controllers/classroom_test.py
@@ -16,6 +16,9 @@
 from __future__ import absolute_import  # pylint: disable=import-only-modules
 
 from constants import constants
+from core.domain import config_domain
+from core.domain import topic_domain
+from core.domain import topic_services
 from core.tests import test_utils
 import feconf
 
@@ -54,11 +57,45 @@ def test_get_fails_when_new_structures_not_enabled(self):
 class ClassroomDataHandlerTests(BaseClassroomControllerTests):
 
     def test_get(self):
+        self.signup(self.ADMIN_EMAIL, self.ADMIN_USERNAME)
+        admin_id = self.get_user_id_from_email(self.ADMIN_EMAIL)
+        self.set_admins([self.ADMIN_USERNAME])
+
+        self.login(self.ADMIN_EMAIL, is_super_admin=True)
+        topic_id_1 = topic_services.get_new_topic_id()
+        topic_id_2 = topic_services.get_new_topic_id()
+        private_topic = topic_domain.Topic.create_default_topic(
+            topic_id_1, 'private_topic_name')
+        topic_services.save_new_topic(admin_id, private_topic)
+        public_topic = topic_domain.Topic.create_default_topic(
+            topic_id_2, 'public_topic_name')
+        topic_services.save_new_topic(admin_id, public_topic)
+        topic_services.publish_topic(topic_id_2, admin_id)
+
+        csrf_token = self.get_new_csrf_token()
+        new_config_value = [{
+            'name': 'Math',
+            'topic_ids': [topic_id_1, topic_id_2]
+        }]
+
+        payload = {
+            'action': 'save_config_properties',
+            'new_config_property_values': {
+                config_domain.TOPIC_IDS_FOR_CLASSROOM_PAGES.name: (
+                    new_config_value),
+            }
+        }
+        self.post_json('/adminhandler', payload, csrf_token=csrf_token)
+        self.logout()
+
         with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
             json_response = self.get_json(
                 '%s/%s' % (feconf.CLASSROOM_DATA_HANDLER, 'Math'))
+            topic_summary_dict = (
+                topic_services.get_topic_summary_by_id(topic_id_2).to_dict())
+
             expected_dict = {
-                'topic_summary_dicts': []
+                'topic_summary_dicts': [topic_summary_dict]
             }
             self.assertDictContainsSubset(expected_dict, json_response)
 
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
@@ -106,13 +106,24 @@ def test_get_multi_summaries(self):
         topic_summaries = topic_services.get_multi_topic_summaries([
             self.TOPIC_ID, 'invalid_id'])
 
-        self.assertEqual(len(topic_summaries), 1)
+        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].total_skill_count, 2)
         self.assertEqual(topic_summaries[0].uncategorized_skill_count, 2)
         self.assertEqual(topic_summaries[0].subtopic_count, 1)
+        self.assertIsNone(topic_summaries[1])
+
+    def test_get_multi_rights(self):
+        topic_rights = topic_services.get_multi_topic_rights([
+            self.TOPIC_ID, 'invalid_id'])
+
+        self.assertEqual(len(topic_rights), 2)
+        self.assertEqual(topic_rights[0].id, self.TOPIC_ID)
+        self.assertEqual(topic_rights[0].manager_ids, [])
+        self.assertFalse(topic_rights[0].topic_is_published)
+        self.assertIsNone(topic_rights[1])
 
     def test_get_new_topic_id(self):
         new_topic_id = topic_services.get_new_topic_id()