def chooserFunction(self,req):

    try:
      res = testSelectorSrvResponse()
      currentTimestamp = int(time.time())       
 
      returnWithError,modifier1,modifier2=self.loadParamDifficultyModifiers(res)
      if(returnWithError):
        return res
        
      returnWithError,userOntologyAlias=self.getUserOntologyAlias(req.username,res)
      if(returnWithError):
        return res

      returnWithError,userLanguage=self.getUserLanguage(req.username,res)
      if(returnWithError):
        return res

      returnWithError,testTypesList=self.getTestTypesFromOntology(res)
      if(returnWithError):
        return res
        
      if(req.testType==""):
        testType=self.determineTestTypeIfNotProvided(res,testTypesList,userOntologyAlias)
      else:
        if (req.testType not in testTypesList):
          res.trace.append("testType provided does not exist")
          res.error="testType provided does not exist"
          res.success=False
          return res
        else:
          testType=req.testType
      
      chosenDif,noUserPerformanceRecordsExist,userPerfOrganizedByTimestamp=self.organizeUserPerformanceByTimestampAndDetermineTestDifficulty(testType,userOntologyAlias,currentTimestamp,self.lookBackTimeStamp,res,modifier1,modifier2)
            
      returnWithError,testsOfTypeOrdered=self.getCognitiveTestsOfType(testType,userLanguage,chosenDif,res)      
      if(returnWithError):
        return res      

      finalTestFilePath,finalTestname=self.getLRUtestOfTypeAndXmlPath(testsOfTypeOrdered,noUserPerformanceRecordsExist,userPerfOrganizedByTimestamp)
      
      #Retrieve the name of the selected test
      tmpList=finalTestname.split('#')
      res.test=tmpList[1]

      #Parse the test xml file and retrieve the desired information
      rospack = rospkg.RosPack()
      localPackagePath=rospack.get_path('rapp_cognitive_exercise')
      finalTestFilePath=localPackagePath+finalTestFilePath
      res.trace.append(finalTestFilePath)
      self.retrieveDataFromTestXml(finalTestFilePath,res,userLanguage)
      res.language=userLanguage
      res.success=True

    except IndexError:
      res.trace.append("Null pointer exception.. some argument was empty")
      res.error="Null pointer exception.. some argument was empty"
      res.success=False
    except IOError:
      res.success=False
      res.trace.append("IO Error, cant open file or read data")
      res.error="IO Error, cant open file or read data"
    return res

  ## @brief Queries the MySQL database through the MySQL wrapper and returns the user's language
  # @param username [string] The username of the user as is in the MySQL database
  # @param res [rapp_platform_ros_communications::testSelectorSrvResponse::Response&] The output arguments of the service as defined in the testSelectorSrv
  #
  # @return res [rapp_platform_ros_communications::testSelectorSrvResponse::Response&] The output arguments of the service as defined in the testSelectorSrv
  # @return userLanguage [string] The user's language setting
dataset/ETHPy150Open rapp-project/rapp-platform/rapp_cognitive_exercise/src/test_selector.py/TestSelector.chooserFunction/original