refactor form structure per new spec + fix

- split jury into interne/externe/ULB,
- remove president from student form,
- add language_autre,
- split duration into pages+minutes+annexes,
- move licence to degrés d'ouverture with CC2r,
- add license_custom,
- filter PACS from student AP list,
- editable généralités help block,
- Libre toggle per settings

Fix:
- missing comma after cc4r column in schema.sql
- remove duplicate form footer from partage template
- remove couverture from student files fieldset; add promoteur ULB conditional disable via JS on Approfondi
- promoteur ULB: remove 'si applicable', make required when visible
This commit is contained in:
Pontoporeia
2026-05-07 17:52:46 +02:00
parent dce0e0b301
commit 24d68dda59
21 changed files with 694 additions and 381 deletions

View File

@@ -3,120 +3,171 @@
* Jury composition fieldset partial.
*
* Variables consumed (all optional — defaults to empty/add-mode):
* $juryPresident string|null President name
* $juryPromoteur string|null Promoteur name
* $juryPromoteurUlb int 1 if promoteur is ULB, 0 otherwise
* $juryPromoteurExt int 1 if promoteur is external, 0 otherwise
* $juryLecteurs array Each element: ['name' => string, 'is_external' => int]
* $juryPromoteur string|null Promoteur interne name
* $juryPromoteurUlb string|null Promoteur ULB name
* $lecteursInternes array [{name: string}]
* $lecteursExternes array [{name: string}]
* $juryPresident string|null President name (edit-only, optional)
* $showPresident bool Show president field (default: false)
* $showPromoteurUlb bool Show ULB promoteur field (default: true)
* $promoteurUlbConditional bool If true, field is hidden unless finality=Approfondi
*
* In "add" mode (no existing jury data), callers should pass nulls/empty arrays and
* may rely on the $formData repopulation helpers (old/wasSelected) defined in add.php.
* When those helpers exist and no explicit values are set, the partial uses them.
* In add-mode repopulation: if old() exists and values are null, populate from it.
*/
$juryPresident = $juryPresident ?? null;
$juryPromoteur = $juryPromoteur ?? null;
$juryPromoteurExt = $juryPromoteurExt ?? 0;
$juryPromoteurUlb = $juryPromoteurUlb ?? 0;
$juryLecteurs = $juryLecteurs ?? [];
$juryPromoteur = $juryPromoteur ?? null;
$juryPromoteurUlb = $juryPromoteurUlb ?? null;
$lecteursInternes = $lecteursInternes ?? [];
$lecteursExternes = $lecteursExternes ?? [];
$juryPresident = $juryPresident ?? null;
$showPresident = $showPresident ?? false;
$showPromoteurUlb = $showPromoteurUlb ?? true;
$promoteurUlbConditional = $promoteurUlbConditional ?? false;
// In add-mode, repopulate from flash form data when helpers are available.
$addMode = ($juryPresident === null && $juryPromoteur === null && empty($juryLecteurs));
// Add-mode repopulation from flash data
$addMode = ($juryPromoteur === null && $juryPromoteurUlb === null && empty($lecteursInternes) && empty($lecteursExternes) && $juryPresident === null);
if ($addMode && function_exists('old')) {
$juryPresident = old('jury_president') ?: null;
$juryPromoteur = old('jury_promoteur') ?: null;
$juryPromoteurExt = function_exists('wasSelected') && wasSelected('jury_promoteur_ext', '1') ? 1 : 0;
$juryPromoteur = old('jury_promoteur') ?: null;
$juryPromoteurUlb = old('jury_promoteur_ulb_name') ?: null;
$juryPresident = old('jury_president') ?: null;
for ($i = 0; $i < 10; $i++) {
$n = old("jury_lecteur_interne:$i");
if ($n !== '') $lecteursInternes[] = ['name' => $n];
}
for ($i = 0; $i < 10; $i++) {
$n = old("jury_lecteur_externe:$i");
if ($n !== '') $lecteursExternes[] = ['name' => $n];
}
}
$juryIdx = max(count($juryLecteurs), 1);
?>
<!-- Composition du jury -->
<fieldset>
<legend>Composition du jury</legend>
<fieldset>
<legend>Composition du jury</legend>
<!-- Président·e -->
<div>
<label for="jury_president">Président·e :</label>
<input type="text" id="jury_president" name="jury_president"
value="<?= htmlspecialchars($juryPresident ?? '') ?>"
placeholder="Nom du/de la président·e (interne)">
</div>
<!-- Promoteur·ice interne -->
<div>
<label for="jury_promoteur">Promoteur·ice interne :</label>
<input type="text" id="jury_promoteur" name="jury_promoteur"
value="<?= htmlspecialchars($juryPromoteur ?? '') ?>" placeholder="Nom">
</div>
<!-- Promoteur·ice -->
<div>
<label for="jury_promoteur">Promoteur·ice :</label>
<div class="admin-jury-row">
<input type="text" id="jury_promoteur" name="jury_promoteur"
value="<?= htmlspecialchars($juryPromoteur ?? '') ?>" placeholder="Nom">
<label class="admin-checkbox-label admin-jury-ext">
<input type="checkbox" name="jury_promoteur_ext" value="1"
<?= $juryPromoteurExt ? 'checked' : '' ?>
aria-label="Promoteur·ice — externe"> Externe
</label>
<label class="admin-checkbox-label admin-jury-ext">
<input type="checkbox" name="jury_promoteur_ulb" value="1"
<?= $juryPromoteurUlb ? 'checked' : '' ?>
aria-label="Promoteur·ice — ULB"> ULB
</label>
</div>
</div>
<!-- Lecteur·ices (dynamic list) -->
<fieldset class="admin-jury-lecteurs">
<legend>Lecteur·ices</legend>
<div id="jury-lecteurs-list" class="admin-jury-list">
<?php if (empty($juryLecteurs)): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteurs[]" placeholder="Nom"
id="jury_lecteur_0" aria-label="Lecteur·ice 1 — nom">
<label class="admin-checkbox-label admin-jury-ext">
<input type="checkbox" name="jury_lecteurs_ext[0]" value="1"
aria-label="Lecteur·ice 1 — externe"> Externe
</label>
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove" onclick="removeJuryRow(this)"
aria-label="Supprimer le lecteur·ice 1"><span aria-hidden="true">✕</span></button>
</div>
<?php else: ?>
<?php foreach ($juryLecteurs as $li => $lm): ?>
<?php $lNum = $li + 1; ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteurs[]"
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
id="jury_lecteur_<?= $li ?>" aria-label="Lecteur·ice <?= $lNum ?> — nom">
<label class="admin-checkbox-label admin-jury-ext">
<input type="checkbox" name="jury_lecteurs_ext[<?= $li ?>]" value="1"
<?= $lm['is_external'] ? 'checked' : '' ?>
aria-label="Lecteur·ice <?= $lNum ?> — externe"> Externe
</label>
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove" onclick="removeJuryRow(this)"
aria-label="Supprimer le lecteur·ice <?= $lNum ?>"><span aria-hidden="true">✕</span></button>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<button type="button" class="btn btn--secondary admin-add-jury-btn"
onclick="addJuryRow()">+ Ajouter un·e lecteur·ice</button>
</fieldset>
</fieldset>
<script>
var juryIdx = <?= $juryIdx ?>;
function addJuryRow() {
var list = document.getElementById('jury-lecteurs-list');
var n = list.querySelectorAll('.admin-jury-entry').length + 1;
var div = document.createElement('div');
div.className = 'admin-jury-entry';
div.innerHTML = '<input type="text" name="jury_lecteurs[]" placeholder="Nom"'
+ ' aria-label="Lecteur\u00b7ice ' + n + ' \u2014 nom">'
+ '<label class="admin-checkbox-label admin-jury-ext">'
+ '<input type="checkbox" name="jury_lecteurs_ext[' + juryIdx + ']" value="1"'
+ ' aria-label="Lecteur\u00b7ice ' + n + ' \u2014 externe"> Externe'
+ '</label>'
+ '<button type="button" class="btn btn--sm btn--ghost admin-btn-remove" onclick="removeJuryRow(this)"'
+ ' aria-label="Supprimer le lecteur\u00b7ice ' + n + '"><span aria-hidden="true">\u2715</span></button>';
list.appendChild(div);
juryIdx++;
<?php if ($showPromoteurUlb): ?>
<!-- Promoteur·ice ULB -->
<div id="jury-promoteur-ulb-row"<?= $promoteurUlbConditional ? ' style="display:none"' : '' ?>>
<label for="jury_promoteur_ulb_name">Promoteur·ice ULB :</label>
<input type="text" id="jury_promoteur_ulb_name" name="jury_promoteur_ulb_name"
value="<?= htmlspecialchars($juryPromoteurUlb ?? '') ?>" placeholder="Nom">
</div>
<?php if ($promoteurUlbConditional): ?>
<script>
(function() {
var finalitySelect = document.querySelector('select[name="finality"]');
var ulbRow = document.getElementById('jury-promoteur-ulb-row');
var ulbInput = ulbRow ? ulbRow.querySelector('input') : null;
function toggleUlb() {
if (!finalitySelect || !ulbRow) return;
var selected = finalitySelect.options[finalitySelect.selectedIndex];
var text = (selected && selected.text) ? selected.text.toLowerCase() : '';
var isApprofondi = text.includes('approfondi');
ulbRow.style.display = isApprofondi ? '' : 'none';
if (ulbInput) {
ulbInput.required = isApprofondi;
ulbInput.disabled = !isApprofondi;
if (!isApprofondi) ulbInput.value = '';
}
}
function removeJuryRow(btn) {
btn.closest('.admin-jury-entry').remove();
if (finalitySelect) {
finalitySelect.addEventListener('change', toggleUlb);
toggleUlb();
}
</script>
})();
</script>
<?php endif; ?>
<?php endif; ?>
<!-- Lecteur·ice(s) interne -->
<fieldset class="admin-jury-lecteurs">
<legend>Lecteur·ice(s) interne</legend>
<div id="jury-lecteurs-internes-list" class="admin-jury-list">
<?php if (empty($lecteursInternes)): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_interne[]" placeholder="Nom"
aria-label="Lecteur·ice interne 1 — nom">
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
</div>
<?php else: ?>
<?php foreach ($lecteursInternes as $li => $lm): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_interne[]"
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
aria-label="Lecteur·ice interne <?= $li + 1 ?> — nom">
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<button type="button" class="btn btn--secondary admin-add-jury-btn"
onclick="addJuryRow('jury-lecteurs-internes-list', 'jury_lecteur_interne[]', 'Lecteur·ice interne')">
+ Ajouter un·e lecteur·ice interne
</button>
</fieldset>
<!-- Lecteur·ice(s) externe -->
<fieldset class="admin-jury-lecteurs">
<legend>Lecteur·ice(s) externe</legend>
<div id="jury-lecteurs-externes-list" class="admin-jury-list">
<?php if (empty($lecteursExternes)): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_externe[]" placeholder="Nom"
aria-label="Lecteur·ice externe 1 — nom">
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
</div>
<?php else: ?>
<?php foreach ($lecteursExternes as $li => $lm): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_externe[]"
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
aria-label="Lecteur·ice externe <?= $li + 1 ?> — nom">
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<button type="button" class="btn btn--secondary admin-add-jury-btn"
onclick="addJuryRow('jury-lecteurs-externes-list', 'jury_lecteur_externe[]', 'Lecteur·ice externe')">
+ Ajouter un·e lecteur·ice externe
</button>
</fieldset>
<?php if ($showPresident): ?>
<!-- Président·e (admin edit only) -->
<div>
<label for="jury_president">Président·e :</label>
<input type="text" id="jury_president" name="jury_president"
value="<?= htmlspecialchars($juryPresident ?? '') ?>"
placeholder="Nom du/de la président·e (interne)">
</div>
<?php endif; ?>
</fieldset>
<script>
function addJuryRow(listId, inputName, roleLabel) {
var list = document.getElementById(listId);
if (!list) return;
var n = list.querySelectorAll('.admin-jury-entry').length + 1;
var div = document.createElement('div');
div.className = 'admin-jury-entry';
div.innerHTML = '<input type="text" name="' + inputName + '" placeholder="Nom"'
+ ' aria-label="' + roleLabel + ' ' + n + ' \u2014 nom">'
+ '<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"'
+ ' onclick="removeJuryRow(this)" aria-label="Supprimer">'
+ '<span aria-hidden="true">\u2715</span></button>';
list.appendChild(div);
}
function removeJuryRow(btn) {
btn.closest('.admin-jury-entry').remove();
}
</script>