Repository: oppia/oppia

Issue:
Add functionality to get the set of interactions that are used in an exploration.
This is a feature request for the Admin page (located at /admin).

In the Misc tab, it would be nice to have a section where you can enter an exploration ID, click a button, and get the set of interaction IDs that that exploration contains. This is much easier than clicking through all the states in the exploration manually, and is useful for determining which interactions we will need to implement in Android.

Clicking the button should make a GET request to a backend handler that fetches the exploration, extracts its interaction IDs, and returns them to the frontend for display to the user. The returned IDs should be de-duplicated. Since this is an admin feature, the backend handler should be admin-accessible only.


Discussion:
@seanlip can you assign this to me
Done!
@seanlip sorry for the delay
I will start working on this now wasn't well before so I couldn't start working on this.
No worries. Thanks for the update and I hope you are feeling better!
@seanlip can you tell where to look for the get method or there isn't any method for this particular request ? i couldn't find any in admin.py
There's no method yet. The point of this issue is to implement it (full-stack).
@seanlip  I've completed the frontend part can you help me a bit for the backend i need to understand from where i can start i was able to a couple of things like there is annotation which will restrict the corresponding api to admin handler only but couldn't fully each and every thing
You may find the [codebase overview](https://github.com/oppia/oppia/wiki/Overview-of-the-Oppia-codebase) helpful, but otherwise my recommendation is to look at existing handlers and see how they work. The "annotations" you mention are called "decorators" -- look up that concept in Python, and search the codebase to see how a decorator is implemented. Otherwise, if you have more specific questions, please ask them, but make sure that your questions are specific.
Okay i will take a look thanks🙂
@seanlip so i was able to understand a bit about the architecture just wanted to confirm that i'm moving in the right direction 
So, first of all, i have to get the exploration object from exp_fetchers using get_exploration_by_id  funtionc and every exploration object has states in which there is an interaction object where i can get the id correct?
Yes.
Hey @aggarwalpulkit596 I wanted to check: how's this issue going?
@BenHenning backend code is complete just need to show on the frontend for that I've asked a bit of help from @DubeySandeep 
Thanks @aggarwalpulkit596. Do you have a PR with the backend code that you can send my way?

Also did you mean to unassign yourself from this issue?
@BenHenning https://github.com/oppia/oppia/pull/9111 here you go
Thanks! I'm guessing you meant to refer to #9139 instead of #9111, so I reviewed & commented on that.
Hi @oppia/core-maintainers, this issue is not assigned to any project. Can you please update the same? Thanks!

Resolving patch:
diff --git a/core/controllers/admin.py b/core/controllers/admin.py
--- a/core/controllers/admin.py
+++ b/core/controllers/admin.py
@@ -2294,9 +2294,9 @@ def get(self) -> None:
             raise self.InvalidInputException('Exploration does not exist.')
 
         interaction_ids = [
-            {'id': state.interaction.id}
+            state.interaction.id
             for state in exploration.states.values()
             if state.interaction.id is not None
         ]
 
-        self.render_json({'interactions': list(interaction_ids)})
+        self.render_json({'interaction_ids': interaction_ids})


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
@@ -3015,8 +3015,7 @@ def test_interactions_by_exploration_id_handler(self) -> None:
 
         response = self.get_json(
             '/interactions', params=payload)
-        interaction_ids = sorted(
-            interaction['id'] for interaction in response['interactions'])
+        interaction_ids = response['interaction_ids']
         self.assertEqual(
             sorted(interaction_ids), ['EndExploration', 'TextInput'])