$count = question_count($quiz_id); if (count($_SESSION['quiz_tally_array']) + 1 < question_count($quiz_id)) { get_quiz_question($prevQuestionID); $_SESSION['last_id']++; if (isset($_POST['choice'])) { $choice = $_POST['choice']; $correct = is_correct($choice); array_push($_SESSION['quiz_tally_array'], $correct); /* print(""); print_r($_POST); print(""); var_dump($_SESSION); */ } } else { if (isset($_POST['choice'])) { array_push($_SESSION['quiz_tally_array'], is_correct($_POST['choice'])); } $numCorrect = 0; foreach ($_SESSION['quiz_tally_array'] as $current) { if ($current > 0) { $numCorrect++; } } $percent = $numCorrect / $count * 100; $percent = intval($percent); /* print_r($_SESSION); echo " percent=".$percent; echo " numcorrect=".$numCorrect; */ ?> <div class="row"> <div class="col-md-2"></div>
function charge_dicos($mots) { $extrawords = array(" ", ",", "<", ">", "(", ")", ".", "/", "\\", "\"", "\n", "\r", "\t", ";", ":", "=", "'", "!", "?", "l", "n", "qu", "d", "c", "s", "n", "t", "j", "m", "a", "à"); $chemin = 'dictionnaire/'; $dico_a_charger = array(); foreach ($mots as $mot) { if (!in_array($mot, $extrawords) && is_correct($mot) && !is_numeric($mot)) { $dico_a_charger[] = name_dico($mot); } } $dico_a_charger = array_unique($dico_a_charger); //On enlève tous les doublons $dictionnaires = array(); foreach ($dico_a_charger as $dico) { if (file_exists($chemin . $dico . '.txt')) { $dictionnaire = file($chemin . $dico . '.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $dictionnaires[$dico] = array_map('rtrim', $dictionnaire); } else { $dictionnaires[$dico] = array(); } // Pas de dictionnaire correspondant, on envoit du vide pour éviter une erreur } return $dictionnaires; }