Repository: oppia/oppia

Issue:
Unable to specify response of a learner's answer when adding interaction of a question inside the skill editor
<!--
  - 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**
Unable to specify response of a learner's answer when adding interaction of a question inside the skill editor

**To Reproduce**
Steps to reproduce the behavior:
 1. Go to Topic and Skill dashboard
 2. Go to the skill tab
 3. Click on a skill to reach the skill editor
 4. Click on `Create new question`
 5. Select any difficulty and type any question
 6. Click on `add interaction` and choose any interaction such as `text input`
 5. Click save interaction and reach the **Add Response** dialog
 6. The response under `If the learner's answer...` will not be able to be specified

**Observed behavior**

![Screenshot from 2021-08-13 21-08-29](https://user-images.githubusercontent.com/43031234/129388140-151b7a98-49d4-4480-b6ea-90017516e5c0.png)
Cannot specify the response of the learners answer. (Just an dropdown arrow is shown which does nothing on click)

**Expected behavior**
We should be able to specify the responses the learner can give successfully.

**Screenshots**
![Screenshot from 2021-08-13 21-19-58](https://user-images.githubusercontent.com/43031234/129389482-f81320b9-2d73-41ce-933b-925c61de3a8b.png)
![Screenshot from 2021-08-13 21-22-17](https://user-images.githubusercontent.com/43031234/129389763-783d06dc-fa56-4e99-8458-90220bd1eb63.png)

**Desktop (please complete the following information; delete this section if the issue does not arise on desktop):**
- OS: Linux
- Browser: chrome, firefox
- Browser-version: 91.0.4472.164 , 90.0

Console errors are thrown when in preview tab of the skill editor for a skill which has questions
<!--
  - 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**
Console errors are thrown when in preview tab of the skill editor for a skill which has questions

**To Reproduce**
Steps to reproduce the behavior:
 1. Go to topics and skill dashboard
 2. Click on skills tab
 3. Open any skill which has questions
 4. Go to preview tab of the editor

**Observed behavior**
The following console error is thrown
```
ContextService should not be used outside the context of an exploration or a question.
```

**Expected behavior**
Console errors should not be present

**Screenshots**
![Screenshot from 2021-08-13 20-34-47](https://user-images.githubusercontent.com/43031234/129383836-1c80873f-7d0a-4f7f-b71b-59f6dfc96f7f.png)
![Screenshot from 2021-08-13 20-39-36](https://user-images.githubusercontent.com/43031234/129384218-47d09912-9836-4f6e-a5c3-8fece7d1928e.png)


**Desktop**
- OS: Linux
- Browser: chrome, firefox
- Browser-version: 91.0.4472.164 , 90.0


Unable to specify response of a learner's answer when adding interaction of a question inside the skill editor
<!--
  - 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**
Unable to specify response of a learner's answer when adding interaction of a question inside the skill editor

**To Reproduce**
Steps to reproduce the behavior:
 1. Go to Topic and Skill dashboard
 2. Go to the skill tab
 3. Click on a skill to reach the skill editor
 4. Click on `Create new question`
 5. Select any difficulty and type any question
 6. Click on `add interaction` and choose any interaction such as `text input`
 5. Click save interaction and reach the **Add Response** dialog
 6. The response under `If the learner's answer...` will not be able to be specified

**Observed behavior**

![Screenshot from 2021-08-13 21-08-29](https://user-images.githubusercontent.com/43031234/129388140-151b7a98-49d4-4480-b6ea-90017516e5c0.png)
Cannot specify the response of the learners answer. (Just an dropdown arrow is shown which does nothing on click)

**Expected behavior**
We should be able to specify the responses the learner can give successfully.

**Screenshots**
![Screenshot from 2021-08-13 21-19-58](https://user-images.githubusercontent.com/43031234/129389482-f81320b9-2d73-41ce-933b-925c61de3a8b.png)
![Screenshot from 2021-08-13 21-22-17](https://user-images.githubusercontent.com/43031234/129389763-783d06dc-fa56-4e99-8458-90220bd1eb63.png)

**Desktop (please complete the following information; delete this section if the issue does not arise on desktop):**
- OS: Linux
- Browser: chrome, firefox
- Browser-version: 91.0.4472.164 , 90.0



Discussion:
@kevintab95 could you look into this regression in the creator experience?
Per @seanlip this does not occur on prod, so it is a regression we need to fix. @kevintab95, could you take a look at this regression?
@kevintab95 could you look into this regression in the creator experience?

Resolving patch:
diff --git a/core/domain/draft_upgrade_services.py b/core/domain/draft_upgrade_services.py
--- a/core/domain/draft_upgrade_services.py
+++ b/core/domain/draft_upgrade_services.py
@@ -135,8 +135,13 @@ def _convert_html_in_draft_change_list(
                 if 'choices' in new_value.keys():
                     for value_index, value in enumerate(
                             new_value['choices']['value']):
-                        new_value['choices']['value'][value_index] = (
-                            conversion_fn(value))
+                        if isinstance(value, dict) and 'html' in value:
+                            new_value['choices']['value'][value_index][
+                                'html'
+                            ] = conversion_fn(value['html'])
+                        elif isinstance(value, python_utils.BASESTRING):
+                            new_value['choices']['value'][value_index] = (
+                                conversion_fn(value))
             elif (change.property_name ==
                   exp_domain.STATE_PROPERTY_WRITTEN_TRANSLATIONS):
                 for content_id, language_code_to_written_translation in (


Test patch:
diff --git a/core/domain/draft_upgrade_services_test.py b/core/domain/draft_upgrade_services_test.py
--- a/core/domain/draft_upgrade_services_test.py
+++ b/core/domain/draft_upgrade_services_test.py
@@ -185,6 +185,25 @@ def test_convert_states_v46_dict_to_v47_dict(self):
                     ' svg_filename-with-value="&amp;quot;igage.svg&amp;quot;">'
                     '</oppia-noninteractive-svgdiagram>'
                 ).to_dict()
+            }), exp_domain.ExplorationChange({
+                'cmd': 'edit_state_property',
+                'state_name': 'Intro',
+                'property_name': 'widget_customization_args',
+                'new_value': {
+                    'choices': {
+                        'value': [
+                            state_domain.SubtitledHtml(
+                                'ca_choices_0',
+                                '<oppia-noninteractive-svgdiagram '
+                                'svg_filename-with-value="&amp;quot;'
+                                'img12.svg&amp;quot;" alt-with-value="'
+                                '&amp;quot;Image&amp;quot;">'
+                                '</oppia-noninteractive-svgdiagram>'
+                            ).to_dict()
+                        ]
+                    },
+                    'showChoicesInShuffledOrder': {'value': True}
+                }
             })
         ]
         # Migrate exploration to state schema version 47.