'use strict'

angular.module('EXAM').controller('AnswerPairText', ['$scope', '$http', function($scope, $http){
  $scope.question = new Question()

  $scope.addPairText = function(obj){
    let max = 0
    if (obj.right.length > 0){
      max = Math.max.apply(Math, obj.right.map(function(ansobj){ return ansobj.id }))
    }
    $scope.question.addPairText(obj, max)
  }

  $scope.deletePairText = function(obj, index){
    $scope.question.deleteArray(obj.left, index)
    $scope.question.deleteArray(obj.right, index)
  }

  $scope.deleteArray = function(obj, index){
    $scope.question.deleteArray(obj, index)
  }
}])