def load_demo(collection_id):
 delete_demo(collection_id)
 if (not collection_domain.Collection.is_demo_collection_id(collection_id)):
  raise Exception(('Invalid demo collection id %s' % collection_id))
 demo_filepath = os.path.join(feconf.SAMPLE_COLLECTIONS_DIR, feconf.DEMO_COLLECTIONS[collection_id])
 if demo_filepath.endswith('yaml'):
  yaml_content = utils.get_file_contents(demo_filepath)
 else:
  raise Exception(('Unrecognized file path: %s' % demo_filepath))
 collection = save_new_collection_from_yaml(feconf.SYSTEM_COMMITTER_ID, yaml_content, collection_id)
 publish_collection_and_update_user_profiles(feconf.SYSTEM_COMMITTER_ID, collection_id)
 index_collections_given_ids([collection_id])
 for collection_node in collection.nodes:
  exp_id = collection_node.exploration_id
  if (exp_services.get_exploration_by_id(exp_id, strict=False) is None):
   exp_services.load_demo(exp_id)
 logging.info(('Collection with id %s was loaded.' % collection_id))

def load_demo ( collection_id ) : delete_demo ( collection_id ) if ( not collection_domain . Collection . is_demo_collection_id ( collection_id ) ) : raise Exception ( ( 'Invalid demo collection id %s' % collection_id ) ) demo_filepath = os . path . join ( feconf . SAMPLE_COLLECTIONS_DIR , feconf . DEMO_COLLECTIONS [ collection_id ] ) if demo_filepath . endswith ( 'yaml' ) : yaml_content = utils . get_file_contents ( demo_filepath ) else : raise Exception ( ( 'Unrecognized file path: %s' % demo_filepath ) ) collection = save_new_collection_from_yaml ( feconf . SYSTEM_COMMITTER_ID , yaml_content , collection_id ) publish_collection_and_update_user_profiles ( feconf . SYSTEM_COMMITTER_ID , collection_id ) index_collections_given_ids ( [ collection_id ] ) for collection_node in collection . nodes : exp_id = collection_node . exploration_id if ( exp_services . get_exploration_by_id ( exp_id , strict = False ) is None ) : exp_services . load_demo ( exp_id ) logging . info ( ( 'Collection with id %s was loaded.' % collection_id ) )
loads a demo exploration .