avg and bugfix

This commit is contained in:
Flummi 2022-12-22 07:06:30 +01:00
parent b2591bd1b6
commit 196fc337e0
2 changed files with 8 additions and 2 deletions

View File

@ -9,12 +9,16 @@ if(!empty($progress)) {
preg_match_all("/(?<task>.*): (?<act>.*) \/ (?<max>.*)/m", $progress, $tmp); preg_match_all("/(?<task>.*): (?<act>.*) \/ (?<max>.*)/m", $progress, $tmp);
for($i = 0; $i < count($tmp[0]); $i++) { for($i = 0; $i < count($tmp[0]); $i++) {
if(preg_match('/XP\:/', $tmp['task'][$i]))
continue;
$list[$i] = (object)[ $list[$i] = (object)[
'task' => trim($tmp['task'][$i]), 'task' => trim($tmp['task'][$i]),
'act' => (int)str_replace('.', '', $tmp['act'][$i]), 'act' => (int)str_replace('.', '', $tmp['act'][$i]),
'max' => (int)str_replace('.', '', $tmp['max'][$i]) 'max' => (int)str_replace('.', '', $tmp['max'][$i])
]; ];
$list[$i]->percent = round($list[$i]->act / $list[$i]->max * 100, 2); $list[$i]->percent = round($list[$i]->act / $list[$i]->max * 100, 2);
$list[$i]->left = $list[$i]->max - $list[$i]->act;
} }
usort($list, function($a, $b) { return $b->percent <=> $a->percent; }); usort($list, function($a, $b) { return $b->percent <=> $a->percent; });

View File

@ -18,6 +18,7 @@
<th>Aufgabe</th> <th>Aufgabe</th>
<th>Fortschritt</th> <th>Fortschritt</th>
<th>Ziel</th> <th>Ziel</th>
<th>&uuml;brig</th>
<th>Prozent</th> <th>Prozent</th>
</tr> </tr>
</thead> </thead>
@ -25,8 +26,9 @@
{% for($i = 0; $i < count($list); $i++): %} {% for($i = 0; $i < count($list); $i++): %}
<tr style="background-color: {{ $i >= 5 ? 'red' : 'white' }}"> <tr style="background-color: {{ $i >= 5 ? 'red' : 'white' }}">
<td>{{ $list[$i]->task }}</td> <td>{{ $list[$i]->task }}</td>
<td>{{ $list[$i]->act }}</td> <td>{{ number_format($list[$i]->act, 0, '', '.') }}</td>
<td>{{ $list[$i]->max }}</td> <td>{{ number_format($list[$i]->max, 0, '', '.') }}</td>
<td>{{ number_format($list[$i]->left, 0, '', '.') }}</td>
<td>{{ $list[$i]->percent }}</td> <td>{{ $list[$i]->percent }}</td>
</tr> </tr>
{% endfor; %} {% endfor; %}