 filterForPoolType = (exercises, pool_type) ->
   _.filter exercises, (exercise) -> -1 isnt exercise.pool_types.indexOf(pool_type)
 
-groupBySortedSections = ( exercises ) ->
+
+groupBySortedSections = ( ecosystemId, exercises ) ->
   sections = {}
-  grouped = _.groupBy(exercises, getChapterSection)
+  grouped = _.groupBy(exercises, (exercise) ->
+    getChapterSection(ecosystemId, exercise)
+  )
   for section in _.sortBy( _.keys(grouped), ContentHelpers.chapterSectionToNumber)
     sections[section] = grouped[section]
   sections

    getPageExerciseTypes: (pageId) ->
      _.unique _.flatten _.map @_exercises[pageId], @exports.getExerciseTypes

    # poolTypes: (exercise) ->
    #   _.without( exercise.pool_types, 'all_exercises')

    allForPage: (pageId) ->
      @_exercises[pageId] or []


  LO: ['lo', 'aplo']
  GENERIC: ['blooms', 'dok', 'length']

getChapterSection = (ecosystemId, exercise) ->
  for tag in exercise.tags when tag.type is 'cnxmod'
    section = TocStore.findWhere(ecosystemId, uuid: tag.data)
    return section.chapter_section.join('.') if section?

getTagName = (tag) ->
  name = _.compact([tag.name, tag.description]).join(' ')
