def test_nunmber_of_explorations_cannot_exceed_max(self):
        # Add MAX_LEARNER_PLAYLIST_ACTIVITY_COUNT explorations.
        exp_ids = [
            'SAMPLE_EXP_ID_%s' % index
            for index in range(0, MAX_LEARNER_PLAYLIST_ACTIVITY_COUNT)
        ]
        for exp_id in exp_ids:
            learner_progress_services.add_exp_to_learner_playlist(
                self.user_id, exp_id)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         exp_ids)

        # Now if we try to add another exploration at the end of the list,
        # it shouldn't be added as the list length would exceed
        # MAX_LEARNER_PLAYLIST_ACTIVITY_COUNT.
        learner_playlist_services.mark_exploration_to_be_played_later(
            self.user_id,
            'SAMPLE_EXP_ID_MAX',
            position_to_be_inserted=MAX_LEARNER_PLAYLIST_ACTIVITY_COUNT)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         exp_ids)

        # Also if we try adding another exploration at no specific location,
        # it shouldn't be added as the list length would exceed
        # MAX_LEARNER_PLAYLIST_ACTIVITY_COUNT.
        learner_playlist_services.mark_exploration_to_be_played_later(
            self.user_id, 'SAMPLE_EXP_ID_MAX')
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         exp_ids)
    def test_subscribed_exploration_cannot_be_added_to_playlist(self):
        # Subscribe to exploration.
        subscription_services.subscribe_to_exploration(self.user_id,
                                                       self.EXP_ID_0)

        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [])
        # Now if we try to add the same exploration, it shouldn't be added.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_0)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [])
    def test_multiple_explorations_are_added_correctly_to_playlist(self):
        # Test adding two explorations to the learner playlist.
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [])

        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_0)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0])

        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_1)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0, self.EXP_ID_1])
    def test_incomplete_exploration_is_not_added_to_learner_playlist(self):
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_0)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0])

        state_name = 'state_name'
        version = 1
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_1, state_name, version)

        # Test that the exploration added to the in progress list doesn't get
        # added to the learner playlist.
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0])
    def test_single_exploration_is_added_correctly_to_playlist(self):
        # Test adding a single exploration_id to learner playlist.
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [])
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_0)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0])

        # Test adding a single exploration_id to learner playlist at
        # a specific position.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_1, position_to_be_inserted=0)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_1, self.EXP_ID_0])
    def post(self, activity_type, activity_id):
        position_to_be_inserted_in = self.payload.get('index')

        belongs_to_completed_or_incomplete_list = False
        playlist_limit_exceeded = False
        belongs_to_subscribed_activities = False

        if activity_type == constants.ACTIVITY_TYPE_EXPLORATION:
            (
                belongs_to_completed_or_incomplete_list,
                playlist_limit_exceeded,
                belongs_to_subscribed_activities) = (
                    learner_progress_services.add_exp_to_learner_playlist(
                        self.user_id, activity_id,
                        position_to_be_inserted=position_to_be_inserted_in))
        elif activity_type == constants.ACTIVITY_TYPE_COLLECTION:
            (
                belongs_to_completed_or_incomplete_list,
                playlist_limit_exceeded,
                belongs_to_subscribed_activities) = (
                    learner_progress_services.
                    add_collection_to_learner_playlist(
                        self.user_id, activity_id,
                        position_to_be_inserted=position_to_be_inserted_in))

        self.values.update({
            'belongs_to_completed_or_incomplete_list': (
                belongs_to_completed_or_incomplete_list),
            'playlist_limit_exceeded': playlist_limit_exceeded,
            'belongs_to_subscribed_activities': (
                belongs_to_subscribed_activities)
        })

        self.render_json(self.values)
    def test_can_see_exploration_playlist(self):
        self.login(self.VIEWER_EMAIL)

        response = self.get_json(feconf.LEARNER_DASHBOARD_DATA_URL)
        self.assertEqual(len(response['exploration_playlist']), 0)

        self.save_new_default_exploration(
            self.EXP_ID_1, self.owner_id, title=self.EXP_TITLE_1)
        self.publish_exploration(self.owner_id, self.EXP_ID_1)

        learner_progress_services.add_exp_to_learner_playlist(
            self.viewer_id, self.EXP_ID_1)
        response = self.get_json(feconf.LEARNER_DASHBOARD_DATA_URL)
        self.assertEqual(len(response['exploration_playlist']), 1)
        self.assertEqual(
            response['exploration_playlist'][0]['id'], self.EXP_ID_1)
        self.logout()
