def config_course_cohorts_legacy(course, discussions, cohorted, cohorted_discussions=None, auto_cohort_groups=None, always_cohort_inline_discussions=None):
 def to_id(name):
  '\n        Helper method to convert a discussion topic name to a database identifier\n        '
  return topic_name_to_id(course, name)
 topics = dict(((name, {'sort_key': 'A', 'id': to_id(name)}) for name in discussions))
 course.discussion_topics = topics
 config = {'cohorted': cohorted}
 if (cohorted_discussions is not None):
  config['cohorted_discussions'] = [to_id(name) for name in cohorted_discussions]
 if (auto_cohort_groups is not None):
  config['auto_cohort_groups'] = auto_cohort_groups
 if (always_cohort_inline_discussions is not None):
  config['always_cohort_inline_discussions'] = always_cohort_inline_discussions
 course.cohort_config = config
 try:
  modulestore().update_item(course, ModuleStoreEnum.UserID.test)
 except NotImplementedError:
  pass

def config_course_cohorts_legacy ( course , discussions , cohorted , cohorted_discussions = None , auto_cohort_groups = None , always_cohort_inline_discussions = None ) : def to_id ( name ) : return topic_name_to_id ( course , name ) topics = dict ( ( ( name , { 'sort_key' : 'A' , 'id' : to_id ( name ) } ) for name in discussions ) ) course . discussion_topics = topics config = { 'cohorted' : cohorted } if ( cohorted_discussions is not None ) : config [ 'cohorted_discussions' ] = [ to_id ( name ) for name in cohorted_discussions ] if ( auto_cohort_groups is not None ) : config [ 'auto_cohort_groups' ] = auto_cohort_groups if ( always_cohort_inline_discussions is not None ) : config [ 'always_cohort_inline_discussions' ] = always_cohort_inline_discussions course . cohort_config = config try : modulestore ( ) . update_item ( course , ModuleStoreEnum . UserID . test ) except NotImplementedError : pass
given a course with no discussion set up .