def test_initialization(self): """Tests init method.""" user_learner_progress = (learner_progress_domain.LearnerProgress( [], [], [], [], [], [], [], [], [], [], [], [], [], [], [])) self.assertEqual( user_learner_progress.incomplete_exp_summaries, []) self.assertEqual( user_learner_progress.incomplete_collection_summaries, []) self.assertEqual( user_learner_progress.partially_learnt_topic_summaries, []) self.assertEqual(user_learner_progress.completed_exp_summaries, []) self.assertEqual( user_learner_progress.completed_collection_summaries, []) self.assertEqual( user_learner_progress.completed_story_summaries, []) self.assertEqual( user_learner_progress.learnt_topic_summaries, []) self.assertEqual( user_learner_progress.topics_to_learn_summaries, []) self.assertEqual( user_learner_progress.exploration_playlist_summaries, []) self.assertEqual( user_learner_progress.collection_playlist_summaries, []) self.assertEqual( user_learner_progress.all_topic_summaries, []) self.assertEqual( user_learner_progress.untracked_topic_summaries, [])
def test_initialization(self): """Tests init method.""" user_learner_progress = (learner_progress_domain.LearnerProgress( [], [], [], [], [], [])) self.assertEqual(user_learner_progress.incomplete_exp_summaries, []) self.assertEqual(user_learner_progress.incomplete_collection_summaries, []) self.assertEqual(user_learner_progress.completed_exp_summaries, []) self.assertEqual(user_learner_progress.completed_collection_summaries, []) self.assertEqual(user_learner_progress.exploration_playlist_summaries, []) self.assertEqual(user_learner_progress.collection_playlist_summaries, [])
def get_activity_progress(user_id): """Returns the progress of the learners - the explorations and collections completed by the user and those in progress. Args: user_id: str. The id of the learner. Returns: (LearnerProgress, dict, list(str)). The first return value is the learner progress domain object corresponding to the particular learner. The second return value is the numbers of the activities that are no longer present. It contains four keys: - incomplete_explorations: int. The number of incomplete explorations no longer present. - incomplete_collections: int. The number of incomplete collections no longer present. - completed_explorations: int. The number of completed explorations no longer present. - completed_collections: int. The number of completed collections no longer present. The third return value is the titles of the collections to which new explorations have been added. """ activity_ids_in_learner_dashboard = ( get_learner_dashboard_activities(user_id)) completed_exploration_ids = ( activity_ids_in_learner_dashboard.completed_exploration_ids) completed_collection_ids = ( activity_ids_in_learner_dashboard.completed_collection_ids) incomplete_exploration_ids = ( activity_ids_in_learner_dashboard.incomplete_exploration_ids) incomplete_collection_ids = ( activity_ids_in_learner_dashboard.incomplete_collection_ids) exploration_playlist_ids = ( activity_ids_in_learner_dashboard.exploration_playlist_ids) collection_playlist_ids = ( activity_ids_in_learner_dashboard.collection_playlist_ids) activity_models = ( datastore_services.fetch_multiple_entities_by_ids_and_models([ ('ExpSummaryModel', incomplete_exploration_ids), ('CollectionSummaryModel', incomplete_collection_ids), ('ExpSummaryModel', completed_exploration_ids), ('CollectionSummaryModel', completed_collection_ids), ('ExpSummaryModel', exploration_playlist_ids), ('CollectionSummaryModel', collection_playlist_ids) ])) incomplete_exploration_models = activity_models[0] incomplete_collection_models = activity_models[1] completed_exploration_models = activity_models[2] completed_collection_models = activity_models[3] exploration_playlist_models = activity_models[4] collection_playlist_models = activity_models[5] incomplete_exp_summaries = ([ exp_services.get_exploration_summary_from_model(model) if model else None for model in incomplete_exploration_models ]) incomplete_collection_summaries = ([ collection_services.get_collection_summary_from_model(model) if model else None for model in incomplete_collection_models ]) completed_exp_summaries = ([ exp_services.get_exploration_summary_from_model(model) if model else None for model in completed_exploration_models ]) completed_collection_summaries = ([ collection_services.get_collection_summary_from_model(model) if model else None for model in completed_collection_models ]) exploration_playlist_summaries = ([ exp_services.get_exploration_summary_from_model(model) if model else None for model in exploration_playlist_models ]) collection_playlist_summaries = ([ collection_services.get_collection_summary_from_model(model) if model else None for model in collection_playlist_models ]) filtered_incomplete_exp_summaries, nonexistent_incomplete_exp_ids = ( _get_filtered_incomplete_exp_summaries(incomplete_exp_summaries, incomplete_exploration_ids)) filtered_completed_exp_summaries, nonexistent_completed_exp_ids = ( _get_filtered_completed_exp_summaries(completed_exp_summaries, completed_exploration_ids)) (filtered_completed_collection_summaries, nonexistent_completed_collection_ids, completed_to_incomplete_collection_summaries) = ( _get_filtered_completed_collection_summaries( user_id, completed_collection_summaries, completed_collection_ids)) completed_to_incomplete_collection_titles = [] for collection_summary in completed_to_incomplete_collection_summaries: incomplete_collection_summaries.append(collection_summary) completed_to_incomplete_collection_titles.append( collection_summary.title) incomplete_collection_ids.append(collection_summary.id) (filtered_incomplete_collection_summaries, nonexistent_incomplete_collection_ids) = ( _get_filtered_incomplete_collection_summaries( incomplete_collection_summaries, incomplete_collection_ids)) filtered_exp_playlist_summaries, nonexistent_playlist_exp_ids = ( _get_filtered_exp_playlist_summaries(exploration_playlist_summaries, exploration_playlist_ids)) (filtered_collection_playlist_summaries, nonexistent_playlist_collection_ids) = ( _get_filtered_collection_playlist_summaries( collection_playlist_summaries, collection_playlist_ids)) number_of_deleted_activities = { 'incomplete_explorations': len(nonexistent_incomplete_exp_ids), 'incomplete_collections': len(nonexistent_incomplete_collection_ids), 'completed_explorations': len(nonexistent_completed_exp_ids), 'completed_collections': len(nonexistent_completed_collection_ids), 'exploration_playlist': len(nonexistent_playlist_exp_ids), 'collection_playlist': len(nonexistent_playlist_collection_ids) } _remove_activity_ids_from_incomplete_list( user_id, nonexistent_incomplete_exp_ids, nonexistent_incomplete_collection_ids) _remove_activity_ids_from_completed_list( user_id, nonexistent_completed_exp_ids, nonexistent_completed_collection_ids) _remove_activity_ids_from_playlist(user_id, nonexistent_playlist_exp_ids, nonexistent_playlist_collection_ids) learner_progress = learner_progress_domain.LearnerProgress( filtered_incomplete_exp_summaries, filtered_incomplete_collection_summaries, filtered_completed_exp_summaries, filtered_completed_collection_summaries, filtered_exp_playlist_summaries, filtered_collection_playlist_summaries) return (learner_progress, number_of_deleted_activities, completed_to_incomplete_collection_titles)