internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: oppia/oppia

Issue:
Add typescript installation and basic configuration
- Typescript installation
- Installation of typings for node modules which we use
- Initial tsconfig.json file

Add typescript installation and basic configuration
- Typescript installation
- Installation of typings for node modules which we use
- Initial tsconfig.json file



Discussion:

Resolving patch:
diff --git a/constants.py b/constants.py
--- a/constants.py
+++ b/constants.py
@@ -20,17 +20,26 @@
 
 import json
 import os
+import re
 
 
 def parse_json_from_js(js_file):
     """Extracts JSON object from JS file."""
     text = js_file.read()
-    first_bracket_index = text.find('= {')
-    last_bracket_index = text.rfind('}')
-    json_text = text[first_bracket_index + 2:last_bracket_index + 1]
+    text_without_comments = remove_comments(text)
+    first_bracket_index = text_without_comments.find('= {')
+    last_bracket_index = text_without_comments.rfind('}')
+    json_text = (
+        text_without_comments[first_bracket_index + 2:last_bracket_index + 1]
+    )
     return json.loads(json_text)
 
 
+def remove_comments(text):
+    """Removes comments from given text."""
+    return re.sub(r'  //.*\n', r'', text)
+
+
 class Constants(dict):
     """Transforms dict to object, attributes can be accessed by dot notation."""
     __getattr__ = dict.__getitem__


Test patch:
diff --git a/constants_test.py b/constants_test.py
--- a/constants_test.py
+++ b/constants_test.py
@@ -44,3 +44,22 @@ def test_constants_and_feconf_are_consistent(self):
         self.assertIn(
             feconf.SYSTEM_COMMITTER_ID, constants.constants.SYSTEM_USER_IDS)
         self.assertEqual(len(constants.constants.SYSTEM_USER_IDS), 2)
+
+    def test_all_comments_are_removed_from_json_text(self):
+        """Tests if comments are removed from json text."""
+        with open(os.path.join(
+            feconf.TESTS_DATA_DIR, 'dummy_constants.js'), 'r') as f:
+            actual_text_without_comments = constants.remove_comments(f.read())
+            expected_text_without_comments = (
+                'var dummy_constants = {\n'
+                '  "File_purpose": "This file is for testing comments '
+                'removal",\n\n'
+                '  "Dummy_constant": "Simple constant",\n\n'
+                '  "Dummy_list_constant": ["List", "of", "dummy", '
+                '"constants"],\n\n'
+                '  "Dummy_constant_without_comment": '
+                '"Dummy constant with no comment"\n'
+                '};\n')
+
+            self.assertEqual(
+                actual_text_without_comments, expected_text_without_comments)
diff --git a/core/tests/data/dummy_constants.js b/core/tests/data/dummy_constants.js
new file mode 100644
--- /dev/null
+++ b/core/tests/data/dummy_constants.js
@@ -0,0 +1,12 @@
+var dummy_constants = {
+  // Define purpose of file.
+  "File_purpose": "This file is for testing comments removal",
+
+  // Dummy constant.
+  "Dummy_constant": "Simple constant",
+
+  // Dummy list constant.
+  "Dummy_list_constant": ["List", "of", "dummy", "constants"],
+
+  "Dummy_constant_without_comment": "Dummy constant with no comment"
+};
Repository: oppia/oppia

