       .sortBy((a) -> a.ilo.ilo_number)
       .value()
 
+    unit.findGroupById = (id) ->
+      _.find unit.groups, (grp) -> grp.id == id
+
     # Actually make the request to refresh and load unit data
     unit.refresh(onSuccess, onFailure)
     unit

  unitService.mapGroupToUnit = (unit, group) ->
    group.tutorial = -> unit.tutorialFromId(group.tutorial_id)
    group.unit = -> unit
    group

  #

        unit.tutorials = _.map(unit.tutorials, (tutorial) ->
          tutorialService.createInstanceFrom(tutorial, unit)
        )
        unit.groups = _.map(unit.groups, (grp) -> unitService.mapGroupToUnit(unit, grp))

        # Add a sequence from the order fetched from server
        unit.task_definitions = _.map(unit.task_definitions, (taskDef, index, list) ->
          taskDef.seq = index
