Example #1
0
    def test_remove_exp_from_incomplete_list_handler(self):
        """Test handler for removing explorations from the partially completed
        list.
        """
        self.login(self.USER_EMAIL)

        state_name = 'state_name'
        version = 1

        # Add two explorations to the partially completed list.
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_0, state_name, version)
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_1, state_name, version)
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(self.user_id),
            [self.EXP_ID_0, self.EXP_ID_1])

        # Remove one exploration.
        self.testapp.delete(
            str('%s/%s/%s' %
                (feconf.LEARNER_INCOMPLETE_ACTIVITY_DATA_URL,
                 constants.ACTIVITY_TYPE_EXPLORATION, self.EXP_ID_0)))
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(self.user_id),
            [self.EXP_ID_1])

        # Remove another exploration.
        self.testapp.delete(
            str('%s/%s/%s' %
                (feconf.LEARNER_INCOMPLETE_ACTIVITY_DATA_URL,
                 constants.ACTIVITY_TYPE_EXPLORATION, self.EXP_ID_1)))
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(self.user_id),
            [])
Example #2
0
    def test_exp_incomplete_event_handler(self):
        """Test handler for leaving an exploration incomplete."""

        self.login(self.USER_EMAIL)
        response = self.testapp.get(feconf.LIBRARY_INDEX_URL)
        csrf_token = self.get_csrf_token_from_response(response)

        payload = {
            'client_time_spent_in_secs': 0,
            'params': {},
            'session_id': '1PZTCw9JY8y-8lqBeuoJS2ILZMxa5m8N',
            'state_name': 'middle',
            'version': 1
        }

        # Add the incomplete exploration id to the incomplete list.
        self.post_json(
            '/explorehandler/exploration_maybe_leave_event/%s' % self.EXP_ID_0,
            payload, csrf_token)
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(self.user_id),
            [self.EXP_ID_0])

        # Adding the exploration again has no effect.
        self.post_json(
            '/explorehandler/exploration_maybe_leave_event/%s' % self.EXP_ID_0,
            payload, csrf_token)
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(self.user_id),
            [self.EXP_ID_0])

        payload = {
            'client_time_spent_in_secs': 0,
            'collection_id': self.COL_ID_1,
            'params': {},
            'session_id': '1PZTCw9JY8y-8lqBeuoJS2ILZMxa5m8N',
            'state_name': 'middle',
            'version': 1
        }

        # If the exploration is played in the context of a collection, the
        # collection is also added to the incomplete list.
        self.post_json(
            '/explorehandler/exploration_maybe_leave_event/%s' %
            self.EXP_ID_1_0,  # pylint: disable=line-too-long
            payload,
            csrf_token)
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(self.user_id),
            [self.EXP_ID_0, self.EXP_ID_1_0])
        self.assertEqual(
            learner_progress_services.get_all_incomplete_collection_ids(
                self.user_id), [self.COL_ID_1])
Example #3
0
    def test_remove_exp_from_incomplete_list_handler(self):
        """Test handler for removing explorations from the partially completed
        list.
        """

        self.login(self.USER_EMAIL)
        response = self.testapp.get(feconf.LIBRARY_INDEX_URL)
        csrf_token = self.get_csrf_token_from_response(response)

        state_name = 'state_name'
        version = 1

        # Add two explorations to the partially completed list.
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_0, state_name, version)
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_1, state_name, version)
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(
                self.user_id), [self.EXP_ID_0, self.EXP_ID_1])

        payload = {
            'exploration_id': self.EXP_ID_0
        }

        # Remove one exploration.
        self.post_json(
            '%s/remove_in_progress_exploration' % feconf.LEARNER_DASHBOARD_URL,
            payload, csrf_token)
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(
                self.user_id), [self.EXP_ID_1])

        payload = {
            'exploration_id': self.EXP_ID_1
        }

        # Remove another exploration.
        self.post_json(
            '%s/remove_in_progress_exploration' % feconf.LEARNER_DASHBOARD_URL,
            payload, csrf_token)
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(
                self.user_id), [])
    def test_get_all_incomplete_exp_ids(self):
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(self.user_id),
            [])

        state_name = 'state name'
        version = 1

        # Add an exploration to the incomplete list.
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_0, state_name, version)
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(self.user_id),
            [self.EXP_ID_0])

        # Add another exploration.
        learner_progress_services.mark_exploration_as_incomplete(
            self.user_id, self.EXP_ID_1, state_name, version)
        self.assertEqual(
            learner_progress_services.get_all_incomplete_exp_ids(self.user_id),
            [self.EXP_ID_0, self.EXP_ID_1])