Repository: oppia/oppia
File: core/controllers/admin.py (Python)

Code before:
        """
        assert self.user_id is not None
        if constants.DEV_MODE:
            if feconf.ROLE_ID_CURRICULUM_ADMIN not in self.user.roles:
                raise Exception(
                    'User does not have enough rights to generate data.'
                )
            logging.info(
                '[ADMIN] %s generated %s number of dummy '
                'translation opportunities (explorations)'
                % (
                    self.user_id,
                    num_dummy_translation_opportunities_to_generate,
                )
            )

            # Generate a new topic, story, skill and questions id.
            topic_id = 'dummyTopicId'
            story_id = 'dummyStoryId'
            skill_id = 'dummySkillId'

            question_id_1 = 'dummyQuestionId1'
            question_id_2 = 'dummyQuestionId2'
            question_id_3 = 'dummyQuestionId3'

            # Check if our specific dummy entities exist by their hardcoded IDs.
            # Using strict=False to return None if they don't exist.
            # This makes the generator self-contained and independent of other
            # dummy generators that might create skills with similar descriptions
            # but different IDs.
            existing_skill = skill_fetchers.get_skill_by_id(
                skill_id, strict=False
            )
            initial_dummy_opportunites_generation = existing_skill is None

            if initial_dummy_opportunites_generation:
                skill = self._create_dummy_skill(
                    skill_id, 'Dummy Skill 1', '<p>Dummy Explanation 1</p>'
                )
                question_1 = self._create_dummy_question(
                    question_id_1, 'Question 1', [skill_id]
                )
                question_2 = self._create_dummy_question(
                    question_id_2, 'Question 2', [skill_id]
                )
                question_3 = self._create_dummy_question(
                    question_id_3, 'Question 3', [skill_id]
                )
                story = story_domain.Story.create_default_story(
                    story_id,
                    'Dummy Story',

Review comment (suggestion):
From what I see here, it looks like the behaviour was implemented to avoid confusion for admins.

The issue is that the functions assumes that if another a skill with the matching description exists then it must have a same hard coded id. However, other functions might be using a different hardcoded id.

Now, the confusion that current solution might cause is that if we create a new skill (with hard coded id in this function) with same description and title as some skill created by other function then it would be a confusing scenario for the admins. Does your solution address this?

There looks like 2 ways from here:
1. In your solution ensure that we use unique and contextual title and description.
2. Overhaul all admin data generation functions to use same hardcoded ids for skills with same title and description.

Code after:
        """
        assert self.user_id is not None
        if constants.DEV_MODE:
            if feconf.ROLE_ID_CURRICULUM_ADMIN not in self.user.roles:
                raise Exception(
                    'User does not have enough rights to generate data.'
                )
            logging.info(
                '[ADMIN] %s generated %s number of dummy '
                'translation opportunities (explorations)'
                % (
                    self.user_id,
                    num_dummy_translation_opportunities_to_generate,
                )
            )

            # Generate a new topic, story, skill and questions id.
            topic_id = 'dummyTopicId'
            story_id = 'dummyStoryId'
            skill_id = 'dummySkillId'

            question_id_1 = 'dummyQuestionId1'
            question_id_2 = 'dummyQuestionId2'
            question_id_3 = 'dummyQuestionId3'

            existing_skill = skill_fetchers.get_skill_by_id(
                skill_id, strict=False
            )
            initial_dummy_opportunites_generation = existing_skill is None

            if initial_dummy_opportunites_generation:
                skill = self._create_dummy_skill(
                    skill_id,
                    'Translation Opportunities Dummy Skill',
                    '<p>Dummy Explanation for Translation Opportunities</p>',
                )
                question_1 = self._create_dummy_question(
                    question_id_1, 'Question 1', [skill_id]
                )
                question_2 = self._create_dummy_question(
                    question_id_2, 'Question 2', [skill_id]
                )
                question_3 = self._create_dummy_question(
                    question_id_3, 'Question 3', [skill_id]
                )
                story = story_domain.Story.create_default_story(
                    story_id,
                    'Translation Opportunities Dummy Story',
                    'Dummy story for translation opportunities',
                    topic_id,
                    'translation-dummy-story',