(function(){
    angular.module('ctfApp').controller('TasksController', ['$scope', '$http', 'APIProvider', 'AppSettings', function($scope, $http, APIProvider, AppSettings) {
        $scope.apiAddress = AppSettings.apiAddress;
        APIProvider.getTasks(function(data){
            // console.log(data);
            APIProvider.getMyCompletedLevelsList(function(completed){
                $.each(data, function(key, task){
                    if (completed.indexOf(task.level) !== -1){
                        data[key].completed = true;
                    }
                    else {
                        data[key].completed = false;
                    }
                });
            });
            $scope.tasks = data;
        });
    }]);
})();