Exemple #8
0
    def test_remove_exploration_from_learner_playlist(self):
        self.login(self.VIEWER_EMAIL)

        # Add explorations to the learner playlist.
        learner_progress_services.add_exp_to_learner_playlist(
            self.viewer_id, self.EXP_ID_1)
        learner_progress_services.add_exp_to_learner_playlist(
            self.viewer_id, self.EXP_ID_2)
        self.assertEqual(
            learner_playlist_services.get_all_exp_ids_in_learner_playlist(
                self.viewer_id), [self.EXP_ID_1, self.EXP_ID_2])

        # Remove an exploration.
        self.delete_json(
            python_utils.STR(
                '%s/%s/%s' %
                (feconf.LEARNER_PLAYLIST_DATA_URL,
                 constants.ACTIVITY_TYPE_EXPLORATION, self.EXP_ID_1)))
        self.assertEqual(
            learner_playlist_services.get_all_exp_ids_in_learner_playlist(
                self.viewer_id), [self.EXP_ID_2])

        # Removing the same exploration again has no effect.
        self.delete_json(
            python_utils.STR(
                '%s/%s/%s' %
                (feconf.LEARNER_PLAYLIST_DATA_URL,
                 constants.ACTIVITY_TYPE_EXPLORATION, self.EXP_ID_1)))
        self.assertEqual(
            learner_playlist_services.get_all_exp_ids_in_learner_playlist(
                self.viewer_id), [self.EXP_ID_2])

        # Remove the second exploration.
        self.delete_json(
            python_utils.STR(
                '%s/%s/%s' %
                (feconf.LEARNER_PLAYLIST_DATA_URL,
                 constants.ACTIVITY_TYPE_EXPLORATION, self.EXP_ID_2)))
        self.assertEqual(
            learner_playlist_services.get_all_exp_ids_in_learner_playlist(
                self.viewer_id), [])

        self.logout()
    def test_get_ids_of_activities_in_learner_dashboard(self):
        # Add activities to the completed section.
        learner_progress_services.mark_exploration_as_completed(
            self.user_id, self.EXP_ID_0)
        learner_progress_services.mark_collection_as_completed(
            self.user_id, self.COL_ID_0)

        # Add activities to the incomplete section.
        state_name = 'state name'
        version = 1
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_1, state_name, version)
        learner_progress_services.mark_collection_as_incomplete(
            self.user_id, self.COL_ID_1)

        # Add activities to the playlist section.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_3)
        learner_progress_services.add_collection_to_learner_playlist(
            self.user_id, self.COL_ID_3)

        # Get the ids of all the activities.
        activity_ids = (
            learner_progress_services.get_learner_dashboard_activities(  # pylint: disable=line-too-long
                self.user_id))

        self.assertEqual(activity_ids.completed_exploration_ids,
                         [self.EXP_ID_0])
        self.assertEqual(activity_ids.completed_collection_ids,
                         [self.COL_ID_0])
        self.assertEqual(activity_ids.incomplete_exploration_ids,
                         [self.EXP_ID_1])
        self.assertEqual(activity_ids.incomplete_collection_ids,
                         [self.COL_ID_1])
        self.assertEqual(activity_ids.exploration_playlist_ids,
                         [self.EXP_ID_3])
        self.assertEqual(activity_ids.collection_playlist_ids, [self.COL_ID_3])
    def test_adding_exisiting_exploration_changes_order_of_explorations(self):
        # Test adding the exploration_id if it is already in
        # learner_playlist.exploration_ids.
        # Add the first exploration to the second position.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_0)
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_1)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0, self.EXP_ID_1])

        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_0, position_to_be_inserted=1)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_1, self.EXP_ID_0])
    def test_get_learner_dashboard_ids(self):
        self.login(self.VIEWER_EMAIL)

        self.save_new_default_exploration(
            self.EXP_ID_1, self.owner_id, title=self.EXP_TITLE_1)
        self.publish_exploration(self.owner_id, self.EXP_ID_1)
        self.save_new_default_exploration(
            self.EXP_ID_2, self.owner_id, title=self.EXP_TITLE_2)
        self.publish_exploration(self.owner_id, self.EXP_ID_2)
        self.save_new_default_exploration(
            self.EXP_ID_3, self.owner_id, title=self.EXP_TITLE_3)
        self.publish_exploration(self.owner_id, self.EXP_ID_3)

        self.save_new_default_collection(
            self.COL_ID_1, self.owner_id, title=self.COL_TITLE_1)
        self.publish_collection(self.owner_id, self.COL_ID_1)
        self.save_new_default_collection(
            self.COL_ID_2, self.owner_id, title=self.COL_TITLE_2)
        self.publish_collection(self.owner_id, self.COL_ID_2)
        self.save_new_default_collection(
            self.COL_ID_3, self.owner_id, title=self.COL_TITLE_3)
        self.publish_collection(self.owner_id, self.COL_ID_3)

        state_name = 'state_name'
        version = 1

        learner_progress_services.mark_exploration_as_completed(
            self.viewer_id, self.EXP_ID_1)
        learner_progress_services.mark_exploration_as_incomplete(
            self.viewer_id, self.EXP_ID_2, state_name, version)
        learner_progress_services.add_exp_to_learner_playlist(
            self.viewer_id, self.EXP_ID_3)

        learner_progress_services.mark_collection_as_completed(
            self.viewer_id, self.COL_ID_1)
        learner_progress_services.mark_collection_as_incomplete(
            self.viewer_id, self.COL_ID_2)
        learner_progress_services.add_collection_to_learner_playlist(
            self.viewer_id, self.COL_ID_3)

        response = self.get_json(feconf.LEARNER_DASHBOARD_IDS_DATA_URL)
        learner_dashboard_activity_ids = (
            response['learner_dashboard_activity_ids'])

        self.assertEqual(
            learner_dashboard_activity_ids['completed_exploration_ids'],
            [self.EXP_ID_1])
        self.assertEqual(
            learner_dashboard_activity_ids['incomplete_exploration_ids'],
            [self.EXP_ID_2])
        self.assertEqual(
            learner_dashboard_activity_ids['exploration_playlist_ids'],
            [self.EXP_ID_3])

        self.assertEqual(
            learner_dashboard_activity_ids['completed_collection_ids'],
            [self.COL_ID_1])
        self.assertEqual(
            learner_dashboard_activity_ids['incomplete_collection_ids'],
            [self.COL_ID_2])
        self.assertEqual(
            learner_dashboard_activity_ids['collection_playlist_ids'],
            [self.COL_ID_3])
    def test_get_learner_dashboard_ids(self):
        self.login(self.VIEWER_EMAIL)

        self.save_new_default_exploration(self.EXP_ID_1,
                                          self.owner_id,
                                          title=self.EXP_TITLE_1)
        self.publish_exploration(self.owner_id, self.EXP_ID_1)
        self.save_new_default_exploration(self.EXP_ID_2,
                                          self.owner_id,
                                          title=self.EXP_TITLE_2)
        self.publish_exploration(self.owner_id, self.EXP_ID_2)
        self.save_new_default_exploration(self.EXP_ID_3,
                                          self.owner_id,
                                          title=self.EXP_TITLE_3)
        self.publish_exploration(self.owner_id, self.EXP_ID_3)

        self.save_new_default_collection(self.COL_ID_1,
                                         self.owner_id,
                                         title=self.COL_TITLE_1)
        self.publish_collection(self.owner_id, self.COL_ID_1)
        self.save_new_default_collection(self.COL_ID_2,
                                         self.owner_id,
                                         title=self.COL_TITLE_2)
        self.publish_collection(self.owner_id, self.COL_ID_2)
        self.save_new_default_collection(self.COL_ID_3,
                                         self.owner_id,
                                         title=self.COL_TITLE_3)
        self.publish_collection(self.owner_id, self.COL_ID_3)

        self.save_new_topic(self.TOPIC_ID_1,
                            self.owner_id,
                            name=self.TOPIC_NAME_1,
                            url_fragment='topic-one',
                            description='A new topic',
                            canonical_story_ids=[],
                            additional_story_ids=[],
                            uncategorized_skill_ids=[],
                            subtopics=[self.subtopic_0],
                            next_subtopic_id=1)
        self.save_new_story(self.STORY_ID_1, self.owner_id, self.TOPIC_ID_1)
        topic_services.add_canonical_story(self.owner_id, self.TOPIC_ID_1,
                                           self.STORY_ID_1)

        topic_services.publish_story(self.TOPIC_ID_1, self.STORY_ID_1,
                                     self.admin_id)
        topic_services.publish_topic(self.TOPIC_ID_1, self.admin_id)

        self.save_new_topic(self.TOPIC_ID_2,
                            self.owner_id,
                            name=self.TOPIC_NAME_2,
                            url_fragment='topic-two',
                            description='A new topic',
                            canonical_story_ids=[],
                            additional_story_ids=[],
                            uncategorized_skill_ids=[],
                            subtopics=[self.subtopic_1],
                            next_subtopic_id=1)
        self.save_new_story(self.STORY_ID_2, self.owner_id, self.TOPIC_ID_2)
        topic_services.add_canonical_story(self.owner_id, self.TOPIC_ID_2,
                                           self.STORY_ID_2)

        topic_services.publish_story(self.TOPIC_ID_2, self.STORY_ID_2,
                                     self.admin_id)
        topic_services.publish_topic(self.TOPIC_ID_2, self.admin_id)

        self.save_new_topic(self.TOPIC_ID_3,
                            self.owner_id,
                            name=self.TOPIC_NAME_3,
                            url_fragment='topic-three',
                            description='A new topic',
                            canonical_story_ids=[],
                            additional_story_ids=[],
                            uncategorized_skill_ids=[],
                            subtopics=[self.subtopic_1],
                            next_subtopic_id=1)
        self.save_new_story(self.STORY_ID_3, self.owner_id, self.TOPIC_ID_3)
        topic_services.add_canonical_story(self.owner_id, self.TOPIC_ID_3,
                                           self.STORY_ID_3)

        topic_services.publish_story(self.TOPIC_ID_3, self.STORY_ID_3,
                                     self.admin_id)
        topic_services.publish_topic(self.TOPIC_ID_3, self.admin_id)

        state_name = 'state_name'
        version = 1

        learner_progress_services.mark_exploration_as_completed(
            self.viewer_id, self.EXP_ID_1)
        learner_progress_services.mark_exploration_as_incomplete(
            self.viewer_id, self.EXP_ID_2, state_name, version)
        learner_progress_services.add_exp_to_learner_playlist(
            self.viewer_id, self.EXP_ID_3)

        learner_progress_services.mark_collection_as_completed(
            self.viewer_id, self.COL_ID_1)
        learner_progress_services.mark_collection_as_incomplete(
            self.viewer_id, self.COL_ID_2)
        learner_progress_services.add_collection_to_learner_playlist(
            self.viewer_id, self.COL_ID_3)

        learner_progress_services.mark_story_as_completed(
            self.viewer_id, self.STORY_ID_1)

        learner_progress_services.mark_topic_as_learnt(self.viewer_id,
                                                       self.TOPIC_ID_1)
        learner_progress_services.record_topic_started(self.viewer_id,
                                                       self.TOPIC_ID_2)
        learner_progress_services.validate_and_add_topic_to_learn_goal(
            self.viewer_id, self.TOPIC_ID_3)

        response = self.get_json(feconf.LEARNER_DASHBOARD_IDS_DATA_URL)
        learner_dashboard_activity_ids = (
            response['learner_dashboard_activity_ids'])

        self.assertEqual(
            learner_dashboard_activity_ids['completed_exploration_ids'],
            [self.EXP_ID_1])
        self.assertEqual(
            learner_dashboard_activity_ids['incomplete_exploration_ids'],
            [self.EXP_ID_2])
        self.assertEqual(
            learner_dashboard_activity_ids['exploration_playlist_ids'],
            [self.EXP_ID_3])

        self.assertEqual(
            learner_dashboard_activity_ids['completed_collection_ids'],
            [self.COL_ID_1])
        self.assertEqual(
            learner_dashboard_activity_ids['incomplete_collection_ids'],
            [self.COL_ID_2])
        self.assertEqual(
            learner_dashboard_activity_ids['collection_playlist_ids'],
            [self.COL_ID_3])

        self.assertEqual(learner_dashboard_activity_ids['completed_story_ids'],
                         [self.STORY_ID_1])

        self.assertEqual(learner_dashboard_activity_ids['learnt_topic_ids'],
                         [self.TOPIC_ID_1])
        self.assertEqual(
            learner_dashboard_activity_ids['partially_learnt_topic_ids'],
            [self.TOPIC_ID_2])
        self.assertEqual(learner_dashboard_activity_ids['topic_ids_to_learn'],
                         [self.TOPIC_ID_3])
