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

Issue:
Refactor PlaythroughIssuesService.openPlaythroughModal()
`openPlaythroughModal` currently suffers from over-abstraction for a very simple problem: showing a slice of an array.

![image](https://user-images.githubusercontent.com/5094060/54098825-94a78600-438c-11e9-847b-e80d9a809ceb.png)

My intuition says that we can vastly simplify the implementation by using a single integer: `firstIndexToRender`. We should be able to simplify this to (disclaimer — pseudo-code ahead):

```Javascript
var firstIndexToRender = Math.max(0, getAllActions().length - ACTIONS_TO_EXPAND_BY);

$scope.expandActionsToRender = function() {
  firstIndexToRender = Math.max(0, firstIndexToRender - ACTIONS_TO_EXPAND_BY)
};
$scope.getActionsToRender = function() {
  return getAllActions().slice(firstIndexToRender);
};
```

```HTML
<button class="expand-arrow" ng-click="expandActionsToRender()"></button>
<div ng-repeat="action in getActionsToRender()">
  <[action]>
</div>
```

This will also require test coverage and clean-up, since there are a lot of dependencies on the current way to render these actions ("Display Blocks").


Discussion:
@pranavsid98 would you like to pick this up?
@brianrodri Sorry about the delayed response. But, what do you mean when you use the constant ACTIONS_TO_EXPAND_BY? If it means a fixed number of actions that we expand by every time, that would be incorrect. Our ideology is that each Display block contains a set of relevant actions, and doesn't take the number of actions in the block as a factor.
I took a quick look at this -- @pranavsid98, could you please explain what the algorithm is for figuring out how many actions to expand by each time the up/down arrow is clicked? I actually expected it to be a fixed constant as well. E.g. if you do this on github then you would expand by a fixed number of 20 or so lines each time (I think).
Right, I was thinking you should be able to calculate which indices to stop at in the constructor, and building an array of where to "stop":

`[n - 3, n - 8, n - 3, ..., 0]`

Then the code can simply become 

```javascript
/** @type {number[]} */
var startingIndices = calculateStartingIndices();
/** @type {number} */
var currentChoice = 0;

$scope.expandActionsToRender = function() {
  currentChoice = Math.max(startingIndices.length - 1, currentChoice + 1);
};
$scope.getActionsToRender = function() {
  return getAllActions().slice(startingIndices[currentChoice]);
};
```

```html
<button class="expand-arrow" ng-click="expandActionsToRender()"></button>
<div ng-repeat="action in getActionsToRender()">
  <[action]>
</div>
```

Resolving patch:
diff --git a/scripts/check_frontend_coverage.py b/scripts/check_frontend_coverage.py
--- a/scripts/check_frontend_coverage.py
+++ b/scripts/check_frontend_coverage.py
@@ -159,6 +159,7 @@
     'is-nonempty.filter.ts',
     'item-selection-input-rules.service.ts',
     'ItemSelectionInput.ts',
+    'learner-action-render.service.ts',
     'learner-answer-details-data.service.ts',
     'learner-dashboard-backend-api.service.ts',
     'learner-dashboard-ids-backend-api.service.ts',


Test patch:
Repository: oppia/oppia

Issue:
One off jobs are not working with the --prod_env flag.
<!--
  - 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**
One off jobs are not working with the --prod_env flag either in the development server ie ```python -m scripts.start --prod_env``` or the ```bash scripts/run_e2e_tests.sh --prod_env```.




Discussion:

Resolving patch:
diff --git a/scripts/build.py b/scripts/build.py
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -144,8 +144,13 @@
     dest='minify_third_party_libs_only')
 
 
-def generate_app_yaml():
-    """Generate app.yaml from app_dev.yaml."""
+def generate_app_yaml(is_prod_mode=False):
+    """Generate app.yaml from app_dev.yaml.
+
+    Args:
+        is_prod_mode: bool. Whether the script is being called
+        with --prod_env flag or not.
+    """
     prod_file_prefix = 'build/'
     content = '# THIS FILE IS AUTOGENERATED, DO NOT MODIFY\n'
     with python_utils.open_file(APP_DEV_YAML_FILEPATH, 'r') as yaml_file:
@@ -155,7 +160,8 @@ def generate_app_yaml():
             content = content.replace(
                 file_path,
                 prod_file_prefix + file_path)
-    content = content.replace('version: default', '')
+    if not is_prod_mode:
+        content = content.replace('version: default', '')
     if os.path.isfile(APP_YAML_FILEPATH):
         os.remove(APP_YAML_FILEPATH)
     with python_utils.open_file(APP_YAML_FILEPATH, 'w+') as prod_yaml_file:
@@ -1253,7 +1259,7 @@ def main(args=None):
         if not options.minify_third_party_libs_only:
             hashes = generate_hashes()
             build_using_webpack()
-            generate_app_yaml()
+            generate_app_yaml(is_prod_mode=options.prod_mode)
             generate_build_directory(hashes)
 
     save_hashes_to_file(dict())


Test patch:
Repository: oppia/oppia

Issue:
Add modal to allow user to add commit message when saving an edit to a question
When editing a question, the user should be allowed to specify a commit message.


Discussion:
@tjiang11 was this fixed by 5614?
@tjiang11 are you still working on this?
@DubeySandeep , Is this issue still available to work on?


Resolving patch:
diff --git a/core/domain/question_services.py b/core/domain/question_services.py
--- a/core/domain/question_services.py
+++ b/core/domain/question_services.py
@@ -165,7 +165,7 @@ def _update_linked_skill_ids_of_question(
     }
     change_list = [question_domain.QuestionChange(change_dict)]
     update_question(
-        user_id, question_id, change_list, 'updated linked skill ids')
+        user_id, question_id, change_list, 'Updated linked skill ids')
     (opportunity_services
      .update_skill_opportunities_on_question_linked_skills_change(
          old_linked_skill_ids, new_linked_skill_ids))


Test patch:
Repository: oppia/oppia

Issue:
Story chapters don't play without prerequisite skills
**Describe the bug**
If a story chapter is created without prerequisite skills, then when the exploration in the chapter is played, an orange error message is shown and the exploration doesn't play.

**To Reproduce**
Steps to reproduce the behavior:
 1. Signup and login as an admin (by going to Roles tab in /admin and giving yourself Admin role)
 2. In the Activities tab in /admin, reload the first exploration (anything is fine as long as you know the ID).
 3. Go to topics and skills dashboard page and create a topic.
 4. Click 'Create Story' in the topic editor and add a story title.
 5. Click 'Create Chapter' in the story editor and add a chapter title.
 6. In the 'Exploration ID' field, add the ID of the reloaded exploration, if it was the first one, add '0'.
 7. Publish the story and go to '/story/<[storyId]>'.
 9. Click on the exploration circle here.

**Observed behavior**
The following error message is logged in the backend, and the exploration doesn't play.
![image](https://user-images.githubusercontent.com/22347970/74082530-e404a380-4a80-11ea-8c36-2e73ed08331a.png)

**Expected behavior**
Exploration should play normally without the pretests.

**Desktop (please complete the following information; delete this section if the issue does not arise on desktop):**
- Common issue

**Smartphone (please complete the following information; delete this section if the issue does not arise on smartphones):**
 - Common issue



Discussion:

Resolving patch:
diff --git a/core/domain/question_fetchers.py b/core/domain/question_fetchers.py
--- a/core/domain/question_fetchers.py
+++ b/core/domain/question_fetchers.py
@@ -48,6 +48,8 @@ def get_questions_and_skill_descriptions_by_skill_ids(
             batch of questions (or None if no more pages are left). The returned
             next cursor value is urlsafe.
     """
+    if not skill_ids:
+        return [], [], None
     question_skill_link_models, next_cursor = (
         question_models.QuestionSkillLinkModel
         .get_question_skill_links_by_skill_ids(


Test patch:
diff --git a/core/domain/question_fetchers_test.py b/core/domain/question_fetchers_test.py
--- a/core/domain/question_fetchers_test.py
+++ b/core/domain/question_fetchers_test.py
@@ -69,6 +69,12 @@ def test_get_questions_and_skill_descriptions_by_skill_ids(self):
         self.assertEqual(
             questions[0].to_dict(), self.question.to_dict())
 
+    def test_get_no_questions_with_no_skill_ids(self):
+        questions, _, _ = (
+            question_fetchers.get_questions_and_skill_descriptions_by_skill_ids(
+                1, [], ''))
+        self.assertEqual(len(questions), 0)
+
     def test_get_questions_with_multi_skill_ids(self):
         question_id_1 = question_services.get_new_question_id()
         question_1 = self.save_new_question(
Repository: oppia/oppia

Issue:
Remove gulp from setup entirely.
To continue consolidating our setup process to a python stack, gulp needs to be removed. Currently gulp only provides a watch functionality that starts build processes if some directories are changed. Our dependency on npm already includes access to npm-watch, which can be used to replace gulp.
Remove gulp from setup entirely.
To continue consolidating our setup process to a python stack, gulp needs to be removed. Currently gulp only provides a watch functionality that starts build processes if some directories are changed. Our dependency on npm already includes access to npm-watch, which can be used to replace gulp.


Discussion:
Gulp is used for automatic recompilation without the need to restart dev server manually for changes in the `third_party` folder and `manifest.json`. I think that these changes are so rare and usually just one time that we can bother the developer with the need to restart server.
@vojtechjelinek Hello. I would like to take this up. I have limited experience with JS and gulp. Can you give me a pointer on what I need to do to remove gulp from setup? Thank you.
@terrameijar You need to find out from what places gulp is called, I think that only from `scripts/start.py` but you will need to check the other files too. Then you can remove the calls to gulp from these places. In the end, you can remove `gulpfile.js` and also all the gulp dependencies.
@kevinlee12 Is this open? Can I get assigned to this?
@sin-ha I have assigned you.
Gulp is used for automatic recompilation without the need to restart dev server manually for changes in the `third_party` folder and `manifest.json`. I think that these changes are so rare and usually just one time that we can bother the developer with the need to restart server.
@vojtechjelinek Hello. I would like to take this up. I have limited experience with JS and gulp. Can you give me a pointer on what I need to do to remove gulp from setup? Thank you.
@terrameijar You need to find out from what places gulp is called, I think that only from `scripts/start.py` but you will need to check the other files too. Then you can remove the calls to gulp from these places. In the end, you can remove `gulpfile.js` and also all the gulp dependencies.
@kevinlee12 Is this open? Can I get assigned to this?
@sin-ha I have assigned you.

Resolving patch:
diff --git a/scripts/start.py b/scripts/start.py
--- a/scripts/start.py
+++ b/scripts/start.py
@@ -132,11 +132,6 @@ def main(args=None):
     # spam people accidentally.
     background_processes = []
     if not parsed_args.prod_env:
-        background_processes.append(subprocess.Popen([
-            common.NODE_BIN_PATH,
-            os.path.join(common.NODE_MODULES_PATH, 'gulp', 'bin', 'gulp.js'),
-            'watch']))
-
         # In prod mode webpack is launched through scripts/build.py
         python_utils.PRINT('Compiling webpack...')
         background_processes.append(subprocess.Popen([


Test patch:
Repository: oppia/oppia

Issue:
yarn.lock file gets changed automatically locally
I've observed in multiple PR's as well as while I push local changes to github that yarn.lock file gets changed automatically.




Discussion:
cc / @oppia/dev-workflow-team 

Resolving patch:
diff --git a/scripts/common.py b/scripts/common.py
--- a/scripts/common.py
+++ b/scripts/common.py
@@ -36,7 +36,7 @@
 NODE_VERSION = '10.18.0'
 
 # NB: Please ensure that the version is consistent with the version in .yarnrc.
-YARN_VERSION = '1.21.1'
+YARN_VERSION = '1.22.0'
 
 COVERAGE_VERSION = '4.5.4'
 
diff --git a/scripts/install_third_party_libs.py b/scripts/install_third_party_libs.py
--- a/scripts/install_third_party_libs.py
+++ b/scripts/install_third_party_libs.py
@@ -211,7 +211,7 @@ def main():
         tweak_yarn_executable()
 
     # Install third-party node modules needed for the build process.
-    subprocess.check_call([get_yarn_command()])
+    subprocess.check_call([get_yarn_command(), 'install', '--pure-lockfile'])
 
     # Install pre-commit script.
     python_utils.PRINT('Installing pre-commit hook for git')
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
@@ -60,7 +60,7 @@
 NPM_CMD = os.path.join(
     OPPIA_PARENT_DIR, 'oppia_tools', 'node-10.18.0', 'bin', 'npm')
 YARN_CMD = os.path.join(
-    OPPIA_PARENT_DIR, 'oppia_tools', 'yarn-v1.17.3', 'bin', 'yarn')
+    OPPIA_PARENT_DIR, 'oppia_tools', 'yarn-v1.22.0', 'bin', 'yarn')
 FRONTEND_TEST_SCRIPT = 'run_frontend_tests'
 TRAVIS_CI_PROTRACTOR_CHECK_SCRIPT = 'check_e2e_tests_are_captured_in_ci'
 GIT_IS_DIRTY_CMD = 'git status --porcelain --untracked-files=no'


Test patch:
Repository: oppia/oppia

Issue:
Blank page loaded when navigated to feedback page from creator dashboard_Both mobile and browsers
**Describe the bug**
Blank page loaded when navigated to feedback page from creator dashboard

**To Reproduce**
Steps to reproduce the behavior:
 1. Create an exploration as user1 and logout
 2. Play through the course as user2 and submit a feedback
 3. Login as user1 and navigate to creator dashboard
 4. Click on the open feedback count (2 in this scenario as in image1)

**Observed behavior**
Blank page loaded when navigated to feedback page from creator dashboard

**Expected behavior**
Meaningful message / page should be loaded

**Screenshots**
Image1
![image](https://user-images.githubusercontent.com/56336353/76447177-3c1b2680-63ee-11ea-879a-a9d01a73b6fb.png)

Blank page
![image](https://user-images.githubusercontent.com/56336353/76447267-6836a780-63ee-11ea-98b4-b5846bbab3d9.png)


**Desktop (please complete the following information; delete this section if the issue does not arise on desktop):**
OS: Chrome OS
Browser Chrome
Version 79.0.3945.119 (Official Build) (64-bit)

**Smartphone (please complete the following information; delete this section if the issue does not arise on smartphones):**
 Device: [iPhoneXS]
OS: [ iOS13.3]
Browser [chrome]


Discussion:

Resolving patch:
diff --git a/core/domain/config_domain.py b/core/domain/config_domain.py
--- a/core/domain/config_domain.py
+++ b/core/domain/config_domain.py
@@ -335,7 +335,7 @@ def get_all_config_property_names(cls):
 IS_IMPROVEMENTS_TAB_ENABLED = ConfigProperty(
     'is_improvements_tab_enabled', BOOL_SCHEMA,
     'Exposes the Improvements Tab for creators in the exploration editor.',
-    True)
+    False)
 
 ALWAYS_ASK_LEARNERS_FOR_ANSWER_DETAILS = ConfigProperty(
     'always_ask_learners_for_answer_details', BOOL_SCHEMA,


Test patch:
diff --git a/core/controllers/admin_test.py b/core/controllers/admin_test.py
--- a/core/controllers/admin_test.py
+++ b/core/controllers/admin_test.py
@@ -105,7 +105,7 @@ def test_change_configuration_property(self):
         response_dict = self.get_json('/adminhandler')
         response_config_properties = response_dict['config_properties']
         self.assertDictContainsSubset({
-            'value': True,
+            'value': False,
         }, response_config_properties[
             config_domain.IS_IMPROVEMENTS_TAB_ENABLED.name])
Repository: oppia/oppia

Issue:
Add frontend tests for debouncer service
The frontend tests for the debouncer service were flaky so we have removed them in #8649. Investigate the issue that was happening and readd the tests.


Discussion:
I'll take a look @vojtechjelinek, thanks!

Resolving patch:
diff --git a/scripts/check_frontend_coverage.py b/scripts/check_frontend_coverage.py
--- a/scripts/check_frontend_coverage.py
+++ b/scripts/check_frontend_coverage.py
@@ -102,6 +102,7 @@
     'creator-dashboard-page.constants.ts',
     'data.ts',
     'date-time-format.service.ts',
+    'debouncer.service.ts',
     'debug-info-tracker.service.ts',
     'device-info.service.ts',
     'document-attribute-customization.service.ts',


Test patch:
Repository: oppia/oppia

Issue:
Typescript checks don't work on circle CI
<!--
  - 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**
Typescript checks don't work on circle CI

**To Reproduce**
Steps to reproduce the behavior:
1. See logs on any pull request.

**Observed behavior**
```
Compiling and testing typescript...
/usr/bin/env: ‘node’: No such file or directory
Compilation successful!
```

**Expected behavior**
They should run.



Discussion:
/cc @oppia/core-maintainers 

Resolving patch:
diff --git a/scripts/typescript_checks.py b/scripts/typescript_checks.py
--- a/scripts/typescript_checks.py
+++ b/scripts/typescript_checks.py
@@ -24,6 +24,7 @@
 import sys
 
 import python_utils
+from . import common
 
 COMPILED_JS_DIR = os.path.join('local_compiled_js_for_test', '')
 TSCONFIG_FILEPATH = 'tsconfig.json'
@@ -42,7 +43,7 @@ def validate_compiled_js_dir():
 
 def compile_and_check_typescript():
     """Compiles typescript files and checks the compilation errors."""
-    node_path = os.path.join(os.pardir, 'oppia_tools/node-10.18.0')
+    node_path = common.NODE_PATH
     os.environ['PATH'] = '%s/bin:' % node_path + os.environ['PATH']
 
     validate_compiled_js_dir()


Test patch:
Repository: oppia/oppia

Issue:
Some characters in the Negative Numbers lesson page seem cut off
<!--
  - 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**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
 1. Go to 'https://www.oppia.org/math/negative-numbers'
 2. See 'Negative Numbers just got easier' is cut off.

**Observed behavior**
A clear and concise description of what you have observed.
'Negative Numbers just got easier' seems cut off.

**Expected behavior**
A clear and concise description of what you expected to happen.
'Negative Numbers just got easier' should be fully visible.

**Screenshots**
If applicable, add screenshots to help explain your problem.
![easier-curoff](https://user-images.githubusercontent.com/11008603/84357572-81184a00-abe3-11ea-9655-7eee9c485b74.png)



Discussion:

Resolving patch:
diff --git a/scripts/check_frontend_coverage.py b/scripts/check_frontend_coverage.py
--- a/scripts/check_frontend_coverage.py
+++ b/scripts/check_frontend_coverage.py
@@ -136,7 +136,6 @@
     'display-solution-modal.controller.ts',
     'drag-and-drop-html-string-editor.directive.ts',
     'drag-and-drop-positive-int-editor.directive.ts',
-    'drag-and-drop-sort-input-validation.service.ts',
     'early-quit-issue.directive.ts',
     'edit-profile-picture-modal.controller.ts',
     'edit-thumbnail-modal.controller.ts',


Test patch:
Repository: oppia/oppia

Issue:
utils.get_time_in_millisecs returns invalid values
<!--
  - 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**
Implementation of `utils.get_time_in_millisecs` is currently broken.
https://github.com/oppia/oppia/blob/c7e60d8fe471b21fb38ed6520292164fc0ed0f50/utils.py#L408-L418

Specifically, `time.mktime` is being passed in an invalid value. According to its [documentation](https://docs.python.org/2/library/time.html#time.mktime), the argument should be a `struct_time` with **_the local time_, not _the UTC time_**.

This results in return values that are off from the real time it should represent. It also makes it infeasible to convert the milliseconds back into the corresponding datetime, because the value is  invalid.


Discussion:

Resolving patch:
diff --git a/utils.py b/utils.py
--- a/utils.py
+++ b/utils.py
@@ -414,8 +414,8 @@ def get_time_in_millisecs(datetime_obj):
     Returns:
         float. The time in milliseconds since the Epoch.
     """
-    seconds = time.mktime(datetime_obj.utctimetuple()) * 1000
-    return seconds + python_utils.divide(datetime_obj.microsecond, 1000.0)
+    msecs = time.mktime(datetime_obj.timetuple()) * 1000.0
+    return msecs + python_utils.divide(datetime_obj.microsecond, 1000.0)
 
 
 def get_current_time_in_millisecs():


Test patch:
diff --git a/utils_test.py b/utils_test.py
--- a/utils_test.py
+++ b/utils_test.py
@@ -363,3 +363,17 @@ def test_require_valid_thumbnail_filename(self):
             'Expected a filename ending in svg, received name.jpg', 'name.jpg')
         filename = 'filename.svg'
         utils.require_valid_thumbnail_filename(filename)
+
+    def test_get_time_in_millisecs(self):
+        dt = datetime.datetime(2020, 6, 15)
+        msecs = utils.get_time_in_millisecs(dt)
+        self.assertEqual(
+            dt,
+            datetime.datetime.fromtimestamp(python_utils.divide(msecs, 1000.0)))
+
+    def test_get_time_in_millisecs_with_complicated_time(self):
+        dt = datetime.datetime(2020, 6, 15, 5, 18, 23, microsecond=123456)
+        msecs = utils.get_time_in_millisecs(dt)
+        self.assertEqual(
+            dt,
+            datetime.datetime.fromtimestamp(python_utils.divide(msecs, 1000.0)))
Repository: oppia/oppia

Issue:
Todo: @showtim3, Increase the coverage of question-creation-service.ts to 100% and remove it from the check_frontend_coverage.py file.
While working on the skill-editor UI, i created a service and was unable to get its coverage to 100% even after a lot of efforts. Will definitely do it later. 

Todo @Showtim3 


Discussion:

Resolving patch:
diff --git a/scripts/check_frontend_coverage.py b/scripts/check_frontend_coverage.py
--- a/scripts/check_frontend_coverage.py
+++ b/scripts/check_frontend_coverage.py
@@ -303,7 +303,6 @@
     'promo-bar.directive.ts',
     'promo-bar.service.ts',
     'python-program.tokenizer.ts',
-    'question-creation.service.ts',
     'question-difficulty-selector.directive.ts',
     'question-editor.directive.ts',
     'question-opportunities.directive.ts',


Test patch: