MSIN-4554 — Enhance team-related question handling in distribution print functions. Implement logic to ensure team names are correctly retrieved and displayed based on participant roles. Increment version code to 4.72.955 to reflect these changes.
This commit is contained in:
@ -312,6 +312,7 @@ function fxBibSaveDistPrintOrient($int_eve_id, $strOrient) {
|
||||
|
||||
/**
|
||||
* MSIN-4512 — Valeur cellule PDF pour une clé optionnelle.
|
||||
* MSIN-4554 — nom_equipe : pec (comme assignation) ; que: déjà enrichies en équipe via fxBibGetDistPrintQuestionAnswers.
|
||||
*/
|
||||
function fxBibDistPrintResolveColValue($strKey, array $row, array $tabAnswersByQue, $strLangue = 'fr') {
|
||||
$strKey = trim((string)$strKey);
|
||||
@ -328,7 +329,17 @@ function fxBibDistPrintResolveColValue($strKey, array $row, array $tabAnswersByQ
|
||||
if ($strKey === 'par_sexe') {
|
||||
return fxBibDistPrintSexeLabel($row['par_sexe'] ?? '', $strLangue);
|
||||
}
|
||||
// MSIN-4554 — Champ cœur : même priorité que l'écran d'assignation.
|
||||
if ($strKey === 'nom_equipe') {
|
||||
$strPec = trim((string)($row['pec_nom_equipe'] ?? ''));
|
||||
if ($strPec !== '') {
|
||||
return $strPec;
|
||||
}
|
||||
return trim((string)($row['par_nom_equipe'] ?? ''));
|
||||
}
|
||||
if (preg_match('/^que:(\d+)$/', $strKey, $m)) {
|
||||
// MSIN-4554 — Sur épreuve équipe les réponses (dont nom d'équipe) sont
|
||||
// déjà enrichies dans fxBibGetDistPrintQuestionAnswers.
|
||||
return trim((string)($tabAnswersByQue[(int)$m[1]] ?? ''));
|
||||
}
|
||||
|
||||
|
||||
@ -10717,9 +10717,37 @@ function fxBibDistPrintAnswerKey(array $row) {
|
||||
return $intParLookup . ':' . $intPecId;
|
||||
}
|
||||
|
||||
/**
|
||||
* MSIN-4554 — Libellé = question « Nom d'équipe » (formulaire) ?
|
||||
*/
|
||||
function fxBibDistPrintIsTeamNameQuestionLabel($strLabel) {
|
||||
$str = function_exists('mb_strtolower')
|
||||
? mb_strtolower(trim((string)$strLabel), 'UTF-8')
|
||||
: strtolower(trim((string)$strLabel));
|
||||
if ($str === '') {
|
||||
return false;
|
||||
}
|
||||
if (preg_match('/\bteam\s*name\b/u', $str)) {
|
||||
return true;
|
||||
}
|
||||
if (preg_match('/^(équipe|equipe|team)$/u', $str)) {
|
||||
return true;
|
||||
}
|
||||
// « Nom d'équipe », « Nom de l'équipe », « Nom de votre équipe », etc.
|
||||
if (preg_match('/nom/u', $str) && preg_match('/équip/u', $str)) {
|
||||
return true;
|
||||
}
|
||||
if (preg_match('/nom/u', $str) && preg_match('/\bequipe\b/u', $str)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* MSIN-4433 — Réponses questions pour une liste de participants.
|
||||
* resultats_questions.par_id = resultats_participants.par_id_original (legacy MS1).
|
||||
* MSIN-4554 — Épreuve équipe : (1) réponses vides = celles du capitaine même pec_id ;
|
||||
* (2) questions « Nom d'équipe » = pec_nom_equipe (même source que l'assignation).
|
||||
* @return array<string, array<int, string>> clé "par_lookup:pec_id" => [que_id => réponse]
|
||||
*/
|
||||
function fxBibGetDistPrintQuestionAnswers($epr_id, array $tabQueIds, array $tabParticipants, $strLangue = 'fr') {
|
||||
@ -10774,6 +10802,98 @@ function fxBibGetDistPrintQuestionAnswers($epr_id, array $tabQueIds, array $tabP
|
||||
$out[$strKey][$intQueId] = trim((string)($row['ans'] ?? ''));
|
||||
}
|
||||
|
||||
// MSIN-4554 — Règle épreuve en équipe seulement.
|
||||
$tabEprMeta = $objDatabase->fxGetRow(
|
||||
"SELECT epr_equipe FROM inscriptions_epreuves WHERE epr_id = $epr_id LIMIT 1"
|
||||
);
|
||||
if (!is_array($tabEprMeta) || (int)($tabEprMeta['epr_equipe'] ?? 0) !== 1) {
|
||||
return $out;
|
||||
}
|
||||
|
||||
// Index participants : clé réponse + pec + rôle + nom équipe commande.
|
||||
$tabByAnsKey = [];
|
||||
$tabCaptainAnsKeyByPec = [];
|
||||
foreach ($tabParticipants as $row) {
|
||||
if (!is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
$strKey = fxBibDistPrintAnswerKey($row);
|
||||
$intPec = (int)($row['pec_id'] ?? 0);
|
||||
$tabByAnsKey[$strKey] = $row;
|
||||
if ($intPec > 0 && (int)($row['rol_id'] ?? 0) === 1 && !isset($tabCaptainAnsKeyByPec[$intPec])) {
|
||||
$tabCaptainAnsKeyByPec[$intPec] = $strKey;
|
||||
}
|
||||
}
|
||||
|
||||
// (1) Coéquipier sans réponse → réponse du capitaine (même commande).
|
||||
foreach ($tabByAnsKey as $strKey => $row) {
|
||||
$intPec = (int)($row['pec_id'] ?? 0);
|
||||
if ($intPec <= 0 || !isset($tabCaptainAnsKeyByPec[$intPec])) {
|
||||
continue;
|
||||
}
|
||||
$strCapKey = $tabCaptainAnsKeyByPec[$intPec];
|
||||
if ($strCapKey === $strKey) {
|
||||
continue;
|
||||
}
|
||||
$tabCapAns = $out[$strCapKey] ?? [];
|
||||
if (!is_array($tabCapAns) || empty($tabCapAns)) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($out[$strKey]) || !is_array($out[$strKey])) {
|
||||
$out[$strKey] = [];
|
||||
}
|
||||
foreach ($tabQueIds as $intQueId) {
|
||||
$strMine = trim((string)($out[$strKey][$intQueId] ?? ''));
|
||||
if ($strMine !== '') {
|
||||
continue;
|
||||
}
|
||||
$strCap = trim((string)($tabCapAns[$intQueId] ?? ''));
|
||||
if ($strCap !== '') {
|
||||
$out[$strKey][$intQueId] = $strCap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// (2) Questions « Nom d'équipe » → toujours pec_nom_equipe (comme l'assignation).
|
||||
$strColQ = ($strLangue === 'en') ? 'que_question_en' : 'que_question_fr';
|
||||
$strColCart = ($strLangue === 'en') ? 'que_cart_label_en' : 'que_cart_label_fr';
|
||||
$tabQueLabels = $objDatabase->fxGetResults(
|
||||
"SELECT que_id,
|
||||
COALESCE(
|
||||
NULLIF(TRIM($strColCart), ''),
|
||||
NULLIF(TRIM($strColQ), ''),
|
||||
CONCAT('Question #', que_id)
|
||||
) AS que_label
|
||||
FROM inscriptions_questions
|
||||
WHERE que_id IN ($strQueIds)"
|
||||
);
|
||||
$tabTeamNameQueIds = [];
|
||||
if (is_array($tabQueLabels)) {
|
||||
foreach ($tabQueLabels as $tabQueRow) {
|
||||
$intQueId = (int)($tabQueRow['que_id'] ?? 0);
|
||||
if ($intQueId > 0 && fxBibDistPrintIsTeamNameQuestionLabel($tabQueRow['que_label'] ?? '')) {
|
||||
$tabTeamNameQueIds[] = $intQueId;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($tabTeamNameQueIds)) {
|
||||
foreach ($tabByAnsKey as $strKey => $row) {
|
||||
$strPecNom = trim((string)($row['pec_nom_equipe'] ?? ''));
|
||||
if ($strPecNom === '') {
|
||||
$strPecNom = trim((string)($row['par_nom_equipe'] ?? ''));
|
||||
}
|
||||
if ($strPecNom === '') {
|
||||
continue;
|
||||
}
|
||||
if (!isset($out[$strKey]) || !is_array($out[$strKey])) {
|
||||
$out[$strKey] = [];
|
||||
}
|
||||
foreach ($tabTeamNameQueIds as $intQueId) {
|
||||
$out[$strKey][$intQueId] = $strPecNom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* Constantes *
|
||||
*
|
||||
**************/
|
||||
define('_VERSION_CODE', '4.72.954'); // MSIN-4553 — nom + plaque dans barre titre Détails (replié)
|
||||
define('_VERSION_CODE', '4.72.955'); // MSIN-4554 — liste dist. : nom d'équipe = assignation (épreuve équipe)
|
||||
define('_DATE_CODE', '2026-08-03');
|
||||
//MSIN-4290
|
||||
define('QR_SECRET_KEY', 'ms1_qr_2026_cle_secrete_longue_et_fixe');
|
||||
|
||||
Reference in New Issue
Block a user