Aktuelle Abt.
= (int) $aktabt ?>
/ = (int) $maxvalue ?>
Aktuelle Gruppe
= (int) $akt_subabt_admin ?>
/ = (int) $max_subabt ?>
Aktuelle Gruppe
= $akt_subabt ?>
/ = $max_subabt ?>
Noch keine Datensätze vorhanden.
prepare($sql); // In PHP 8.1+, you can simply pass an array to execute() // We merge the year with the IDs into one flat array $params = array_merge([$current_year], $ids); $stmt->execute($params); $noten = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); } $rangNote = intval(db_get_var($mysqli, "SELECT `value` FROM $tableVar WHERE `name` = ?", ['rangNote'])); $orderBestRang = db_get_var($mysqli, "SELECT `value` FROM $tableVar WHERE `name` = ?", ['orderBestRang']); $okValuesOrderBestRang = ["ASC", "DESC"]; $rangOrderOk = in_array($orderBestRang, $okValuesOrderBestRang) && intval($rangNote) > 0; $notenIndexed = []; foreach ($noten as $sn) { $notenIndexed[$sn['person_id']][$sn['geraet_id']][$sn['note_bezeichnung_id']][$sn['run_number']] = $sn['value']; } $stmt->close(); // Extended Disciplines, contains the 0 disc $disciplinesExtended = array_merge( [["id" => 0, "name" => "None"]], $disciplines ); foreach ($grouped as $abteilung => $entries_group): // Nur sortieren, wenn der Benutzer nicht 'Admin' ist if (!$isAdmin || $live_view_admin) { $entries_with_calculated_index = []; // Optional: Vorab-Caching der MAX-Indices, um DB-Abfragen im Loop zu vermeiden // (Nur aktivieren, wenn $entries_group sehr groß ist und Performance-Probleme auftreten) $maxStartIndexCache = []; foreach ($entries_group as $row) { $old_geraet_id = $row['geraetId']; if ($live_view_admin) { $old_geraet_index = $indexed_array_geraete_id_index[$row['geraetId']]; $shifted_geraet_index = $old_geraet_index + $akt_subabt - 1; if ($shifted_geraet_index > $max_subabt) { $shifted_geraet_index -= $max_subabt; } $row['geraetId'] = $indexed_array_geraete_index_id[$shifted_geraet_index]; } $rohstartindex = intval($row['startIndex']); $abtId = intval($row['abtId']); // Hole maxStartIndex (mit Caching-Logik optional) if (!isset($maxStartIndexCache["$abtId-$old_geraet_id "])) { $maxStartIndexCache["$abtId-$old_geraet_id"] = db_get_var($mysqli, "SELECT COUNT(*) FROM `$tableTeilnehmendeAbt` WHERE abteilung_id = ? AND geraet_id = ?", [$abtId, $old_geraet_id]); } $maxstartindex = $maxStartIndexCache["$abtId-$old_geraet_id"]; // Sicherheit: Vermeiden Sie Division durch Null oder Modulo durch 0 if ($maxstartindex < 1) { $maxstartindex = 1; } // The order shift depends on the number of rotations the group has made $rotation_shift = $akt_subabt - 1; $calculedstartindex = $rohstartindex - $rotation_shift; // Sicherstellen, dass das Ergebnis positiv ist (PHP Modulo kann negative Ergebnisse liefern) // Wenn das Ergebnis negativ ist, addieren wir maxstartindex if ($calculedstartindex < 1) { $calculedstartindex += $maxstartindex; } // Kopie der Zeile erstellen, um Originaldaten nicht zu verändern $row['calculedstartindex'] = $calculedstartindex; $entries_with_calculated_index[] = $row; } // Sortieren nach dem berechneten Startindex usort($entries_with_calculated_index, fn($a, $b) => $a['calculedstartindex'] <=> $b['calculedstartindex']); $entries_to_display = $entries_with_calculated_index; } else { $entries_to_display = $entries_group; } $arrayIndexedNoten = []; foreach ($entries_group as $row): if ($isAdmin && $rangOrderOk) { $rangNotenArray[$indexedProgrammIds[$row['programm'] ?? ''] ?? ''][$row['id']] = isset($notenIndexed[$row['id']][0][$rangNote][1]) ? (float) $notenIndexed[$row['id']][0][$rangNote][1] : null; } foreach ($disciplinesExtended as $discipline): // Check if the current user/admin is allowed to see this specific discipline if ($discipline['id'] === 0 || $selectedFreigabeId == $discipline['id'] || $isAdmin): // 2. Now iterate through the scoring configurations for this discipline foreach ($notenConfig as $snC) { if (intval($snC['pro_geraet']) === 1 && intval($discipline['id']) === 0) { continue; } if (intval($snC['pro_geraet']) !== 1) { $allowedGeraete = !empty($snC['geraete_json']) ? json_decode($snC['geraete_json'], true) : []; if (!in_array($discipline['id'], $allowedGeraete)) { continue; } } $defaultValue = $snC['default_value'] ?? 0; $runsJSON = !empty($snC['anzahl_laeufe_json']) ? json_decode($snC['anzahl_laeufe_json'], true) : []; $runs = $runsJSON[$discipline['id']][$indexedProgrammIds[$row['programm'] ?? ''] ?? ''] ?? $runsJSON[$discipline['id']]['all'] ?? $runsJSON["default"] ?? 1; for ($r = 1; $r <= $runs; $r++): $note = $notenIndexed[$row['id']][$discipline['id']][$snC['id']][$r] ?? null; $normalizedNote = ($note !== null) ? number_format($note, $snC['nullstellen'] ?? 2) : null; $arrayIndexedNoten[intval($row['id'])][intval($discipline['id'])][intval($snC['id'])][intval($r)] = ["value" => $normalizedNote]; endfor; } endif; endforeach; endforeach; $table_data_geraet_label = ''; $extra_table_classes = ''; if ($live_view_admin) { $shifted_geraet_index = $indexed_array_geraete_id_index[$abteilung] + $akt_subabt - 1; if ($shifted_geraet_index > $max_subabt) { $shifted_geraet_index -= $max_subabt; } $shifted_geraet_id = $indexed_array_geraete_index_id[$shifted_geraet_index]; $table_data_geraet_label = ' data-geraet-index="' . $shifted_geraet_index . '"'; $extra_table_classes = ' shiftedGeraetTable'; } ?>| = htmlspecialchars($header_data['title']) ?> |
|---|
| >
|
= $count ?> = ($count > 1) ? $personMehrzahl : $personEinzahl ?>
Gesamt: = $total_count ?> = ($total_count > 1) ? $personMehrzahl : $personEinzahl ?>