function afficheQuestions($linkDb, $questions) { // print_r($questions); echo "<br />"; // On parcourt chaque lignes // On prend le compteur à la question en cours if (isset($_SESSION["questionCourante"])) { $numQuestion = $_SESSION["questionCourante"]; } else { $_SESSION["questionCourante"] = 0; $_SESSION["Rep"] = NULL; $numQuestion = $_SESSION["questionCourante"]; } /* * // Si fin du QCM * if( isset($questions["$numQuestion"]) ) { * * * } */ $_SESSION["idQuestion"] = $questions["{$numQuestion}"]["idQuestion"]; //echo 'Question courante ='.$numQuestion . "<br />"; echo 'Vous en etes à la question ' . ($numQuestion + 1) . ' sur ' . Compte_question($linkDb, $_SESSION["idQCM"]) . ' '; echo "<h3>" . $questions["{$numQuestion}"]["enonceQuestion"] . "</h3><br />"; $_SESSION['idQuestion'] = $questions["{$numQuestion}"]["idQuestion"]; echo '<form method = "post" action ="CreationTab.php">'; afficheReponses(fetchReponses($linkDb, $questions["{$numQuestion}"]["idQuestion"])); echo '<input type = "submit" name = "Question_suivante" value = "Question suivante" />'; echo '</form>'; $_SESSION["cpt"] = Compte_question($linkDb, $_GET["idQCM"]); //echo $_SESSION ['questionCourante']."Patate".$_SESSION ["cpt"]; echo "<br />"; }
function afficheQuestion($qcms, $link) { //On affiche tous les QCM foreach ($qcms as $indexLigne => $question) { // On passe l'id du QCM dans $_GET pour repondre au QCM ?> <div class="question"> <?php echo $question["enonceQuestion"] . '<br />'; ?> </div> <?php $_SESSION["idQuestion"] = $question["idQuestion"]; $rep = fetchReponses($link); foreach ($rep as $indexLigne => $reponses) { ?> <?php if ($reponses["juste"] == 1) { echo '<div class="True">'; echo $reponses["enonceReponse"] . '<br />'; echo '</div>'; } else { echo '<div class="False">'; echo $reponses["enonceReponse"] . '<br />'; echo '</div>'; } ?> </div> <?php } } }
and open the template in the editor. --> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="style2.css" /> <title></title> </head> <?php // Si l'on est pas connecté $nbQuestion = 0; $nbJuste = 0; foreach ($_SESSION["Rep"] as $indexLigne => $reponse) { $Id = $reponse["Id"]; $data = \fetchReponses($Id, $link); //récupération des réponses justes //var_dump($data); $string = ""; foreach ($data as $indexRep => $rep) { //creation du mot bianaire des rep justes $string .= $rep["juste"]; } if (strcmp($string, $reponse["R"])) { // comparaison avec les réponses users echo "Reponse juste a la question " . $Id . "<br />"; $nbJuste++; } else { echo "Reponse fausse à la question " . $Id . "<br />"; } $nbQuestion++;