Exemple #13
0
    def test_mark_exploration_to_be_played_later(self):
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [])

        # Add an exploration to the learner playlist.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_0)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0])

        # Add another exploration.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_1)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0, self.EXP_ID_1])

        # Add the first exploration in a different position.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_0, 1)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_1, self.EXP_ID_0])

        # Add the first exploration in the first position.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_0, 0)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0, self.EXP_ID_1])

        # Add an exploration to the in progress list of the user.
        state_name = 'state_name'
        version = 1
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_3, state_name, version)

        # Test that the exploration added to the in progress list doesn't get
        # added to the learner playlist.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_3)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [self.EXP_ID_0, self.EXP_ID_1])

        # Empty the learner playlist.
        learner_playlist_services.remove_exploration_from_learner_playlist(
            self.user_id, self.EXP_ID_0)
        learner_playlist_services.remove_exploration_from_learner_playlist(
            self.user_id, self.EXP_ID_1)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         [])

        # Test that the length of the learner playlist doesn't exceed
        # MAX_LEARNER_PLAYLIST_ACTIVITY_COUNT.
        # List of explorations to be added.
        exp_ids = [
            'SAMPLE_EXP_ID_%s' % index
            for index in range(0, MAX_LEARNER_PLAYLIST_ACTIVITY_COUNT)
        ]
        for exp_id in exp_ids:
            learner_progress_services.add_exp_to_learner_playlist(
                self.user_id, exp_id)
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         exp_ids)

        # Now if we try adding another exploration, it shouldn't be added as the
        # list length would exceed MAX_LEARNER_PLAYLIST_ACTIVITY_COUNT.
        learner_playlist_services.mark_exploration_to_be_played_later(
            self.user_id, 'SAMPLE_EXP_ID')

        # The list still remains the same.
        self.assertEqual(self._get_all_learner_playlist_exp_ids(self.user_id),
                         exp_ids)
    def test_get_activity_progress(self):
        # Add activities to the completed section.
        learner_progress_services.mark_exploration_as_completed(
            self.user_id, self.EXP_ID_0)
        learner_progress_services.mark_collection_as_completed(
            self.user_id, self.COL_ID_0)

        # Add activities to the incomplete section.
        state_name = 'state name'
        version = 1
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_1, state_name, version)
        learner_progress_services.mark_collection_as_incomplete(
            self.user_id, self.COL_ID_1)

        # Add activities to the playlist section.
        learner_progress_services.add_exp_to_learner_playlist(
            self.user_id, self.EXP_ID_3)
        learner_progress_services.add_collection_to_learner_playlist(
            self.user_id, self.COL_ID_3)

        # Get the progress of the user.
        activity_progress = learner_progress_services.get_activity_progress(
            self.user_id)

        incomplete_exp_summaries = (
            activity_progress[0].incomplete_exp_summaries)
        incomplete_collection_summaries = (
            activity_progress[0].incomplete_collection_summaries)
        completed_exp_summaries = (
            activity_progress[0].completed_exp_summaries)
        completed_collection_summaries = (
            activity_progress[0].completed_collection_summaries)
        exploration_playlist_summaries = (
            activity_progress[0].exploration_playlist_summaries)
        collection_playlist_summaries = (
            activity_progress[0].collection_playlist_summaries)

        self.assertEqual(len(incomplete_exp_summaries), 1)
        self.assertEqual(len(incomplete_collection_summaries), 1)
        self.assertEqual(len(completed_exp_summaries), 1)
        self.assertEqual(len(completed_collection_summaries), 1)
        self.assertEqual(len(exploration_playlist_summaries), 1)
        self.assertEqual(len(collection_playlist_summaries), 1)

        self.assertEqual(incomplete_exp_summaries[0].title, 'Sillat Suomi')
        self.assertEqual(incomplete_collection_summaries[0].title,
                         'Introduce Oppia')
        self.assertEqual(completed_exp_summaries[0].title,
                         'Bridges in England')
        self.assertEqual(completed_collection_summaries[0].title, 'Bridges')
        self.assertEqual(exploration_playlist_summaries[0].title,
                         'Welcome Oppia')
        self.assertEqual(collection_playlist_summaries[0].title,
                         'Welcome Oppia Collection')

        # Delete an exploration in the completed section.
        exp_services.delete_exploration(self.owner_id, self.EXP_ID_0)
        # Delete an exploration in the incomplete section.
        exp_services.delete_exploration(self.owner_id, self.EXP_ID_1)
        # Delete an exploration in the playlist section.
        exp_services.delete_exploration(self.owner_id, self.EXP_ID_3)
        # Add an exploration to a collection that has already been completed.
        collection_services.update_collection(
            self.owner_id, self.COL_ID_0, [{
                'cmd': collection_domain.CMD_ADD_COLLECTION_NODE,
                'exploration_id': self.EXP_ID_2
            }], 'Add new exploration')

        # Get the progress of the user.
        activity_progress = learner_progress_services.get_activity_progress(
            self.user_id)

        # Check that the exploration is no longer present in the incomplete
        # section.
        self.assertEqual(len(activity_progress[0].incomplete_exp_summaries), 0)
        # Check that the dashboard records the exploration deleted in the
        # completed section.
        self.assertEqual(activity_progress[1]['completed_explorations'], 1)
        # Check that the dashboard records the exploration deleted in the
        # incomplete section.
        self.assertEqual(activity_progress[1]['incomplete_explorations'], 1)
        # Check that the dashboard records the exploration deleted in the
        # playlist section.
        self.assertEqual(activity_progress[1]['exploration_playlist'], 1)

        incomplete_collection_summaries = (
            activity_progress[0].incomplete_collection_summaries)

        # Check that the collection to which a new exploration has been added
        # has been moved to the incomplete section.
        self.assertEqual(len(incomplete_collection_summaries), 2)
        self.assertEqual(incomplete_collection_summaries[1].title, 'Bridges')
        # Check that the dashboard has recorded the change in the collection.
        self.assertEqual(activity_progress[2], ['Bridges'])

        # Now suppose the user has completed the collection. It should be added
        # back to the completed section.
        learner_progress_services.mark_collection_as_completed(
            self.user_id, self.COL_ID_0)

        # Delete a collection in the completed section.
        collection_services.delete_collection(self.owner_id, self.COL_ID_0)
        # Delete a collection in the incomplete section.
        collection_services.delete_collection(self.owner_id, self.COL_ID_1)
        # Delete a collection in the playlist section.
        collection_services.delete_collection(self.owner_id, self.COL_ID_3)

        # Get the progress of the user.
        activity_progress = learner_progress_services.get_activity_progress(
            self.user_id)

        # Check that the dashboard records the collection deleted in the
        # completed section.
        self.assertEqual(activity_progress[1]['completed_collections'], 1)
        # Check that the dashboard records the collection deleted in the
        # incomplete section.
        self.assertEqual(activity_progress[1]['incomplete_collections'], 1)
        # Check that the dashboard records the collection deleted in the
        # playlist section.
        self.assertEqual(activity_progress[1]['collection_playlist'], 1)