Exemplo n.º 1
0
    public function testFromDatabase()
    {
        $PDO = new PDO('sqlite::memory:');
        $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $PDO->exec('CREATE TABLE IF NOT EXISTS `' . PREFIX . 'training` (
			`accountid` int(10),
			`typeid` int(10),
			`vdot` decimal(5,2),
			`vdot_by_time` decimal(5,2)
			);
		');
        $PDO->exec('INSERT INTO `' . PREFIX . 'training` VALUES(1, 3,  0, 90)');
        // empty
        $PDO->exec('INSERT INTO `' . PREFIX . 'training` VALUES(1, 3, 50, 25)');
        // 0.5
        $PDO->exec('INSERT INTO `' . PREFIX . 'training` VALUES(1, 3, 50, 45)');
        // 0.9
        $PDO->exec('INSERT INTO `' . PREFIX . 'training` VALUES(1, 3,100, 80)');
        // 0.8, best vdot_by_time
        $PDO->exec('INSERT INTO `' . PREFIX . 'training` VALUES(2, 3, 90, 90)');
        // 1.0, other account
        $PDO->exec('INSERT INTO `' . PREFIX . 'training` VALUES(1, 5, 90, 90)');
        // 1.0, other type
        $Corrector = new VDOTCorrector();
        $Corrector->fromDatabase($PDO, 1, 3);
        $PDO->exec('DROP TABLE `' . PREFIX . 'training`');
        $this->assertEquals(0.9, $Corrector->factor());
    }
Exemplo n.º 2
0
 /**
  * Exact value
  * @codeCoverageIgnore
  * @return float
  */
 public function exactValue()
 {
     if (!is_null($this->Corrector)) {
         return $this->Corrector->factor() * $this->Value;
     }
     return $this->Value;
 }
Exemplo n.º 3
0
 /**
  * VDOT shape
  * 
  * This value is already corrected.
  * If no VDOT corrector was set, the global/static one is used.
  * 
  * @return float
  */
 public function value()
 {
     if (is_null($this->Corrector)) {
         $this->Corrector = new VDOTCorrector();
     }
     return $this->uncorrectedValue() * $this->Corrector->factor();
 }
Exemplo n.º 4
0
    protected function setUp()
    {
        $this->PDO = new PDO('sqlite::memory:');
        $this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $this->PDO->exec('CREATE TABLE IF NOT EXISTS `' . PREFIX . 'training` (
			`accountid` int(10),
			`sportid` int(10),
			`time` int(10),
			`s` int(10),
			`use_vdot` tinyint(1),
			`vdot` decimal(5,2),
			`vdot_with_elevation` decimal(5,2)
			);
		');
        VDOTCorrector::setGlobalFactor(1.0);
    }
Exemplo n.º 5
0
 /**
  * Recalculate VDOT corrector
  * @return float new factor
  */
 public function recalculateVDOTcorrector()
 {
     $Corrector = new JD\VDOTCorrector();
     $Corrector->fromDatabase(DB::getInstance(), SessionAccountHandler::getId(), Configuration::General()->competitionType());
     $this->updateVdotCorrector($Corrector->factor());
     return $Corrector->factor();
 }
Exemplo n.º 6
0
 /**
  * Init constants
  */
 private function defineConsts()
 {
     require_once FRONTEND_PATH . 'system/define.consts.php';
     Configuration::loadAll();
     \Runalyze\Calculation\JD\VDOTCorrector::setGlobalFactor(Configuration::Data()->vdotFactor());
     require_once FRONTEND_PATH . 'class.Helper.php';
 }
Exemplo n.º 7
0
 /**
  * Correction factor
  * @return string
  */
 public function correctionFactor()
 {
     $Corrector = new VDOTCorrector();
     $Corrector->fromActivity($this->Activity);
     return sprintf("%1.4f", $Corrector->factor());
 }