         }
       )
     )
-    params
-
-  $scope.tierBadgesParams = ()->
-    params = []
-    angular.forEach($scope.gradedMetrics, (metric, index)->
-      angular.forEach(metric.tiers, (tier, index)->
-        angular.forEach(tier.badges, (badge, index)->
-          params.push {
-            name: badge.name,
-            tier_id: tier.id,
-            metric_id: tier.metric_id,
-            id: badge.id,
-            badge_id: badge.badge.id,
-            description: badge.description,
-            point_total: badge.point_total,
-            icon: badge.icon,
-            multiple: badge.multiple
-          }
-        )
-      )
-    )
-    params
-    
+    return params
+
   $scope.gradedRubricParams = ()->
     {
       points_given: $scope.pointsGiven(),

           self.loadTierBadge(tierBadge)
       )

  ]

      $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
