}>, avertissements: array} */ public static function lire(string $chemin): array { $texte = preg_replace('/^[ \t]*\/\/.*$/m', '', File::get($chemin)); $questions = []; $avertissements = []; preg_match_all('/::(.*?)::(.*?)\{(.*?)\}/s', $texte, $blocs, PREG_SET_ORDER); foreach ($blocs as $bloc) { $enonce = trim($bloc[2]); $contenu = trim($bloc[3]); if ($contenu === 'T' || $contenu === 'F') { $questions[] = [ 'enonce' => $enonce, 'type' => QuestionQuiz::VRAI_FAUX, 'reponse_vrai_faux' => $contenu === 'T', 'choix' => [], ]; continue; } if (str_starts_with($contenu, '#')) { $avertissements[] = "question numérique ignorée (type non supporté par la banque) : {$enonce}"; continue; } $choix = []; foreach (preg_split('/\r?\n/', $contenu) as $ligne) { $ligne = trim($ligne); if ($ligne === '') { continue; } $choix[] = [ 'texte' => trim(substr($ligne, 1)), 'est_correct' => $ligne[0] === '=', ]; } $questions[] = [ 'enonce' => $enonce, 'type' => QuestionQuiz::QCM, 'reponse_vrai_faux' => null, 'choix' => $choix, ]; } return ['questions' => $questions, 'avertissements' => $avertissements]; } }