prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Show skill mastery values in the topic viewer
  Add a skill tab in the topic viewer that will show skill mastery of all skills in that topic (Once we have enough skill mastery information for the skill)
  
  Milestone 3.2 in @sophiewu6 's GSoC project
  
  </issue>
  <code>
  [start of core/controllers/topic_viewer.py]
  1 # Copyright 2018 The Oppia Authors. All Rights Reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #      http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS-IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 """Controllers for the topic viewer page."""
  16 
  17 from constants import constants
  18 from core.controllers import acl_decorators
  19 from core.controllers import base
  20 from core.domain import story_fetchers
  21 from core.domain import topic_fetchers
  22 import feconf
  23 
  24 
  25 class TopicViewerPage(base.BaseHandler):
  26     """Renders the topic viewer page."""
  27 
  28     @acl_decorators.can_access_topic_viewer_page
  29     def get(self, _):
  30         """Handles GET requests."""
  31 
  32         if not constants.ENABLE_NEW_STRUCTURE_PLAYERS:
  33             raise self.PageNotFoundException
  34 
  35         self.render_template('dist/topic-viewer-page.mainpage.html')
  36 
  37 
  38 class TopicPageDataHandler(base.BaseHandler):
  39     """Manages the data that needs to be displayed to a learner on the topic
  40     viewer page.
  41     """
  42     GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON
  43 
  44     @acl_decorators.can_access_topic_viewer_page
  45     def get(self, topic_name):
  46         """Handles GET requests."""
  47 
  48         if not constants.ENABLE_NEW_STRUCTURE_PLAYERS:
  49             raise self.PageNotFoundException
  50 
  51         topic = topic_fetchers.get_topic_by_name(topic_name)
  52         canonical_story_ids = topic.get_canonical_story_ids(
  53             include_only_published=True)
  54         additional_story_ids = topic.get_additional_story_ids(
  55             include_only_published=True)
  56         canonical_story_summaries = [
  57             story_fetchers.get_story_summary_by_id(
  58                 canonical_story_id) for canonical_story_id
  59             in canonical_story_ids]
  60 
  61         additional_story_summaries = [
  62             story_fetchers.get_story_summary_by_id(
  63                 additional_story_id) for additional_story_id
  64             in additional_story_ids]
  65 
  66         canonical_story_dicts = [
  67             summary.to_human_readable_dict() for summary
  68             in canonical_story_summaries]
  69 
  70         additional_story_dicts = [
  71             summary.to_human_readable_dict() for summary
  72             in additional_story_summaries]
  73 
  74         uncategorized_skill_ids = topic.get_all_uncategorized_skill_ids()
  75         subtopics = topic.get_all_subtopics()
  76 
  77         self.values.update({
  78             'topic_id': topic.id,
  79             'topic_name': topic.name,
  80             'canonical_story_dicts': canonical_story_dicts,
  81             'additional_story_dicts': additional_story_dicts,
  82             'uncategorized_skill_ids': uncategorized_skill_ids,
  83             'subtopics': subtopics
  84         })
  85         self.render_json(self.values)
  86
  [end of core/controllers/topic_viewer.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/core/controllers/topic_viewer.py b/core/controllers/topic_viewer.py
  --- a/core/controllers/topic_viewer.py
  +++ b/core/controllers/topic_viewer.py
  @@ -17,6 +17,7 @@
   from constants import constants
   from core.controllers import acl_decorators
   from core.controllers import base
  +from core.domain import skill_services
   from core.domain import story_fetchers
   from core.domain import topic_fetchers
   import feconf
  @@ -74,12 +75,26 @@
           uncategorized_skill_ids = topic.get_all_uncategorized_skill_ids()
           subtopics = topic.get_all_subtopics()
   
  +        assigned_skill_ids = topic.get_all_skill_ids()
  +        skill_descriptions = skill_services.get_skill_descriptions_by_ids(
  +            topic.id, assigned_skill_ids)
  +
  +        if self.user_id:
  +            degrees_of_mastery = skill_services.get_multi_user_skill_mastery(
  +                self.user_id, assigned_skill_ids)
  +        else:
  +            degrees_of_mastery = {}
  +            for skill_id in assigned_skill_ids:
  +                degrees_of_mastery[skill_id] = None
  +
           self.values.update({
               'topic_id': topic.id,
               'topic_name': topic.name,
               'canonical_story_dicts': canonical_story_dicts,
               'additional_story_dicts': additional_story_dicts,
               'uncategorized_skill_ids': uncategorized_skill_ids,
  -            'subtopics': subtopics
  +            'subtopics': subtopics,
  +            'degrees_of_mastery': degrees_of_mastery,
  +            'skill_descriptions': skill_descriptions
           })
           self.render_json(self.values)
  
verification_info: {"golden_diff": "diff --git a/core/controllers/topic_viewer.py b/core/controllers/topic_viewer.py\n--- a/core/controllers/topic_viewer.py\n+++ b/core/controllers/topic_viewer.py\n@@ -17,6 +17,7 @@\n from constants import constants\n from core.controllers import acl_decorators\n from core.controllers import base\n+from core.domain import skill_services\n from core.domain import story_fetchers\n from core.domain import topic_fetchers\n import feconf\n@@ -74,12 +75,26 @@\n         uncategorized_skill_ids = topic.get_all_uncategorized_skill_ids()\n         subtopics = topic.get_all_subtopics()\n \n+        assigned_skill_ids = topic.get_all_skill_ids()\n+        skill_descriptions = skill_services.get_skill_descriptions_by_ids(\n+            topic.id, assigned_skill_ids)\n+\n+        if self.user_id:\n+            degrees_of_mastery = skill_services.get_multi_user_skill_mastery(\n+                self.user_id, assigned_skill_ids)\n+        else:\n+            degrees_of_mastery = {}\n+            for skill_id in assigned_skill_ids:\n+                degrees_of_mastery[skill_id] = None\n+\n         self.values.update({\n             'topic_id': topic.id,\n             'topic_name': topic.name,\n             'canonical_story_dicts': canonical_story_dicts,\n             'additional_story_dicts': additional_story_dicts,\n             'uncategorized_skill_ids': uncategorized_skill_ids,\n-            'subtopics': subtopics\n+            'subtopics': subtopics,\n+            'degrees_of_mastery': degrees_of_mastery,\n+            'skill_descriptions': skill_descriptions\n         })\n         self.render_json(self.values)\n", "issue": "Show skill mastery values in the topic viewer\nAdd a skill tab in the topic viewer that will show skill mastery of all skills in that topic (Once we have enough skill mastery information for the skill)\r\n\r\nMilestone 3.2 in @sophiewu6 's GSoC project\n", "before_files": [{"content": "# Copyright 2018 The Oppia Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS-IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Controllers for the topic viewer page.\"\"\"\n\nfrom constants import constants\nfrom core.controllers import acl_decorators\nfrom core.controllers import base\nfrom core.domain import story_fetchers\nfrom core.domain import topic_fetchers\nimport feconf\n\n\nclass TopicViewerPage(base.BaseHandler):\n    \"\"\"Renders the topic viewer page.\"\"\"\n\n    @acl_decorators.can_access_topic_viewer_page\n    def get(self, _):\n        \"\"\"Handles GET requests.\"\"\"\n\n        if not constants.ENABLE_NEW_STRUCTURE_PLAYERS:\n            raise self.PageNotFoundException\n\n        self.render_template('dist/topic-viewer-page.mainpage.html')\n\n\nclass TopicPageDataHandler(base.BaseHandler):\n    \"\"\"Manages the data that needs to be displayed to a learner on the topic\n    viewer page.\n    \"\"\"\n    GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON\n\n    @acl_decorators.can_access_topic_viewer_page\n    def get(self, topic_name):\n        \"\"\"Handles GET requests.\"\"\"\n\n        if not constants.ENABLE_NEW_STRUCTURE_PLAYERS:\n            raise self.PageNotFoundException\n\n        topic = topic_fetchers.get_topic_by_name(topic_name)\n        canonical_story_ids = topic.get_canonical_story_ids(\n            include_only_published=True)\n        additional_story_ids = topic.get_additional_story_ids(\n            include_only_published=True)\n        canonical_story_summaries = [\n            story_fetchers.get_story_summary_by_id(\n                canonical_story_id) for canonical_story_id\n            in canonical_story_ids]\n\n        additional_story_summaries = [\n            story_fetchers.get_story_summary_by_id(\n                additional_story_id) for additional_story_id\n            in additional_story_ids]\n\n        canonical_story_dicts = [\n            summary.to_human_readable_dict() for summary\n            in canonical_story_summaries]\n\n        additional_story_dicts = [\n            summary.to_human_readable_dict() for summary\n            in additional_story_summaries]\n\n        uncategorized_skill_ids = topic.get_all_uncategorized_skill_ids()\n        subtopics = topic.get_all_subtopics()\n\n        self.values.update({\n            'topic_id': topic.id,\n            'topic_name': topic.name,\n            'canonical_story_dicts': canonical_story_dicts,\n            'additional_story_dicts': additional_story_dicts,\n            'uncategorized_skill_ids': uncategorized_skill_ids,\n            'subtopics': subtopics\n        })\n        self.render_json(self.values)\n", "path": "core/controllers/topic_viewer.py"}]}