 
 handleTimedOutTask = (req, res, taskBody) -> errors.clientTimeout res, "The results weren't provided within the timeout"
 
-verifyClientResponse = (responseObject, res) ->
-  unless typeof responseObject is "object"
-    errors.badInput res, "The response to that query is required to be a JSON object."
-    null
-  else
-    responseObject
-
-logTaskComputation = (taskObject,taskLogObject, callback) ->
-  taskLogObject.calculationTimeMS = taskObject.calculationTimeMS
-  taskLogObject.sessions = taskObject.sessions
-  taskLogObject.save callback
-
-
-updateSessions = (taskObject,callback) ->
-  sessionIDs = _.pluck taskObject.sessions, 'sessionID'
-
-  async.map sessionIDs, retrieveOldSessionData, (err, oldScores) ->
-    if err? then callback err, {"error": "There was an error retrieving the old scores"}
-
-    oldScoreArray = _.toArray putRankingFromMetricsIntoScoreObject taskObject, oldScores
-    newScoreArray = bayes.updatePlayerSkills oldScoreArray
-    saveNewScoresToDatabase newScoreArray, callback
-
-
-saveNewScoresToDatabase = (newScoreArray, callback) ->
-  async.eachSeries newScoreArray, updateScoreInSession, (err) -> callback err,newScoreArray
-
-
-updateScoreInSession = (scoreObject,callback) ->
-  LevelSession.findOne {"_id": scoreObject.id}, (err, session) ->
-    if err? then return callback err, null
-
-    session = session.toObject()
-    newTotalScore = scoreObject.meanStrength - 1.8 * scoreObject.standardDeviation
-    scoreHistoryAddition = [Date.now(), newTotalScore]
-    updateObject =
-      meanStrength: scoreObject.meanStrength
-      standardDeviation: scoreObject.standardDeviation
-      totalScore: newTotalScore
-      $push: {scoreHistory: {$each: [scoreHistoryAddition], $slice: -1000}}
-
-    LevelSession.update {"_id": scoreObject.id}, updateObject, callback
-    log.info "New total score for session #{scoreObject.id} is #{updateObject.totalScore}"
 
 
 putRankingFromMetricsIntoScoreObject = (taskObject,scoreObject) ->


addPairwiseTaskToQueue = (taskPair, cb) ->
  LevelSession.findOne(_id:taskPair[0]).lean().exec (err, firstSession) =>
    if err? then return cb err, false
    LevelSession.find(_id:taskPair[1]).exec (err, secondSession) =>
      if err? then return cb err, false
      try
        taskPairs = generateTaskPairs(secondSession, firstSession)
      catch e
        if e then return cb e, false

      sendEachTaskPairToTheQueue taskPairs, (taskPairError) ->
        if taskPairError? then return cb taskPairError,false
        cb null, true

module.exports.resimulateAllSessions = (req, res) ->
  unless isUserAdmin req then return errors.unauthorized res, "Unauthorized. Even if you are authorized, you shouldn't do this"

  cb null, taskObject

getSessionInformation = (sessionIDString, callback) ->
  findParameters =
    _id: sessionIDString
  selectString = 'submitDate team submittedCode teamSpells levelID creator creatorName'
  query = LevelSession
  .findOne(findParameters)
  .select(selectString)
  .lean()

  query.exec (err, session) ->
    if err? then return callback err, {"error":"There was an error retrieving the session."}
    callback null, session

###
module.exports.processTaskResult = (req, res) ->
  clientResponseObject = verifyClientResponse req.body, res