Issue:
Run front-end tests in pre-push hook only if changes are made in JS files
The pre-push hook currently runs front-end tests irrespective of whether changes are made in JS files. Ideally, we should run front-end tests only if changes are made to JS files.
Some changes need to be made around [here](https://github.com/oppia/oppia/blob/develop/scripts/pre_push_hook.py#L329).
This issue keeps track of the same.


Discussion:

Resolving patch:
diff --git a/scripts/pre_push_hook.py b/scripts/pre_push_hook.py
--- a/scripts/pre_push_hook.py
+++ b/scripts/pre_push_hook.py
@@ -295,6 +295,23 @@ def _install_hook():
         print 'Copied file to .git/hooks directory'
 
 
+def does_diff_include_js_files(files_to_lint):
+    """Returns true if diff includes JS files.
+
+    Args:
+        files_to_lint: list(str). List of files to be linted.
+
+    Returns:
+        bool. Status of JS files in diff.
+    """
+
+    js_files_to_check = [
+        filename for filename in files_to_lint if
+        filename.endswith('.js')]
+
+    return bool(js_files_to_check)
+
+
 def main():
     """Main method for pre-push hook that executes the Python/JS linters on all
     files that deviate from develop.
@@ -326,7 +343,9 @@ def main():
                 if lint_status != 0:
                     print 'Push failed, please correct the linting issues above'
                     sys.exit(1)
-            frontend_status = _start_sh_script(FRONTEND_TEST_SCRIPT)
+            frontend_status = 0
+            if does_diff_include_js_files(files_to_lint):
+                frontend_status = _start_sh_script(FRONTEND_TEST_SCRIPT)
             if frontend_status != 0:
                 print 'Push aborted due to failing frontend tests.'
                 sys.exit(1)


Test patch:
Repository: oppia/oppia

Issue:
InteractiveMap interaction: in the rule editor, clicks on the map are not displayed correctly
Create an exploration with a map interaction. Add a rule and click on the map to choose the point the rule applies to. A marker should appear where you click, but it does not.

Save and close the rule, then re-open it. The marker is now displayed correctly.

Create a new rule. Before being clicked on the map should be blank, but instead it displays the position of the marker from the previous rule.



Discussion:

Resolving patch:
diff --git a/extensions/dependencies/dependencies_config.py b/extensions/dependencies/dependencies_config.py
--- a/extensions/dependencies/dependencies_config.py
+++ b/extensions/dependencies/dependencies_config.py
@@ -21,7 +21,7 @@
 # should insert when the Angular app is first initialized.
 DEPENDENCIES_TO_ANGULAR_MODULES_DICT = {
     'codemirror': ['ui.codemirror'],
-    'google_maps': ['ui.map'],
+    'ui_leaflet': ['ui-leaflet'],
     'guppy': [],
     'logic_proof': [],
     'math_expressions': [],
diff --git a/extensions/interactions/InteractiveMap/InteractiveMap.py b/extensions/interactions/InteractiveMap/InteractiveMap.py
--- a/extensions/interactions/InteractiveMap/InteractiveMap.py
+++ b/extensions/interactions/InteractiveMap/InteractiveMap.py
@@ -26,7 +26,7 @@ class InteractiveMap(base.BaseInteraction):
     description = 'Allows learners to specify a position on a world map.'
     display_mode = base.DISPLAY_MODE_SUPPLEMENTAL
     is_trainable = False
-    _dependency_ids = ['google_maps']
+    _dependency_ids = ['ui_leaflet']
     answer_type = 'CoordTwoDim'
     instructions = 'Click on the map'
     narrow_instructions = 'View map'


Test patch:
Repository: oppia/oppia

Issue:
Missing CSRF_TOKEN in a request raises  500 Internal Server Error.
<!--
  - Thanks for taking the time to report a bug in the Oppia project.
  - Before filing a new issue, please do a quick search to check that it hasn't
  - already been filed on the [issue tracker](https://github.com/oppia/oppia/issues)._
  -->

**Describe the bug**

If `CSRF_TOKEN` is missing in a request the error thrown is 500 Internal Server Error hence, we are getting error 500 in production which is not ideal.

**To Reproduce**
Steps to reproduce the behavior:
 1. Remove `CSRF_TOKEN` from the request,
 2. See the error.

**Expected behavior**
Error 401 or 403 should be raised i.e unauthorized or forbidden if `CSRF_TOKEN` is missing.

**Screenshots**

![Screenshot from 2019-03-15 15-48-20](https://user-images.githubusercontent.com/41017303/54425654-dbee9780-473b-11e9-9a75-1702d8741a6c.png)



Discussion:

Resolving patch:
diff --git a/core/controllers/base.py b/core/controllers/base.py
--- a/core/controllers/base.py
+++ b/core/controllers/base.py
@@ -238,7 +238,7 @@ def dispatch(self):
                         'Registration session expired.')
                 csrf_token = self.request.get('csrf_token')
                 if not csrf_token:
-                    raise Exception(
+                    raise self.UnauthorizedUserException(
                         'Missing CSRF token. Changes were not saved. '
                         'Please report this bug.')
 


Test patch:
diff --git a/core/controllers/base_test.py b/core/controllers/base_test.py
--- a/core/controllers/base_test.py
+++ b/core/controllers/base_test.py
@@ -105,6 +105,15 @@ def test_that_no_get_results_in_500_error(self):
         #     POST, PUT and DELETE. Something needs to regulate what
         #     the fields in the payload should be.
 
+    def test_requests_for_missing_csrf_token(self):
+        """Tests request without csrf_token results in 401 error."""
+
+        self.post_json(
+            '/library/any', payload={}, expected_status_int=401)
+
+        self.put_json(
+            '/library/any', payload={}, expected_status_int=401)
+
     def test_requests_for_invalid_paths(self):
         """Test that requests for invalid paths result in a 404 error."""
         user_id = user_services.get_user_id_from_username('learneruser')
Repository: oppia/oppia

Issue:
Adding Lesson Topics to Lesson-Specific Landing Pages
**Is your feature request related to a problem? Please describe.**
Currently, our lesson landing pages don't include many of the keywords related to the lessons themselves, which makes them more difficult to surface in searches and in our ads. 

**Describe the solution you'd like**
I would like to add lesson topics/areas to the lesson landing page (as seen in the screenshot below). In mobile view, the Topics covered list will be seen above the Otter in one column.

Also note that Mark recommended using a more colorful cake, like the one seen in the screenshot below, for the Fractions landing page.

**Describe alternatives you've considered**
I've also considered adding more keywords by adding exploration titles to the collection landing pages to increase relevancy to those pages as well.

**Additional context**
<img width="499" alt="Screenshot 2019-05-24 14 01 05" src="https://user-images.githubusercontent.com/12034267/58350733-60d8ea00-7e2c-11e9-91e5-7d934471f1f6.png">
<img width="499" alt="Screenshot 2019-05-24 14 00 24" src="https://user-images.githubusercontent.com/12034267/58350707-4868cf80-7e2c-11e9-8734-497549b6464c.png">

Adding Lesson Topics to Lesson-Specific Landing Pages
**Is your feature request related to a problem? Please describe.**
Currently, our lesson landing pages don't include many of the keywords related to the lessons themselves, which makes them more difficult to surface in searches and in our ads. 

**Describe the solution you'd like**
I would like to add lesson topics/areas to the lesson landing page (as seen in the screenshot below). In mobile view, the Topics covered list will be seen above the Otter in one column.

Also note that Mark recommended using a more colorful cake, like the one seen in the screenshot below, for the Fractions landing page.

**Describe alternatives you've considered**
I've also considered adding more keywords by adding exploration titles to the collection landing pages to increase relevancy to those pages as well.

**Additional context**
<img width="499" alt="Screenshot 2019-05-24 14 01 05" src="https://user-images.githubusercontent.com/12034267/58350733-60d8ea00-7e2c-11e9-91e5-7d934471f1f6.png">
<img width="499" alt="Screenshot 2019-05-24 14 00 24" src="https://user-images.githubusercontent.com/12034267/58350707-4868cf80-7e2c-11e9-8734-497549b6464c.png">



Discussion:

Resolving patch:
diff --git a/feconf.py b/feconf.py
--- a/feconf.py
+++ b/feconf.py
@@ -951,5 +951,5 @@ def get_empty_ratings():
 # oppia constant defined in
 # core/templates/dev/head/pages/landing-pages/TopicLandingPage.js file.
 AVAILABLE_LANDING_PAGES = {
-    'maths': ['fractions', 'ratios']
+    'maths': ['fractions', 'negative-numbers', 'ratios']
 }


Test patch:
Repository: oppia/oppia

Issue:
Add a test to ensure usage of angular.mock.inject
In test files, inject should be used as angular.mock.inject to maintain a consistent behavior since we use angular.mock.module instead of module. Typescript supports both inject and angular.mock.inject, so we need a custom test to ensure that angular.mock.inject is used instead of inject.
Add a test to ensure usage of angular.mock.inject
In test files, inject should be used as angular.mock.inject to maintain a consistent behavior since we use angular.mock.module instead of module. Typescript supports both inject and angular.mock.inject, so we need a custom test to ensure that angular.mock.inject is used instead of inject.


Discussion:
@ankita240796 how is this going?
Hi @jacobdavis11, currently I am working on milestone 1 of my GSoC project. I will be taking this up after the current release. Sorry for the delay.
@ankita240796 how is this going?
Hi @jacobdavis11, currently I am working on milestone 1 of my GSoC project. I will be taking this up after the current release. Sorry for the delay.

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -147,7 +147,7 @@
         'excluded_dirs': ()}
 }
 
-BAD_PATTERNS_JS_REGEXP = [
+BAD_PATTERNS_JS_AND_TS_REGEXP = [
     {
         'regexp': r'\b(browser.explore)\(',
         'message': 'In tests, please do not use browser.explore().',
@@ -185,6 +185,13 @@
         'excluded_files': (),
         'excluded_dirs': ()
     },
+    {
+        'regexp': r'\b(beforeEach\(inject\(function)\(',
+        'message': 'In tests, please use \'angular.mock.inject\' instead of '
+                   '\'inject\'',
+        'excluded_files': (),
+        'excluded_dirs': ()
+    },
     {
         'regexp': r'templateUrl: \'',
         'message': 'The directives must be directly referenced.',
@@ -2159,7 +2166,7 @@ def _check_bad_patterns(self):
                         total_error_count += 1
 
                 if filepath.endswith(('.js', '.ts')):
-                    for regexp in BAD_PATTERNS_JS_REGEXP:
+                    for regexp in BAD_PATTERNS_JS_AND_TS_REGEXP:
                         if _check_bad_pattern_in_file(
                                 filepath, file_content, regexp):
                             failed = True


Test patch:
Repository: oppia/oppia

Issue:
Add the practice session experience to the topic viewer
Add an option in the topic viewer page that can start the practice session, based on the skills that are part of the topic.
Add the practice session experience to the topic viewer
Add an option in the topic viewer page that can start the practice session, based on the skills that are part of the topic.


Discussion:
@vinitamurthi how is this going?
De-assigning for now; please re-assign if you plan to work on this.
@vinitamurthi how is this going?
De-assigning for now; please re-assign if you plan to work on this.

Resolving patch:
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
@@ -73,6 +73,7 @@ def get(self, topic_name):
 
         self.values.update({
             'topic_name': topic.name,
+            'topic_id': topic.id,
             'canonical_story_dicts': canonical_story_dicts,
             'additional_story_dicts': additional_story_dicts,
             'uncategorized_skill_ids': uncategorized_skill_ids,


Test patch:
diff --git a/core/controllers/topic_viewer_test.py b/core/controllers/topic_viewer_test.py
--- a/core/controllers/topic_viewer_test.py
+++ b/core/controllers/topic_viewer_test.py
@@ -90,6 +90,7 @@ def test_get(self):
                 '%s/%s' % (feconf.TOPIC_DATA_HANDLER, 'public_topic_name'))
             expected_dict = {
                 'topic_name': 'public_topic_name',
+                'topic_id': self.topic_id,
                 'canonical_story_dicts': [{
                     'id': self.story.id,
                     'title': self.story.title,
Repository: oppia/oppia

Issue:
Wrong fileoverview of core/templates/dev/head/components/ck-editor-helpers/ck-editor-rte.directive.ts
There is a wrong fileoverview of file 
``` core/templates/dev/head/components/ck-editor-helpers/ck-editor-rte.directive.ts ``` which creates confusion.
We have to correct it.
![imageedit_1_9022032830](https://user-images.githubusercontent.com/34139754/59574556-4a454c00-90d5-11e9-8f61-23eb6f8491c1.png)



Discussion:
Assigning @bansalnitish as a codeowner.

Resolving patch:
diff --git a/scripts/build.py b/scripts/build.py
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -374,7 +374,7 @@ def process_html(source_file_stream, target_file_stream, file_hashes):
 
 
 def get_dependency_directory(dependency):
-    """Get dependency directory from dependecy dictionary.
+    """Get dependency directory from dependency dictionary.
 
     Args:
         dependency: dict(str, str). Dictionary representing single dependency


Test patch:
Repository: oppia/oppia

Issue:
Remove $parent from HTML files
All $parent statements had been removed from the JS files and a check had been implemented for it in PR #4980. A similar thing has to be done for the HTML files. This issue keeps a track of it.
Remove $parent from HTML files
All $parent statements had been removed from the JS files and a check had been implemented for it in PR #4980. A similar thing has to be done for the HTML files. This issue keeps a track of it.


Discussion:
Hi, I'm currently working around *extensions/objects/templates* and I anyway need to change some of the HTML, so I will also remove the parent tags from there.
Great, thanks @vojtechjelinek! 
@apb7 any updates on this?
Hi @jacobdavis11, I am not working on this at the moment. Therefore, un-assigning. Thanks! 
Hi, I'm currently working around *extensions/objects/templates* and I anyway need to change some of the HTML, so I will also remove the parent tags from there.
Great, thanks @vojtechjelinek! 
@apb7 any updates on this?
Hi @jacobdavis11, I am not working on this at the moment. Therefore, un-assigning. Thanks! 

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -261,6 +261,14 @@
         'message': 'There should not be any trailing whitespaces.',
         'excluded_files': (),
         'excluded_dirs': ()
+    },
+    {
+        'regexp': r'\$parent',
+        'message': 'Please do not access parent properties ' +
+                   'using $parent. Use the scope object' +
+                   'for this purpose.',
+        'excluded_files': (),
+        'excluded_dirs': ()
     }
 ]
 


Test patch:
diff --git a/extensions/value_generators/models/generators_test.py b/extensions/value_generators/models/generators_test.py
--- a/extensions/value_generators/models/generators_test.py
+++ b/extensions/value_generators/models/generators_test.py
@@ -41,6 +41,6 @@ def test_random_selector(self):
         self.assertIn(generator.generate_value(
             {}, **{'list_of_values': ['a', 'b', 'c']}), ['a', 'b', 'c'])
         self.assertIn(
-            'schema="SCHEMA" '
-            'local-value="$parent.$parent.customizationArgs.list_of_values"',
+            'schema="$ctrl.SCHEMA" '
+            'local-value="$ctrl.customizationArgs.list_of_values"',
             generator.get_html_template())
Repository: oppia/oppia

Issue:
Interpolate URL console error in feedbacks.
<!--
  - Thanks for taking the time to report a bug in the Oppia project.
  - Before filing a new issue, please do a quick search to check that it hasn't
  - already been filed on the [issue tracker](https://github.com/oppia/oppia/issues)._
  -->

**Describe the bug**
The feedbacks thread section gives console errors regarding invalid parameters in feedback tab.

**To Reproduce**
Steps to reproduce the behavior:
 1. Create an exploration and publish it.
 2. Login as another user and give some feedback on the exploration.
 3. Go to learner dashboard and reply to your existing feedback.
 4. See error

**Observed behavior**
Console error pops up.

**Expected behavior**
Console error should not pop up.

**Screenshots**
![Screenshot from 2019-07-23 14-20-43](https://user-images.githubusercontent.com/34203227/61699117-ea873400-ad57-11e9-90c4-b3db85522605.png)


**Desktop (please complete the following information; delete this section if the issue does not arise on desktop):**
 - OS: Ubuntu 18.04
 - Browser Chrome
 - Version 75.0.3770.90

**Additional context**
This problem happens on learner as well as creator side of feedback threads.

Interpolate URL console error in feedbacks.
<!--
  - Thanks for taking the time to report a bug in the Oppia project.
  - Before filing a new issue, please do a quick search to check that it hasn't
  - already been filed on the [issue tracker](https://github.com/oppia/oppia/issues)._
  -->

**Describe the bug**
The feedbacks thread section gives console errors regarding invalid parameters in feedback tab.

**To Reproduce**
Steps to reproduce the behavior:
 1. Create an exploration and publish it.
 2. Login as another user and give some feedback on the exploration.
 3. Go to learner dashboard and reply to your existing feedback.
 4. See error

**Observed behavior**
Console error pops up.

**Expected behavior**
Console error should not pop up.

**Screenshots**
![Screenshot from 2019-07-23 14-20-43](https://user-images.githubusercontent.com/34203227/61699117-ea873400-ad57-11e9-90c4-b3db85522605.png)


**Desktop (please complete the following information; delete this section if the issue does not arise on desktop):**
 - OS: Ubuntu 18.04
 - Browser Chrome
 - Version 75.0.3770.90

**Additional context**
This problem happens on learner as well as creator side of feedback threads.



Discussion:

Resolving patch:
diff --git a/core/domain/feedback_services.py b/core/domain/feedback_services.py
--- a/core/domain/feedback_services.py
+++ b/core/domain/feedback_services.py
@@ -167,7 +167,7 @@ def create_message(
     msg.put()
 
     # Update the message count in the thread.
-    if thread.message_count:
+    if thread.message_count is not None:
         thread.message_count += 1
     else:
         thread.message_count = (


Test patch:
Repository: oppia/oppia

Issue:
Fix follow-up comments from #7191 and #7068
This issue tracks the follow-up comments from #7191 and #7068.


Discussion:
@Jamesjay4199, any update on this? (I think we need to resolve this before the next release cut.) 
Okay, I'll send in a PR asap.

Resolving patch:
diff --git a/feconf.py b/feconf.py
--- a/feconf.py
+++ b/feconf.py
@@ -815,9 +815,6 @@ def get_empty_ratings():
     'Discover top-rated or recently-published explorations on Oppia. Learn '
     'from these explorations or help improve an existing one for the '
     'community.')
-SEARCH_PAGE_DESCRIPTION = (
-    'Discover a new exploration to learn from, or help improve an existing '
-    'one for the community.')
 
 # The type of the response returned by a handler when an exception is raised.
 HANDLER_TYPE_HTML = 'html'


Test patch: