public function testForVDOT20() { $this->object->setVDOT(20); $this->object->setDaysToRecognizeForLongjogs(7); $this->object->setDaysToRecognizeForWeekKilometer(7); $this->object->setMinimalDaysToRecognizeForWeekKilometer(7); $this->object->setMinimalDistanceForLongjogs(10); $this->object->setPercentageForLongjogs(0.33); $this->object->setPercentageForWeekKilometer(0.67); DB::getInstance()->insert('training', array('sportid', 'time', 'distance'), array(Configuration::General()->runningSport(), time() - 1 * DAY_IN_S, 15)); DB::getInstance()->insert('training', array('sportid', 'time', 'distance'), array(Configuration::General()->runningSport(), time() - 3 * DAY_IN_S, 15)); DB::getInstance()->insert('training', array('sportid', 'time', 'distance'), array(Configuration::General()->runningSport(), time() - 8 * DAY_IN_S, 42)); $Results = $this->object->asArray(); $this->assertEquals(30, $Results['weekkm-result']); $this->assertEquals(0.82, $Results['longjog-result'], '', 0.01); $this->assertEquals(1.0, $Results['weekkm-percentage'], '', 0.01); $this->assertEquals(0.82, $Results['longjog-percentage'], '', 0.01); $this->assertEquals(94, $Results['percentage'], '', 0.01); $this->assertEquals(94, $this->object->value()); $this->assertEquals('94 %', $this->object->valueInPercent()); $this->object->setPercentageForLongjogs(1); $this->assertEquals(82, $this->object->value()); $this->object->setDaysToRecognizeForLongjogs(14); $this->assertEquals(555, $this->object->value()); // Attention: depens on START_TIME $this->object->setMinimalDaysToRecognizeForWeekKilometer(70); $this->object->setDaysToRecognizeForWeekKilometer(70); $this->object->setPercentageForLongjogs(0.01); $this->assertEquals(29, $this->object->value()); }
/** * Add line for average and goal */ protected function addAverage() { if ($this->showsAverage()) { $BasicEndurance = new BasicEndurance(); $BasicEndurance->readSettingsFromConfiguration(); $Result = $BasicEndurance->asArray(); $Avg = new Distance($this->factorForWeekKm() * $Result['weekkm-percentage'] * $BasicEndurance->getTargetWeekKm()); $Goal = new Distance($this->factorForWeekKm() * $BasicEndurance->getTargetWeekKm()); $LabelKeys = array_keys($this->getXLabels()); $this->addThreshold('y', round($Avg->valueInPreferredUnit()), '#999'); $this->addThreshold('y', round($Goal->valueInPreferredUnit()), '#999'); $this->addAnnotation(-1, round($Avg->valueInPreferredUnit()), __('avg:') . ' ' . $Avg->string(true, 0), 0, -10); $this->addAnnotation(end($LabelKeys), round($Goal->valueInPreferredUnit()), __('goal:') . ' ' . $Goal->string(true, 0), 0, -10); } }
/** * Get fieldset for basic endurance * @return \FormularFieldset */ public function getFieldsetBasicEndurance() { $BasicEndurance = new BasicEndurance(); $BasicEndurance->readSettingsFromConfiguration(); $BEresults = $BasicEndurance->asArray(); $Strategy = new Prognosis\Daniels(); $Strategy->setupFromDatabase(); $Strategy->adjustVDOT(false); $Prognosis = new Prognosis\Prognosis(); $Prognosis->setStrategy($Strategy); $GeneralTable = ' <table class="fullwidth zebra-style"> <tbody class="top-and-bottom-border"> <tr> <td>' . __('<strong>Current VDOT</strong> <small>(based on heart rate)</small>') . '</td> <td class="r">' . round(Configuration::Data()->vdot(), 2) . '</td> <td> </td> <td>' . sprintf(__('<strong>Target kilometer per week</strong> <small>(%s weeks)</small>'), round($BasicEndurance->getDaysForWeekKm() / 7)) . '</td> <td class="r">' . Distance::format($BasicEndurance->getTargetWeekKm(), false, 0) . '</td> <td class="small">' . sprintf(__('done by %s%'), round(100 * $BEresults['weekkm-percentage'])) . '</td> <td class="small">(ø ' . Distance::format($BEresults['weekkm-result'] / $BasicEndurance->getDaysForWeekKm() * 7, false, 0) . ')</td> <td class="small">x' . $BasicEndurance->getPercentageForWeekKilometer() . '</td> <td rowspan="2" class="bottom-spacer b" style="vertical-align:middle;">= ' . round($BEresults['percentage']) . '%</td> </tr> <tr> <td>' . __('<strong>Marathon time</strong> <small>(optimal)</small>') . '</td> <td class="r">' . Duration::format($Prognosis->inSeconds(42.195)) . '</td> <td> </td> <td>' . sprintf(__('<strong>Target long run</strong> <small>(%s weeks)</small>'), round($BasicEndurance->getDaysToRecognizeForLongjogs() / 7)) . '</td> <td class="r">' . Distance::format($BasicEndurance->getRealTargetLongjogKmPerWeek(), false, 0) . '</td> <td class="small">' . sprintf(__('done by %s%'), round(100 * $BEresults['longjog-percentage'])) . '</td> <td class="small">(' . round($BEresults['longjog-result'], 1) . ' points)</td> <td class="small">x' . $BasicEndurance->getPercentageForLongjogs() . '</td> </tr> </tbody> </table>'; $LongjogTable = '<table class="fullwidth zebra-style c"> <thead> <tr> <th>' . __('Date') . '*</th> <th>' . __('Distance') . '</th> <th>' . __('Points') . '</th> </tr> </thead> <tbody>'; $IgnoredLongjogs = 0; $Longjogs = DB::getInstance()->query($BasicEndurance->getQuery(0, true))->fetchAll(); foreach ($Longjogs as $Longjog) { if ($Longjog['points'] >= 0.2) { $LongjogTable .= '<tr> <td>' . Ajax::trainingLink($Longjog['id'], date('d.m.Y', $Longjog['time'])) . '</td> <td>' . Distance::format($Longjog['distance']) . '</td> <td>' . round($Longjog['points'], 1) . ' points</td> </tr>'; } else { $IgnoredLongjogs++; } } $LongjogTable .= '<tr class="top-spacer no-zebra"> <td></td> <td></td> <td class="b">= ' . round($BEresults['longjog-result'], 1) . ' points</td> </tr> </tbody> </table>'; $LongjogTable .= '<p class="small">' . sprintf(__('* %s "long" jogs do not show up, ' . 'because they have less than 0.2 points.'), $IgnoredLongjogs) . '</p>'; $LongjogTable .= '<p class="small">' . sprintf(__('* In general, all runs with more than %s are being considered.'), Distance::format($BasicEndurance->getMinimalDistanceForLongjogs())) . '</p>'; $Fieldset = new FormularFieldset(__('Basic endurance')); $Fieldset->addBlock(__('Your basic endurance is based on your weekly kilometers and your long jogs.<br>' . 'The target is derived from the possible marathon time based on your current shape.') . '<br> '); $Fieldset->addBlock($GeneralTable); $Fieldset->addBlock(__('The points for your long runs are weighted by time and quadratic in distance. ' . 'That means, a long jog yesterday gives more points than a long jog two weeks ago ' . 'and a 30k-jog gives more points than two 20k-jogs.') . '<br> '); $Fieldset->addBlock($LongjogTable); $Fieldset->addBlock(__('The basic endurance is <strong>not</strong> from Jack Daniels.<br>' . 'It\'s our own attempt to adjust the prognosis for long distances based on your current endurance.')); return $Fieldset; }