       taskDef = $scope.unit.taskDef(taskDefId) if taskDefId?
       $scope.filters.taskDefinition = taskDef
       refreshData() if $scope.isTaskDefMode
-      $scope.applyFilters()
+      applyFilters()
     # Set new taskDefinitionIdSelected if task def mode and taskDefAbbr set
     setTaskDefFromTaskKey = (taskKey) ->
       # Only applicable in taskDefMode

      taskDefinition: null
    }, $scope.filters)
    # Sets the new filteredTasks variable
    $scope.applyFilters = ->
      filteredTasks = $filter('tasksOfTaskDefinition')($scope.tasks, $scope.filters.taskDefinition)
      filteredTasks = $filter('tasksInTutorials')(filteredTasks, $scope.filters.tutorials)
      filteredTasks = $filter('tasksWithStudentName')(filteredTasks, $scope.filters.studentName)

      $scope.filters.taskDefinition = taskDef
    setTaskDefFromTaskKey($scope.taskData.taskKey)
    # Student Name options
    $scope.studentNameChanged = applyFilters
    # Finds a task (or null) given its task key
    findTaskForTaskKey = (key) -> _.find($scope.tasks, (t) -> t.hasTaskKey(key))
    # Initially not watching the task key
