@task(name=u'openedx.core.djangoapps.content.course_structures.tasks.update_course_structure')
def update_course_structure(course_key):
 from .models import CourseStructure
 if (not isinstance(course_key, basestring)):
  raise ValueError('course_key must be a string. {} is not acceptable.'.format(type(course_key)))
 course_key = CourseKey.from_string(course_key)
 try:
  structure = _generate_course_structure(course_key)
 except Exception as ex:
  log.exception('An error occurred while generating course structure: %s', ex.message)
  raise
 structure_json = json.dumps(structure['structure'])
 discussion_id_map_json = json.dumps(structure['discussion_id_map'])
 (structure_model, created) = CourseStructure.objects.get_or_create(course_id=course_key, defaults={'structure_json': structure_json, 'discussion_id_map_json': discussion_id_map_json})
 if (not created):
  structure_model.structure_json = structure_json
  structure_model.discussion_id_map_json = discussion_id_map_json
  structure_model.save()

@ task ( name = u'openedx.core.djangoapps.content.course_structures.tasks.update_course_structure' ) def update_course_structure ( course_key ) : from . models import CourseStructure if ( not isinstance ( course_key , basestring ) ) : raise ValueError ( 'course_key must be a string. {} is not acceptable.' . format ( type ( course_key ) ) ) course_key = CourseKey . from_string ( course_key ) try : structure = _generate_course_structure ( course_key ) except Exception as ex : log . exception ( 'An error occurred while generating course structure: %s' , ex . message ) raise structure_json = json . dumps ( structure [ 'structure' ] ) discussion_id_map_json = json . dumps ( structure [ 'discussion_id_map' ] ) ( structure_model , created ) = CourseStructure . objects . get_or_create ( course_id = course_key , defaults = { 'structure_json' : structure_json , 'discussion_id_map_json' : discussion_id_map_json } ) if ( not created ) : structure_model . structure_json = structure_json structure_model . discussion_id_map_json = discussion_id_map_json structure_model . save ( )
regenerates and updates the course structure for the specified course .