/**
  * Finish result table
  */
 protected function finishResultTable()
 {
     $this->ResultTable .= '</tbody></table>';
     if ($_POST['model'] == 'robert-bock' && $this->PrognosisStrategies['robert-bock'] instanceof Prognosis\Bock) {
         $K = $this->PrognosisStrategies['robert-bock']->getK();
         $e = $this->PrognosisStrategies['robert-bock']->getE();
         $this->ResultTable .= HTML::info(sprintf(__('The results give the constants K = %f and e = %f.'), $K, $e)) . '<br>';
         if (!$this->PrognosisObject->isValid()) {
             $this->ResultTable .= HTML::warning(sprintf(__('K must be between %u and %u, e between %f and %f.'), Prognosis\Bock::K_LOWER_BOUND, Prognosis\Bock::K_UPPER_BOUND, Prognosis\Bock::E_LOWER_BOUND, Prognosis\Bock::E_UPPER_BOUND));
         }
     }
 }
 /**
  * Init calculations
  */
 protected function runCalculations()
 {
     foreach ($this->Distances as $km) {
         $Prognosis = $this->PrognosisObject->inSeconds($km);
         $PB = new PersonalBest($km, DB::getInstance(), false);
         $PB->lookupWithDetails();
         $VDOTprognosis = new VDOT();
         $VDOTprognosis->fromPace($km, $Prognosis);
         $VDOTpb = new VDOT();
         $VDOTpb->fromPace($km, $PB->seconds());
         $PacePrognosis = new Pace($Prognosis, $km, Pace::MIN_PER_KM);
         $PacePB = new Pace($PB->seconds(), $km, Pace::MIN_PER_KM);
         $this->Prognoses[] = array('distance' => Distance::format($km, $km <= 3), 'prognosis' => Duration::format($Prognosis), 'prognosis-pace' => $PacePrognosis->valueWithAppendix(), 'prognosis-vdot' => $VDOTprognosis->uncorrectedValue(), 'diff' => !$PB->exists() ? '-' : ($PB->seconds() > $Prognosis ? '+ ' : '- ') . Duration::format(abs(round($PB->seconds() - $Prognosis))), 'diff-class' => $PB->seconds() > $Prognosis ? 'plus' : 'minus', 'pb' => $PB->seconds() > 0 ? Duration::format($PB->seconds()) : '-', 'pb-pace' => $PB->seconds() > 0 ? $PacePB->valueWithAppendix() : '-', 'pb-vdot' => $PB->seconds() > 0 ? $VDOTpb->uncorrectedValue() : '-', 'pb-date' => $PB->seconds() > 0 ? date('d.m.Y', $PB->timestamp()) : '-');
     }
 }
 /**
  * Init calculations
  */
 protected function runCalculations()
 {
     foreach ($this->Distances as $km) {
         $Prognosis = $this->PrognosisObject->inSeconds($km);
         $PB = new PersonalBest($km, DB::getInstance(), false);
         $PB->lookupWithDetails();
         $VDOTprognosis = new VDOT();
         $VDOTprognosis->fromPace($km, $Prognosis);
         $VDOTpb = new VDOT();
         $VDOTpb->fromPace($km, $PB->seconds());
         $PacePrognosis = new Pace($Prognosis, $km, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport()));
         $PacePB = new Pace($PB->seconds(), $km, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport()));
         $DateWithLink = Ajax::trainingLink($PB->activityId(), date('d.m.Y', $PB->timestamp()), true);
         $this->Prognoses[] = array('distance' => (new Distance($km))->stringAuto(), 'prognosis' => Duration::format($Prognosis), 'prognosis-pace' => $PacePrognosis->valueWithAppendix(), 'prognosis-vdot' => $VDOTprognosis->uncorrectedValue(), 'diff' => !$PB->exists() ? '-' : ($PB->seconds() > $Prognosis ? '+ ' : '- ') . Duration::format(abs(round($PB->seconds() - $Prognosis))), 'diff-class' => $PB->seconds() > $Prognosis ? 'plus' : 'minus', 'pb' => $PB->seconds() > 0 ? Duration::format($PB->seconds()) : '-', 'pb-pace' => $PB->seconds() > 0 ? $PacePB->valueWithAppendix() : '-', 'pb-vdot' => $PB->seconds() > 0 ? $VDOTpb->uncorrectedValue() : '-', 'pb-date' => $PB->seconds() > 0 ? $DateWithLink : '-');
     }
 }
    /**
     * 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>&nbsp;</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&#37;'), round(100 * $BEresults['weekkm-percentage'])) . '</td>
						<td class="small">(&oslash; ' . 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']) . '&#37;</td>
					</tr>
					<tr>
						<td>' . __('<strong>Marathon time</strong> <small>(optimal)</small>') . '</td>
						<td class="r">' . Duration::format($Prognosis->inSeconds(42.195)) . '</td>
						<td>&nbsp;</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&#37;'), 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 &quot;long&quot; 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>&nbsp;');
        $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>&nbsp;');
        $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;
    }
Example #5
0
<?php

use Runalyze\Calculation\Prognosis;
use Runalyze\Configuration;
use Runalyze\Activity\Duration;
use Runalyze\Activity\Distance;
$Strategy = new Prognosis\Daniels();
$Strategy->adjustVDOT(false);
$Prognosis = new Prognosis\Prognosis();
$Prognosis->setStrategy($Strategy);
?>

<table id="jd-tables-prognosis" class="zebra-style c" style="width: 700px;">
	<thead>
		<tr>
			<th>VDOT</th>
		<?php 
foreach ($this->Configuration()->value('pace_distances') as $km) {
    ?>
		<?php 
    if ($km >= 1) {
        ?>
			<th><?php 
        echo (new Distance($km))->stringAuto();
        ?>
</th>
		<?php 
    }
    ?>
		<?php 
}
Example #6
0
use Runalyze\Calculation\Prognosis;
use Runalyze\Configuration;
use Runalyze\Activity\Distance;
if (is_dir(FRONTEND_PATH . '../plugin/RunalyzePluginStat_Wettkampf')) {
    $Factory = new PluginFactory();
    $WKplugin = $Factory->newInstance('RunalyzePluginStat_Wettkampf');
}
if (!isset($distance)) {
    $distance = 10;
}
$DataFailed = false;
$Prognosis = array();
$Results = array();
$Strategy = new Prognosis\Daniels();
$Strategy->adjustVDOT(false);
$PrognosisObj = new Prognosis\Prognosis();
$PrognosisObj->setStrategy($Strategy);
if (START_TIME != time()) {
    $Data = Cache::get('prognosePlotData');
    if (is_null($Data)) {
        $withElevation = Configuration::Vdot()->useElevationCorrection();
        $Data = DB::getInstance()->query('
			SELECT
				YEAR(FROM_UNIXTIME(`time`)) as `y`,
				MONTH(FROM_UNIXTIME(`time`)) as `m`,
				SUM(' . JD\Shape::mysqlVDOTsum($withElevation) . ')/SUM(' . JD\Shape::mysqlVDOTsumTime($withElevation) . ') as `vdot`
			FROM `' . PREFIX . 'training`
			WHERE
				`vdot`>0 AND use_vdot<>0
			GROUP BY `y`, `m`
			ORDER BY `y` ASC, `m` ASC')->fetchAll();