            self.loadTierBadge(tierBadge)
        )
 
-  ]
+  ]
     loadTierBadge: (tierBadge)->
       self = this
       courseBadge = self.availableBadges[tierBadge.badge_id]
       loadedBadge = new TierBadgePrototype(tierBadge.id, self, angular.copy(courseBadge))
       self.badges[courseBadge.id] = loadedBadge # add tier badge to tier
       delete self.availableBadges[courseBadge.id] # remove badge from available badges on tier
      

      $scope.courseBadges[badge.id] = courseBadge
    )

  MetricBadgePrototype = (metric, badge, attrs={})->
    this.metric = metric
    this.badge = badge
    this.create()
    this.name = badge.name
    this.metric_id = metric.id
    this.badge_id = badge.id
    this.description = badge.description
    this.point_total = badge.point_total
    this.icon = badge.icon
    this.multiple = badge.multiple

  MetricBadgePrototype.prototype =
    create: ()->
      self = this

      $http.post("/metric_badges", self.createParams()).success(
        (data,status)->
          self.id = data.existing_metric_badge.id
      )
      .error((err)->
        alert("create failed!")
        return false
      )

    createParams: ()->
      metric_id: this.metric.id,
      badge_id: this.badge.id

  TierBadgePrototype = (tier, badge, attrs={})->
    this.tier = tier
    this.badge = badge
    this.name = badge.name
