Repository: oppia/oppia

Issue:
Console errors on chapter creation
**Describe the bug**
When a story chapter is created throught the Add Chapter modal there are console errors after the creation.

**To Reproduce**
Steps to reproduce the behavior:
 1. Create a topic
 2. Create a story
 3. Click '+ ADD CHAPTER' and fill all the fields
 4. See error

**Observed behavior**
The chapter is created with errors.

**Expected behavior**
The chapter should be created without any errors.

**Screenshots**
![image](https://user-images.githubusercontent.com/10142938/89894784-fbad1800-dbda-11ea-89f0-32e35e231e3f.png)

**Additional context**
Add any other context about the problem here.

Console errors on chapter creation
**Describe the bug**
When a story chapter is created throught the Add Chapter modal there are console errors after the creation.

**To Reproduce**
Steps to reproduce the behavior:
 1. Create a topic
 2. Create a story
 3. Click '+ ADD CHAPTER' and fill all the fields
 4. See error

**Observed behavior**
The chapter is created with errors.

**Expected behavior**
The chapter should be created without any errors.

**Screenshots**
![image](https://user-images.githubusercontent.com/10142938/89894784-fbad1800-dbda-11ea-89f0-32e35e231e3f.png)

**Additional context**
Add any other context about the problem here.



Discussion:
@aks681 as the learner and creator experience lead could you make sure blocking bug this gets fixed?
Actually, reassigning to @Showtim3 since they've worked with the editors a lot
I think this is more of a exploration(interaction) bug, rather than the chapter/story editor. @kevintab95 @aks681 Can you guys take this up?
Assigning to @aks681 as lead for the learner and creator experience team. Akshay, can you make sure this blocking bug gets fixed by EOD Thursday, August 20?
@aks681 as the learner and creator experience lead could you make sure blocking bug this gets fixed?
Actually, reassigning to @Showtim3 since they've worked with the editors a lot
I think this is more of a exploration(interaction) bug, rather than the chapter/story editor. @kevintab95 @aks681 Can you guys take this up?
Assigning to @aks681 as lead for the learner and creator experience team. Akshay, can you make sure this blocking bug gets fixed by EOD Thursday, August 20?

Resolving patch:
diff --git a/core/controllers/story_editor.py b/core/controllers/story_editor.py
--- a/core/controllers/story_editor.py
+++ b/core/controllers/story_editor.py
@@ -66,6 +66,11 @@ def get(self, story_id):
         topic_id = story.corresponding_topic_id
         topic = topic_fetchers.get_topic_by_id(topic_id, strict=False)
         skill_ids = topic.get_all_skill_ids()
+        for node in story.story_contents.nodes:
+            for skill_id in node.prerequisite_skill_ids:
+                if skill_id not in skill_ids:
+                    skill_ids.append(skill_id)
+
         skill_summaries = skill_services.get_multi_skill_summaries(skill_ids)
         skill_summary_dicts = [summary.to_dict() for summary in skill_summaries]
         classroom_url_fragment = (


Test patch:
diff --git a/core/controllers/story_editor_test.py b/core/controllers/story_editor_test.py
--- a/core/controllers/story_editor_test.py
+++ b/core/controllers/story_editor_test.py
@@ -17,6 +17,7 @@
 from __future__ import absolute_import  # pylint: disable=import-only-modules
 from __future__ import unicode_literals  # pylint: disable=import-only-modules
 
+from core.domain import story_domain
 from core.domain import story_services
 from core.domain import topic_fetchers
 from core.domain import topic_services
@@ -406,13 +407,41 @@ def test_editable_story_handler_get(self):
 
         # Check that admins can access the editable story data.
         self.login(self.ADMIN_EMAIL)
-
+        self.save_new_valid_exploration(
+            '0', self.admin_id, title='Title 1',
+            category='Mathematics', language_code='en')
+        self.publish_exploration(self.admin_id, '0')
+        change_list = [story_domain.StoryChange({
+            'cmd': story_domain.CMD_ADD_STORY_NODE,
+            'node_id': 'node_1',
+            'title': 'Title 1'
+        }), story_domain.StoryChange({
+            'cmd': story_domain.CMD_UPDATE_STORY_NODE_PROPERTY,
+            'property_name': (
+                story_domain.STORY_NODE_PROPERTY_EXPLORATION_ID),
+            'node_id': 'node_1',
+            'old_value': None,
+            'new_value': '0'
+        }), story_domain.StoryChange({
+            'cmd': story_domain.CMD_UPDATE_STORY_NODE_PROPERTY,
+            'property_name': (
+                story_domain.STORY_NODE_PROPERTY_PREREQUISITE_SKILL_IDS),
+            'node_id': 'node_1',
+            'old_value': [],
+            'new_value': ['skill_id_1']
+        })]
+        self.save_new_skill(
+            'skill_id_1', self.admin_id, description='Description 3')
+        story_services.update_story(
+            self.admin_id, self.story_id, change_list, 'Updated story node.')
         json_response = self.get_json(
             '%s/%s' % (
                 feconf.STORY_EDITOR_DATA_URL_PREFIX, self.story_id))
         self.assertEqual(self.story_id, json_response['story']['id'])
         self.assertEqual('Name', json_response['topic_name'])
-        self.assertEqual([], json_response['skill_summaries'])
+        self.assertEqual(len(json_response['skill_summaries']), 1)
+        self.assertEqual(
+            json_response['skill_summaries'][0]['description'], 'Description 3')
         self.logout()
 
     def test_editable_story_handler_put(self):