def delete(self, activity_type, activity_id): if activity_type == constants.ACTIVITY_TYPE_EXPLORATION: learner_progress_services.remove_exp_from_incomplete_list( self.user_id, activity_id) elif activity_type == constants.ACTIVITY_TYPE_COLLECTION: learner_progress_services.remove_collection_from_incomplete_list( self.user_id, activity_id) self.render_json(self.values)
def delete(self, activity_type, activity_id): """Removes exploration or collection from incomplete list. Args: activity_type: str. The activity type. Currently, it can take values "exploration" or "collection". activity_id: str. The ID of the activity to be deleted. """ if activity_type == constants.ACTIVITY_TYPE_EXPLORATION: learner_progress_services.remove_exp_from_incomplete_list( self.user_id, activity_id) elif activity_type == constants.ACTIVITY_TYPE_COLLECTION: learner_progress_services.remove_collection_from_incomplete_list( self.user_id, activity_id) self.render_json(self.values)
def test_remove_collection_from_incomplete_list(self): self.assertEqual(self._get_all_incomplete_collection_ids(self.user_id), []) # Add two collections to the incomplete list. learner_progress_services.mark_collection_as_incomplete( self.user_id, self.COL_ID_0) learner_progress_services.mark_collection_as_incomplete( self.user_id, self.COL_ID_1) self.assertEqual(self._get_all_incomplete_collection_ids(self.user_id), [self.COL_ID_0, self.COL_ID_1]) # Remove one collection. learner_progress_services.remove_collection_from_incomplete_list( self.user_id, self.COL_ID_0) self.assertEqual(self._get_all_incomplete_collection_ids(self.user_id), [self.COL_ID_1]) # Removing the same collection again has no effect. learner_progress_services.remove_collection_from_incomplete_list( self.user_id, self.COL_ID_0) self.assertEqual(self._get_all_incomplete_collection_ids(self.user_id), [self.COL_ID_1]) # Removing another collection. learner_progress_services.remove_collection_from_incomplete_list( self.user_id, self.COL_ID_1) self.assertEqual(self._get_all_incomplete_collection_ids(self.user_id), [])
def delete(self, activity_type, activity_id): """Removes exploration, collection, story or topic from incomplete list. Args: activity_type: str. The activity type. Currently, it can take values "exploration", "collection", "story" or "topic". activity_id: str. The ID of the activity to be deleted. """ if activity_type == constants.ACTIVITY_TYPE_EXPLORATION: learner_progress_services.remove_exp_from_incomplete_list( self.user_id, activity_id) elif activity_type == constants.ACTIVITY_TYPE_COLLECTION: learner_progress_services.remove_collection_from_incomplete_list( self.user_id, activity_id) elif activity_type == constants.ACTIVITY_TYPE_STORY: learner_progress_services.remove_story_from_incomplete_list( self.user_id, activity_id) elif activity_type == constants.ACTIVITY_TYPE_LEARN_TOPIC: learner_progress_services.remove_topic_from_partially_learnt_list( self.user_id, activity_id) self.render_json(self.values)
def post(self): """Handles POST requests.""" collection_id = self.payload.get('collection_id') learner_progress_services.remove_collection_from_incomplete_list( self.user_id, collection_id) self.render_json(self.values)