       for course in courses
         course.newConcepts = _.difference(course.concepts, alreadyCoveredConcepts)
         alreadyCoveredConcepts = _.union(course.concepts, alreadyCoveredConcepts)
-        console.log course.campaignID, course.newConcepts
     accountManager: ->
       @accountManagerFullName = "#{@accountManager?.firstName} #{@accountManager?.lastName}"
+    dataReady: ->
+      console.log "Data ready!", @dataReady
     
   methods:
     submitEmail: (e) ->
-      $.ajax
-        type: 'GET',
-        url: '/db/user'
-        data: {email: @teacherEmail}
-        success: @fetchCompleteUser
-        error: (data) => noty text: 'Failed to find user by that email', type: 'error'
+      @fetchData().then =>
+        @dataReady = true
+    
+    fetchByEmail: ->
+      new Promise (accept, reject) =>
+        reject("No email provided!") if _.isEmpty(@teacherEmail)
+        $.ajax
+          type: 'GET',
+          url: '/db/user'
+          data: {email: @teacherEmail}
+          success: (data) => accept(data)
+          error: (data) =>
+            noty text: 'Failed to find user by that email', type: 'error'
+            reject(data)
 
     displayReport: (e) ->
       @fetchLinesOfCode().then @finishDisplayReport

  template: require('templates/admin/outcomes-report-view')()
  data: ->
    accountManager: me.toJSON()
    teacherEmail: 'robin+teacher@codecombat.com' # TODO: Don't hardcode this. And add get-by-email endpoint.
    # teacherEmail: '568e7f2552eea226005180b3' # TODO: Don't hardcode this. And add get-by-email endpoint.
    teacher: null
    teacherFullName: null
    accountManagerFullName: null

      window.currentView = undefined
      application.router.openView(resultView)

    fetchData: ->
      @fetchByEmail().then (trimTeacher) =>
        @fetchCompleteUser(trimTeacher).then (teacher) =>
          @teacher = teacher
          Promise.all([
            @fetchTrialRequest(teacher).then (trialRequests) =>
              @trialRequest = trialRequests[0]
            @fetchClassrooms(teacher).then (classrooms) =>
              @classrooms = classrooms
              Promise.all @classrooms.map (classroom) =>
                @fetchStudentSessions(classroom).then (sessions) =>
                  Vue.set classroom, 'sessions', sessions
            Promise.all([
              @fetchCourseInstances(teacher).then (courseInstances) =>
                @courseInstances = courseInstances
              @fetchCourses().then (courses) =>
                @courses = courses
            ]).then ([courseInstances, courses]) =>
              courseIDs = _.uniq courseInstances.map (courseInstance) =>
                courseInstance.courseID
              indexedCourses = _.indexBy(courses, '_id')
              @courses = utils.sortCourses(courseIDs.map (courseID) =>
                indexedCourses[courseID]
              )
          ])
    
    fetchCompleteUser: (data) ->
      new Promise (accept, reject) ->
        user = new User(data)
        user.fetch().then (data) ->
          return accept(data)
        , (error) ->
          return reject(error) if error
    
    fetchTrialRequest: (teacher) ->
      new Promise (accept, reject) ->
        trialRequests = new TrialRequests()
        trialRequests.fetchByApplicant(teacher._id).then (data) ->
          if data.length is 0
            noty text: "WARNING: No trial request found for that user!", type: 'error'
            return reject("WARNING: No trial request found for that user!")
          return accept(data)
        , (error) ->
          return reject(error) if error

    fetchClassrooms: (teacher) ->
      new Promise (accept, reject) ->
        classrooms = new Classrooms()
        classrooms.fetchByOwner(teacher._id).then (data) ->
          accept(data)
        , (error) ->
          reject(error)

    fetchCourseInstances: (teacher) ->
      new Promise (accept, reject) ->
        courseInstances = new CourseInstances()
        courseInstances.fetchByOwner(teacher._id).then (data) ->
          accept(data)
        , (error) ->
          reject(error)

    fetchCourses: ->
      new Promise (accept, reject) ->
        courses = new Courses()
        courses.fetch().then (data) ->
          accept(data)
        , (error) ->
          reject(error)
    
    fetchStudentSessions: (classroom) ->
      new Promise (accept, reject) ->
        sessions = new LevelSessions()
        jqxhrs = sessions.fetchForAllClassroomMembers(new Classroom(classroom))
        Promise.all(jqxhrs.map (jqxhr) -> new Promise(jqxhr.then)).then (responses) ->
          return accept(_.union.apply(_, responses))
          
    fetchLinesOfCode: ->
      $.ajax
        type: 'GET',
