Pas de correction, limité à un choix

Résolu/Fermé
boni91 Messages postés 23 Date d'inscription dimanche 12 novembre 2017 Statut Membre Dernière intervention 22 juillet 2018 - 22 juil. 2018 à 15:05
jordane45 Messages postés 38292 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 19 novembre 2024 - 23 juil. 2018 à 09:44
Bonjour à tous,

j'aimerais limité le nombre de choix a 1, comment faire car j'ai trois possibilité.

		  <?php 
$reponses = array(
'chx' => array(
'chiffre' => '1',
'reponse' => '../png-alphabet/A.png',
'reponse1' => '../png-alphabet/O.png',
'reponse2' => '../png-alphabet/I.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/1-bain.mp3'
) ,
'chx_1' => array(
'chiffre' => '2',
'reponse' => '../png-alphabet/E.png',
'reponse1' => '../png-alphabet/O.png',
'reponse2' => '../png-alphabet/C.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/2-pont.mp3'
) ,
'chx_2' => array(
'chiffre' => '3',
'reponse' => '../png-alphabet/B.png',
'reponse1' => '../png-alphabet/C.png',
'reponse2' => '../png-alphabet/D.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/3-monte.mp3'
) ,
'chx_3' => array(
'chiffre' => '4',
'reponse' => '../png-alphabet/L.png',
'reponse1' => '../png-alphabet/I.png',
'reponse2' => '../png-alphabet/T.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/4-lent.mp3'
) ,
'chx_4' => array(
'chiffre' => '5',
'reponse' => '../png-alphabet/T.png',
'reponse1' => '../png-alphabet/D.png',
'reponse2' => '../png-alphabet/L.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/5-langue.mp3'
) ,
'chx_5' => array(
'chiffre' => '6',
'reponse' => '../png-alphabet/B.png',
'reponse1' => '../png-alphabet/P.png',
'reponse2' => '../png-alphabet/R.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/10-plein.mp3'
));
$reponses1 = array(
'chx_6' => array(
'chiffre' => '7',
'reponse' => '../png-alphabet/O.png',
'reponse1' => '../png-alphabet/C.png',
'reponse2' => '../png-alphabet/G.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/6-trompé.mp3'
),
'chx_7' => array(
'chiffre' => '8',
'reponse' => '../png-alphabet/F.png',
'reponse1' => '../png-alphabet/E.png',
'reponse2' => '../png-alphabet/K.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/7-menteur.mp3'
) ,
'chx_8' => array(
'chiffre' => '9',
'reponse' => '../png-alphabet/H.png',
'reponse1' => '../png-alphabet/I.png',
'reponse2' => '../png-alphabet/J.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/8-plan.mp3'
) ,
'chx_9' => array(
'chiffre' => '10',
'reponse' => '../png-alphabet/S.png',
'reponse1' => '../png-alphabet/T.png',
'reponse2' => '../png-alphabet/D.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/9-train.mp3'
),
'chx_10' => array(
'chiffre' => '11',
'reponse' => '../png-alphabet/R.png',
'reponse1' => '../png-alphabet/N.png',
'reponse2' => '../png-alphabet/M.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/7-menteur.mp3'
) ,
'chx_11' => array(
'chiffre' => '12',
'reponse' => '../png-alphabet/W.png',
'reponse1' => '../png-alphabet/V.png',
'reponse2' => '../png-alphabet/U.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/8-plan.mp3'
)
);

$i = 1;
echo '<form class="form_exercices_ou_result" action="../correct_exo/correction-exo-alphabet-2.php" method="POST" />';
echo'<div style="display:inline-block;width:450px;min-height:350px;border-right:1px solid #000;">';
foreach($reponses as $cle => $reponse){
echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse['chiffre'].'</p>';
echo '<button class="button_audio_2" onclick="playVid(\'son_1'.$cle.'\')" type="button" value="' . $reponse['mp3'] . '"></button>';
echo '<audio id="son_1'.$cle.'">';
echo '<source src="' . $reponse['mp3'] .'" type="audio/mp3">';
echo '<p>Votre navigateur ne supporte pas le format audio.</p>';
echo '</audio>';

echo'<p style="text-align:center;width:100px;font-size:1.2em;"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse1'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse1'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse2'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse2'] .'" width="30px" height="30px" /></p>';

}
echo'</div>';
echo'<div style="display:inline-block;width:450px;height:350px;">';
foreach($reponses1 as $cle1 => $reponse1){
echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse1['chiffre'].'</p>';
echo '<button class="button_audio_2" onclick="playVid(\'son_1'.$cle.'\')" type="button" value="' . $reponse1['mp3'] . '"></button>';
echo '<audio id="son_1'.$cle1.'">';
echo '<source src="' . $reponse1['mp3'] .'" type="audio/mp3">';
echo '<p>Votre navigateur ne supporte pas le format audio.</p>';
echo '</audio>';


echo'<p style="text-align:center;width:100px;font-size:1.2em;"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle1. '" value="' . $reponse1['reponse'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse1['reponse'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle1 . '" value="' . $reponse1['reponse1'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse1['reponse1'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle1 . '" value="' . $reponse1['reponse2'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse1['reponse2'] .'" width="30px" height="30px" /></p>';

}
echo'</div>';
echo '<div style="display:inline-block;margin-left:-15em;margin-top:2em;" class="correction_center"><input type="submit" name="correction" value="correction"/></div>';
echo '</form>';
echo'<div><a href="javascript:scroll(0,0)"><figure style="margin:0 0 0 96%;" class="bouton_retour"><img src="../img/fhg.jpg" alt="fleche vers le haut" width="60" height="60" /></figure></a></div>';

?>
</div>
</section>


merci d'avance

aussi je ne sais pas ou je me suis planté, je reçois bien les informations, mais ne corrige pas comme il le faut, si bonne réponse bouton vert si pas bon bouton rouge, pouvez m'aider MERCIIIIIIIIIIIIIIIIIIIIII.

     		  <?php 
echo '<form class="form_exercices_ou_result" action="" method="POST" />';

$reponses = array(
'chx' => array(
'chiffre' => '1',
'reponse' => '../png-alphabet/A.png',
'reponse1' => '../png-alphabet/O.png',
'reponse2' => '../png-alphabet/I.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/1-bain.mp3'
) ,
'chx_1' => array(
'chiffre' => '2',
'reponse' => '../png-alphabet/E.png',
'reponse1' => '../png-alphabet/O.png',
'reponse2' => '../png-alphabet/C.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/2-pont.mp3'
) ,
'chx_2' => array(
'chiffre' => '3',
'reponse' => '../png-alphabet/B.png',
'reponse1' => '../png-alphabet/C.png',
'reponse2' => '../png-alphabet/D.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/3-monte.mp3'
) ,
'chx_3' => array(
'chiffre' => '4',
'reponse' => '../png-alphabet/L.png',
'reponse1' => '../png-alphabet/I.png',
'reponse2' => '../png-alphabet/T.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/4-lent.mp3'
) ,
'chx_4' => array(
'chiffre' => '5',
'reponse' => '../png-alphabet/T.png',
'reponse1' => '../png-alphabet/D.png',
'reponse2' => '../png-alphabet/L.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/5-langue.mp3'
) ,
'chx_5' => array(
'chiffre' => '6',
'reponse' => '../png-alphabet/B.png',
'reponse1' => '../png-alphabet/P.png',
'reponse2' => '../png-alphabet/R.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/10-plein.mp3'
));
$reponses1 = array(
'chx_6' => array(
'chiffre' => '7',
'reponse' => '../png-alphabet/O.png',
'reponse1' => '../png-alphabet/C.png',
'reponse2' => '../png-alphabet/G.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/6-trompé.mp3'
),
'chx_7' => array(
'chiffre' => '8',
'reponse' => '../png-alphabet/F.png',
'reponse1' => '../png-alphabet/E.png',
'reponse2' => '../png-alphabet/K.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/7-menteur.mp3'
) ,
'chx_8' => array(
'chiffre' => '9',
'reponse' => '../png-alphabet/H.png',
'reponse1' => '../png-alphabet/I.png',
'reponse2' => '../png-alphabet/J.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/8-plan.mp3'
) ,
'chx_9' => array(
'chiffre' => '10',
'reponse' => '../png-alphabet/S.png',
'reponse1' => '../png-alphabet/T.png',
'reponse2' => '../png-alphabet/D.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/9-train.mp3'
),
'chx_10' => array(
'chiffre' => '11',
'reponse' => '../png-alphabet/R.png',
'reponse1' => '../png-alphabet/N.png',
'reponse2' => '../png-alphabet/M.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/7-menteur.mp3'
) ,
'chx_11' => array(
'chiffre' => '12',
'reponse' => '../png-alphabet/W.png',
'reponse1' => '../png-alphabet/V.png',
'reponse2' => '../png-alphabet/U.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/8-plan.mp3'
)
);
$choix = array(
'chx' => array('reponse_bonne' => '../png-alphabet/A.png'),
'chx_1' => array('reponse_bonne' => '../png-alphabet/O.png'),
'chx_2' => array('reponse_bonne' => '../png-alphabet/B.png'),
'chx_3' => array('reponse_bonne' => '../png-alphabet/L.png'),
'chx_4' => array('reponse_bonne' => '../png-alphabet/T.png'),
'chx_5' => array('reponse_bonne' => '../png-alphabet/R.png'),

);
$choix1 = array(
'chx_6' => array('reponse_bonne' => '../png-alphabet/O.png'),
'chx_7' => array('reponse_bonne' => '../png-alphabet/E.png'),
'chx_8' => array('reponse_bonne' => '../png-alphabet/H.png'),
'chx_9' => array('reponse_bonne' => '../png-alphabet/S.png'),
'chx_10' => array('reponse_bonne' => '../png-alphabet/M.png'),
'chx_11' => array('reponse_bonne' => '../png-alphabet/V.png')
);
$errors = array();
$point = array();
$si = 0.8333333333333333;
$z = 0;
echo'<div style="display:inline-block;width:450px;min-height:350px;border-right:1px solid #000;">';
if (isset($_POST['correction']))
{

foreach($reponses as $cle => $reponse){
$clic = trim($_POST[$cle]);
echo '<button class="button_audio" onclick="playVid(\'son_1'.$cle.'\')" type="button" value="' . $reponse['mp3'] . '"></button>';
echo '<audio id="son_1'.$cle.'">';
echo '<source src="' . $reponse['mp3'] .'" type="audio/mp3">';
echo '<p>Votre navigateur ne supporte pas le format audio.</p>';
echo '</audio>';
foreach($choix as $key => $value){
if(empty($clic) && empty($clic) !== $reponse['reponse'] OR empty($clic) && empty($clic) !== $reponse['reponse1'] OR empty($clic) && empty($clic) !== $reponse['reponse2']){
echo'<p>Veuillez recommençer.</p>';
}else if($clic == $reponse['reponse'] AND $reponse['reponse'] == $key OR $clic == $reponse['reponse1'] AND $reponse['reponse1'] == $key OR $clic == $reponse['reponse2'] AND $reponse['reponse2'] == $key ){
$point[$cle] = htmlspecialchars($clic);
var_dump($point[$cle]);

echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse['chiffre'].'</p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em;"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse1'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse1'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse2'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse2'] .'" width="30px" height="30px" /></p>';

echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok1.jpg" alt="reponse bonne" width:"55" height="55" /></figure><br />';
echo $point[$cle];

break;
}else if($clic != $reponse['reponse'] AND $reponse['reponse'] != $key OR $clic != $reponse['reponse1'] AND $reponse['reponse1'] != $key OR $clic != $reponse['reponse2'] AND $reponse['reponse2'] != $key){

$errors[$cle] = htmlspecialchars($clic);
var_dump($errors[$cle]);

echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse['chiffre'].'</p><p style="text-align:center;width:80px;font-size:1.2em;"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle. '" value="' . $reponse['reponse'] . '" />  '. $reponse['reponse'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle . '" value="' . $reponse['reponse1'] . '" />  '. $reponse['reponse1'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle . '" value="' . $reponse['reponse2'] . '" />  '. $reponse['reponse2'] .'</p>';
echo'<p style="color:red;font-size:1.2em;"><b>'. $errors[$cle].'</b></p>';
echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok.jpg" alt="reponse fausse" width:"55" height="55" /></figure><br />';
echo $errors[$cle];
break;

}
}
}


echo'</div>';
echo'<div style="display:inline-block;width:450px;min-height:350px;">';

foreach($reponses1 as $cle1 => $reponse1){
$clic = trim($_POST[$cle1]);
echo '<button class="button_audio" onclick="playVid(\'son_1'.$cle.'\')" type="button" value="' . $reponse1['mp3'] . '"></button>';
echo '<audio id="son_1'.$cle1.'">';
echo '<source src="' . $reponse1['mp3'] .'" type="audio/mp3">';
echo '<p>Votre navigateur ne supporte pas le format audio.</p>';
echo '</audio>';
foreach($choix1 as $key1 => $value1){
if(empty($clic) && empty($clic) !== $reponse1['reponse'] OR empty($clic) && empty($clic) !== $reponse1['reponse1'] OR empty($clic) && empty($clic) !== $reponse1['reponse2'] ){
echo'<p>Veuillez recommençer.</p>';
}else if($clic == $reponse1['reponse'] AND $reponse1['reponse'] == $key OR $clic == $reponse1['reponse1'] AND $reponse1['reponse1'] == $key OR $clic == $reponse1['reponse2'] AND $reponse1['reponse2'] == $key ){
$point[$cle1] = htmlspecialchars($clic);
var_dump($point[$cle]);

echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse1['chiffre'].'</p>
<p style="text-align:center;width:80px;font-size:1.2em;"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse'] . '" />  '. $reponse1['reponse'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse1'] . '" />  '. $reponse1['reponse1'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse2'] . '" />  '. $reponse1['reponse2'] .'</p>';
echo'<p style="color:green;font-size:1.2em;"><b>'. $point[$cle1].'</b></p>';
echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok1.jpg" alt="reponse bonne" width:"55" height="55" /></figure><br />';

break;
}else if($clic != $reponse1['reponse'] AND $reponse1['reponse'] != $key OR $clic != $reponse1['reponse1'] AND $reponse1['reponse1'] != $key OR $clic != $reponse1['reponse2'] AND $reponse1['reponse2'] != $key){

$errors[$cle1] = htmlspecialchars($clic);
var_dump($errors[$cle]);
echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse1['chiffre'].'</p><p style="text-align:center;width:80px;font-size:1.2em;"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle. '" value="' . $reponse1['reponse'] . '" />  '. $reponse1['reponse'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse1'] . '" />  '. $reponse1['reponse1'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse2'] . '" />  '. $reponse1['reponse2'] .'</p>';
echo'<p style="color:red;font-size:1.2em;"><b>'. $errors[$cle1].'</b></p>';
echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok.jpg" alt="reponse fausse" width:"55" height="55" /></figure><br />';

break;

}
}
}

}

echo'</div>';
echo '<br /><br />';
echo '<div style="display:inline-block;margin-left:-15em;margin-top:2em;" class="correction_center"><input type="submit" name="correction" value="correction"/></div>';
echo'</form>';
?>


merci pour votre réponse, jsui un codeur du dimanche HELPPPPPPP



5 réponses

jordane45 Messages postés 38292 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 19 novembre 2024 4 704
22 juil. 2018 à 17:47
Bonjour,
Commence par nous reposter ton code en y mettant la coloration syntaxique :
https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
0
boni91 Messages postés 23 Date d'inscription dimanche 12 novembre 2017 Statut Membre Dernière intervention 22 juillet 2018
22 juil. 2018 à 18:47
merci jordane45,

sur le premier code, j'aimerais limité à un choix la réponse...

$i = 1;
echo '<form class="form_exercices_ou_result" action="../correct_exo/correction-exo-alphabet-2.php" method="POST" />';
echo'<div style="display:inline-block;width:450px;min-height:350px;border-right:1px solid #000;">';
foreach($reponses as $cle => $reponse){
echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse['chiffre'].'</p>';	
echo '<button class="button_audio_2" onclick="playVid(\'son_1'.$cle.'\')" type="button" value="' . $reponse['mp3'] . '"></button>';
			echo '<audio id="son_1'.$cle.'">';
			echo '<source src="' . $reponse['mp3'] .'" type="audio/mp3">';
			echo '<p>Votre navigateur ne supporte pas le format audio.</p>';
			echo '</audio>';

echo'<p style="text-align:center;width:100px;font-size:1.2em;"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse'] . '" /><img style="margin-left:-25px; margin-top:25px;"  src="'. $reponse['reponse'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;"  type="checkbox" name="' . $cle . '" value="' . $reponse['reponse1'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse1'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;"  type="checkbox" name="' . $cle . '" value="' . $reponse['reponse2']  . '" /><img style="margin-left:-25px; margin-top:25px;"  src="'. $reponse['reponse2'] .'" width="30px" height="30px" /></p>';	

}
echo'</div>';
echo'<div style="display:inline-block;width:450px;height:350px;">';
foreach($reponses1 as $cle1 => $reponse1){
echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse1['chiffre'].'</p>';	
echo '<button class="button_audio_2" onclick="playVid(\'son_1'.$cle.'\')" type="button" value="' . $reponse1['mp3'] . '"></button>';
			echo '<audio id="son_1'.$cle1.'">';
			echo '<source src="' . $reponse1['mp3'] .'" type="audio/mp3">';
			echo '<p>Votre navigateur ne supporte pas le format audio.</p>';
			echo '</audio>';


echo'<p style="text-align:center;width:100px;font-size:1.2em;"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle1. '" value="' . $reponse1['reponse'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse1['reponse'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;"  type="checkbox" name="' . $cle1 . '" value="' . $reponse1['reponse1'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse1['reponse1'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;"  type="checkbox" name="' . $cle1 . '" value="' . $reponse1['reponse2']  . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse1['reponse2'] .'" width="30px" height="30px" /></p>';	

}
echo'</div>';
echo '<div style="display:inline-block;margin-left:-15em;margin-top:2em;" class="correction_center"><input type="submit" name="correction" value="correction"/></div>';
echo '</form>';
echo'<div><a href="javascript:scroll(0,0)"><figure style="margin:0 0 0 96%;" class="bouton_retour"><img src="../img/fhg.jpg" alt="fleche vers le haut" width="60" height="60" /></figure></a></div>';

?> 
       


sur le deuxieme code, je reçoit bien les informations, sauf dans la variable $errors qui bien ne peut etre controler...

<?php
echo '<form class="form_exercices_ou_result" action="" method="POST" />';

$reponses = array(
'chx' => array(
'chiffre' => '1',
'reponse' => '../png-alphabet/A.png',
'reponse1' => '../png-alphabet/O.png',
'reponse2' => '../png-alphabet/I.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/1-bain.mp3'
) ,
'chx_1' => array(
'chiffre' => '2',
'reponse' => '../png-alphabet/E.png',
'reponse1' => '../png-alphabet/O.png',
'reponse2' => '../png-alphabet/C.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/2-pont.mp3'
) ,
'chx_2' => array(
'chiffre' => '3',
'reponse' => '../png-alphabet/B.png',
'reponse1' => '../png-alphabet/C.png',
'reponse2' => '../png-alphabet/D.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/3-monte.mp3'
) ,
'chx_3' => array(
'chiffre' => '4',
'reponse' => '../png-alphabet/L.png',
'reponse1' => '../png-alphabet/I.png',
'reponse2' => '../png-alphabet/T.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/4-lent.mp3'
) ,
'chx_4' => array(
'chiffre' => '5',
'reponse' => '../png-alphabet/T.png',
'reponse1' => '../png-alphabet/D.png',
'reponse2' => '../png-alphabet/L.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/5-langue.mp3'
) ,
'chx_5' => array(
'chiffre' => '6',
'reponse' => '../png-alphabet/B.png',
'reponse1' => '../png-alphabet/P.png',
'reponse2' => '../png-alphabet/R.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/10-plein.mp3'
));
$reponses1 = array(
'chx_6' => array(
'chiffre' => '7',
'reponse' => '../png-alphabet/O.png',
'reponse1' => '../png-alphabet/C.png',
'reponse2' => '../png-alphabet/G.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/6-trompé.mp3'
),
'chx_7' => array(
'chiffre' => '8',
'reponse' => '../png-alphabet/F.png',
'reponse1' => '../png-alphabet/E.png',
'reponse2' => '../png-alphabet/K.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/7-menteur.mp3'
) ,
'chx_8' => array(
'chiffre' => '9',
'reponse' => '../png-alphabet/H.png',
'reponse1' => '../png-alphabet/I.png',
'reponse2' => '../png-alphabet/J.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/8-plan.mp3'
) ,
'chx_9' => array(
'chiffre' => '10',
'reponse' => '../png-alphabet/S.png',
'reponse1' => '../png-alphabet/T.png',
'reponse2' => '../png-alphabet/D.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/9-train.mp3'
),
'chx_10' => array(
'chiffre' => '11',
'reponse' => '../png-alphabet/R.png',
'reponse1' => '../png-alphabet/N.png',
'reponse2' => '../png-alphabet/M.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/7-menteur.mp3'
) ,
'chx_11' => array(
'chiffre' => '12',
'reponse' => '../png-alphabet/W.png',
'reponse1' => '../png-alphabet/V.png',
'reponse2' => '../png-alphabet/U.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/8-plan.mp3'
)
);
$choix = array(
'chx' => array('reponse_bonne' => '../png-alphabet/A.png'),
'chx_1' => array('reponse_bonne' => '../png-alphabet/O.png'),
'chx_2' => array('reponse_bonne' => '../png-alphabet/B.png'),
'chx_3' => array('reponse_bonne' => '../png-alphabet/L.png'),
'chx_4' => array('reponse_bonne' => '../png-alphabet/T.png'),
'chx_5' => array('reponse_bonne' => '../png-alphabet/R.png'),

);
$choix1 = array(
'chx_6' => array('reponse_bonne' => '../png-alphabet/O.png'),
'chx_7' => array('reponse_bonne' => '../png-alphabet/E.png'),
'chx_8' => array('reponse_bonne' => '../png-alphabet/H.png'),
'chx_9' => array('reponse_bonne' => '../png-alphabet/S.png'),
'chx_10' => array('reponse_bonne' => '../png-alphabet/M.png'),
'chx_11' => array('reponse_bonne' => '../png-alphabet/V.png')
);
$errors = array();
$point = array();
$si = 0.8333333333333333;
$z = 0;
echo'<div style="display:inline-block;width:450px;min-height:350px;border-right:1px solid #000;">';
if (isset($_POST['correction']))
{

foreach($reponses as $cle => $reponse){
$clic = trim($_POST[$cle]);
echo '<button class="button_audio" onclick="playVid(\'son_1'.$cle.'\')" type="button" value="' . $reponse['mp3'] . '"></button>';
echo '<audio id="son_1'.$cle.'">';
echo '<source src="' . $reponse['mp3'] .'" type="audio/mp3">';
echo '<p>Votre navigateur ne supporte pas le format audio.</p>';
echo '</audio>';
foreach($choix as $key => $value){
if(empty($clic) && empty($clic) !== $reponse['reponse'] OR empty($clic) && empty($clic) !== $reponse['reponse1'] OR empty($clic) && empty($clic) !== $reponse['reponse2']){
echo'<p>Veuillez recommençer.</p>';
}else if($clic == $reponse['reponse'] AND $reponse['reponse'] == $key OR $clic == $reponse['reponse1'] AND $reponse['reponse1'] == $key OR $clic == $reponse['reponse2'] AND $reponse['reponse2'] == $key ){
$point[$cle] = htmlspecialchars($clic);
var_dump($point[$cle]);

echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse['chiffre'].'</p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em;"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse1'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse1'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="checkbox" name="' . $cle . '" value="' . $reponse['reponse2'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse2'] .'" width="30px" height="30px" /></p>';

echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok1.jpg" alt="reponse bonne" width:"55" height="55" /></figure><br />';
echo $point[$cle];

break;
}else if($clic != $reponse['reponse'] AND $reponse['reponse'] != $key OR $clic != $reponse['reponse1'] AND $reponse['reponse1'] != $key OR $clic != $reponse['reponse2'] AND $reponse['reponse2'] != $key){

$errors[$cle] = htmlspecialchars($clic);
var_dump($errors[$cle]);

echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse['chiffre'].'</p><p style="text-align:center;width:80px;font-size:1.2em;"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle. '" value="' . $reponse['reponse'] . '" />  '. $reponse['reponse'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle . '" value="' . $reponse['reponse1'] . '" />  '. $reponse['reponse1'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle . '" value="' . $reponse['reponse2'] . '" />  '. $reponse['reponse2'] .'</p>';
echo'<p style="color:red;font-size:1.2em;"><b>'. $errors[$cle].'</b></p>';
echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok.jpg" alt="reponse fausse" width:"55" height="55" /></figure><br />';
echo $errors[$cle];
break;

}
}
}


echo'</div>';
echo'<div style="display:inline-block;width:450px;min-height:350px;">';

foreach($reponses1 as $cle1 => $reponse1){
$clic = trim($_POST[$cle1]);
echo '<button class="button_audio" onclick="playVid(\'son_1'.$cle.'\')" type="button" value="' . $reponse1['mp3'] . '"></button>';
echo '<audio id="son_1'.$cle1.'">';
echo '<source src="' . $reponse1['mp3'] .'" type="audio/mp3">';
echo '<p>Votre navigateur ne supporte pas le format audio.</p>';
echo '</audio>';
foreach($choix1 as $key1 => $value1){
if(empty($clic) && empty($clic) !== $reponse1['reponse'] OR empty($clic) && empty($clic) !== $reponse1['reponse1'] OR empty($clic) && empty($clic) !== $reponse1['reponse2'] ){
echo'<p>Veuillez recommençer.</p>';
}else if($clic == $reponse1['reponse'] AND $reponse1['reponse'] == $key OR $clic == $reponse1['reponse1'] AND $reponse1['reponse1'] == $key OR $clic == $reponse1['reponse2'] AND $reponse1['reponse2'] == $key ){
$point[$cle1] = htmlspecialchars($clic);
var_dump($point[$cle]);

echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse1['chiffre'].'</p>
<p style="text-align:center;width:80px;font-size:1.2em;"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse'] . '" />  '. $reponse1['reponse'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse1'] . '" />  '. $reponse1['reponse1'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse2'] . '" />  '. $reponse1['reponse2'] .'</p>';
echo'<p style="color:green;font-size:1.2em;"><b>'. $point[$cle1].'</b></p>';
echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok1.jpg" alt="reponse bonne" width:"55" height="55" /></figure><br />';

break;
}else if($clic != $reponse1['reponse'] AND $reponse1['reponse'] != $key OR $clic != $reponse1['reponse1'] AND $reponse1['reponse1'] != $key OR $clic != $reponse1['reponse2'] AND $reponse1['reponse2'] != $key){

$errors[$cle1] = htmlspecialchars($clic);
var_dump($errors[$cle]);
echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse1['chiffre'].'</p><p style="text-align:center;width:80px;font-size:1.2em;"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle. '" value="' . $reponse1['reponse'] . '" />  '. $reponse1['reponse'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse1'] . '" />  '. $reponse1['reponse1'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle1 . '" value="' . $reponse1['reponse2'] . '" />  '. $reponse1['reponse2'] .'</p>';
echo'<p style="color:red;font-size:1.2em;"><b>'. $errors[$cle1].'</b></p>';
echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok.jpg" alt="reponse fausse" width:"55" height="55" /></figure><br />';

break;

}
}
}

}

echo'</div>';
echo '<br /><br />';
echo '<div style="display:inline-block;margin-left:-15em;margin-top:2em;" class="correction_center"><input type="submit" name="correction" value="correction"/></div>';
echo'</form>';
?>


merci
0
jordane45 Messages postés 38292 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 19 novembre 2024 4 704
22 juil. 2018 à 18:56
pour limiter à un choix... au lieu d'utiliser des checkboxes, tu n'as qu'a utiliser des radio
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_radio
0
boni91 Messages postés 23 Date d'inscription dimanche 12 novembre 2017 Statut Membre Dernière intervention 22 juillet 2018
22 juil. 2018 à 19:03
merci jordane45,

effectivement ça va mieux niveau choix, par contre toujours pas de correction
0
jordane45 Messages postés 38292 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 19 novembre 2024 4 704
22 juil. 2018 à 19:21
Pour commencer... refais correctement ton IF
if(empty($clic) && empty($clic) !== $reponse1['reponse'] OR empty($clic) && empty($clic) !== $reponse1['reponse1'] OR empty($clic) && empty($clic) !== $reponse1['reponse2'] ){

Les "empty sont inutiles
Tu n'as rien priorisé entre les OR et les AND donc si n'importe lequel des tests est vrai (peu importe les autres) la conditon sera toujours vraies
0
boni91 Messages postés 23 Date d'inscription dimanche 12 novembre 2017 Statut Membre Dernière intervention 22 juillet 2018
22 juil. 2018 à 19:31
merci, mais que veut tu dire dans refais "les empty sont inutile"
0
jordane45 Messages postés 38292 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 19 novembre 2024 4 704
22 juil. 2018 à 19:46
Refais... du verbe REFAIRE
et
empty($clic) && empty($clic) !==

repeter 50 fois cette instruction est inutle.

Donc... réécris correctement ton IF... voila ce que ça veut dire.
Idem dans ton Else if .... tes conditions ne sont pas bonnes.... tu as oublié des parenthèses je pense
if(  (condition1 && condition2) || (condition3 && condition4)...

Au passage :
A la place de AND utilises
 && 

A la place de OR utilises
 || 
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
boni91 Messages postés 23 Date d'inscription dimanche 12 novembre 2017 Statut Membre Dernière intervention 22 juillet 2018
22 juil. 2018 à 20:40
merci jordane45, j'ai refais les conditions par contre toujours pas de correction, je comprend pas est ce parce que je compare des images entre elles?

     		  <?php 
echo '<form class="form_exercices_ou_result" action="" method="POST" />';
	  
$reponses = array(
'chx' => array(
'chiffre' => '1',
'reponse' => '../png-alphabet/A.png',
'reponse1' => '../png-alphabet/O.png',
'reponse2' => '../png-alphabet/I.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/1-bain.mp3'
) ,
'chx_1' => array(
'chiffre' => '2',
'reponse' => '../png-alphabet/E.png',
'reponse1' => '../png-alphabet/O.png',
'reponse2' => '../png-alphabet/C.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/2-pont.mp3'
) ,
'chx_2' => array(
'chiffre' => '3',
'reponse' => '../png-alphabet/B.png',
'reponse1' => '../png-alphabet/C.png',
'reponse2' => '../png-alphabet/D.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/3-monte.mp3'
) ,
'chx_3' => array(
'chiffre' => '4',
'reponse' => '../png-alphabet/L.png',
'reponse1' => '../png-alphabet/I.png',
'reponse2' => '../png-alphabet/T.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/4-lent.mp3'
) ,
'chx_4' => array(
'chiffre' => '5',
'reponse' => '../png-alphabet/T.png',
'reponse1' => '../png-alphabet/D.png',
'reponse2' => '../png-alphabet/L.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/5-langue.mp3'
) ,
'chx_5' => array(
'chiffre' => '6',
'reponse' => '../png-alphabet/B.png',
'reponse1' => '../png-alphabet/P.png',
'reponse2' => '../png-alphabet/R.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/10-plein.mp3'
));
$reponses1 = array(
'chx_6' => array(
'chiffre' => '7',
'reponse' => '../png-alphabet/O.png',
'reponse1' => '../png-alphabet/C.png',
'reponse2' => '../png-alphabet/G.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/6-trompé.mp3'
),
'chx_7' => array(
'chiffre' => '8',
'reponse' => '../png-alphabet/F.png',
'reponse1' => '../png-alphabet/E.png',
'reponse2' => '../png-alphabet/K.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/7-menteur.mp3'
) ,
'chx_8' => array(
'chiffre' => '9',
'reponse' => '../png-alphabet/H.png',
'reponse1' => '../png-alphabet/I.png',
'reponse2' => '../png-alphabet/J.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/8-plan.mp3'
) ,
'chx_9' => array(
'chiffre' => '10',
'reponse' => '../png-alphabet/S.png',
'reponse1' => '../png-alphabet/T.png',
'reponse2' => '../png-alphabet/D.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/9-train.mp3'
),
'chx_10' => array(
'chiffre' => '11',
'reponse' => '../png-alphabet/R.png',
'reponse1' => '../png-alphabet/N.png',
'reponse2' => '../png-alphabet/M.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/7-menteur.mp3'
) ,
'chx_11' => array(
'chiffre' => '12',
'reponse' => '../png-alphabet/W.png',
'reponse1' => '../png-alphabet/V.png',
'reponse2' => '../png-alphabet/U.png',
'mot' => '',
'btn' => '../btn/oreille.png',
'mp3' => '../mp3/8-plan.mp3'
) 
);
$choix = array(
 'chx' => array('reponse_bonne' => '../png-alphabet/A.png'),
 'chx_1' => array('reponse_bonne' => '../png-alphabet/O.png'),
  'chx_2' => array('reponse_bonne' => '../png-alphabet/B.png'),
  'chx_3' => array('reponse_bonne' => '../png-alphabet/L.png'),
 'chx_4' => array('reponse_bonne' => '../png-alphabet/T.png'),
  'chx_5' => array('reponse_bonne' => '../png-alphabet/R.png'),

);
$choix1 = array(
   'chx_6' => array('reponse_bonne' => '../png-alphabet/O.png'),
 'chx_7' => array('reponse_bonne' => '../png-alphabet/E.png'),
  'chx_8' => array('reponse_bonne' => '../png-alphabet/H.png'),
  'chx_9' => array('reponse_bonne' => '../png-alphabet/S.png'),
   'chx_10' => array('reponse_bonne' => '../png-alphabet/M.png'),
  'chx_11' => array('reponse_bonne' => '../png-alphabet/V.png')
);
$errors = array();
$point = array();
$si = 0.8333333333333333;
$z = 0;
echo'<div style="display:inline-block;width:450px;min-height:350px;border-right:1px solid #000;">';
if (isset($_POST['correction']))
{

foreach($reponses as $cle => $reponse){
$clic = trim($_POST[$cle]);
var_dump($clic);
echo '<button class="button_audio" onclick="playVid(\'son_1'.$cle.'\')" type="button" value="' . $reponse['mp3'] . '"></button>';
echo '<audio id="son_1'.$cle.'">';
echo '<source src="' . $reponse['mp3'] .'" type="audio/mp3">';
echo '<p>Votre navigateur ne supporte pas le format audio.</p>';
echo '</audio>';

if(($clic !== $reponse['reponse']) OR ($clic !== $reponse['reponse1']) OR ($clic !== $reponse['reponse2'])  ){
echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse['chiffre'].'</p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em;"><input class="checkbox" style="margin:10px 0 0 0;" type="radio" name="' . $cle . '" value="' . $reponse['reponse'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="radio" name="' . $cle . '" value="' . $reponse['reponse1'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse1'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="radio" name="' . $cle . '" value="' . $reponse['reponse2'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse2'] .'" width="30px" height="30px" /></p>';

echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok1.jpg" alt="reponse bonne" width:"55" height="55" /></figure><br />';

}else if(($clic == $reponse['reponse']) OR ($clic == $reponse['reponse1']) OR ($clic == $reponse['reponse2'])){
	
$point[$cle] = htmlspecialchars($clic);
var_dump($point[$cle]);

echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse['chiffre'].'</p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em;"><input class="checkbox" style="margin:10px 0 0 0;" type="radio" name="' . $cle . '" value="' . $reponse['reponse'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="radio" name="' . $cle . '" value="' . $reponse['reponse1'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse1'] .'" width="30px" height="30px" /></p>';
echo'<p style="text-align:center;width:100px;font-size:1.2em"><input class="checkbox" style="margin:10px 0 0 0;" type="radio" name="' . $cle . '" value="' . $reponse['reponse2'] . '" /><img style="margin-left:-25px; margin-top:25px;" src="'. $reponse['reponse2'] .'" width="30px" height="30px" /></p>';

echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok1.jpg" alt="reponse bonne" width:"55" height="55" /></figure><br />';
echo $point[$cle];

}else if(($clic != $reponse['reponse']) OR ($clic != $reponse['reponse1']) OR ($clic != $reponse['reponse2'])){

$errors[$cle] = htmlspecialchars($clic);

echo'<p style="font-size:1.2em;padding:0 20px;">'.$reponse['chiffre'].'</p><p style="text-align:center;width:80px;font-size:1.2em;"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle. '" value="' . $reponse['reponse'] . '" />  '. $reponse['reponse'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle . '" value="' . $reponse['reponse1'] . '" />  '. $reponse['reponse1'] .'</p>';
echo'<p style="text-align:center;width:80px;font-size:1.2em"><input style="margin:10px 0 0 -50px;" type="radio" name="' . $cle . '" value="' . $reponse['reponse2'] . '" />  '. $reponse['reponse2'] .'</p>';
echo'<p style="color:red;font-size:1.2em;"><b>'. $errors[$cle].'</b></p>';
echo'<figure style="display:inline-block;margin-top:1em;">';
echo'<img src="../img/ok.jpg" alt="reponse fausse" width:"55" height="55" /></figure><br />';
echo $errors[$cle];


}

} ?>
0
yg_be Messages postés 23337 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 18 novembre 2024 1 551
23 juil. 2018 à 09:29
j'ai l'impression que tes IF sont mal construits. comprends-tu bien la différence entre AND et OR?
tu dois prendre le temps de réfléchir à ces conditions, peut-être en ajoutant un commentaire avant chaque IF, avec une phrase décrivant précisément ce que tu testes.
ajoute un else à la fin, cela te permettra de comprendre quelle condition est vérifiée.
la ligne 149 me semble suspecte: peux-tu décrire ce que tu veux tester?
0
jordane45 Messages postés 38292 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 19 novembre 2024 4 704
23 juil. 2018 à 09:44
J'ajouterai que..... un IF et deux ELSE IF ... dont DEUX tests identiques (ou presque)

if(($clic !== $reponse['reponse']) OR ($clic !== $reponse['reponse1']) OR ($clic !== $reponse['reponse2'])  ){



 }else if(($clic == $reponse['reponse']) OR ($clic == $reponse['reponse1']) OR ($clic == $reponse['reponse2'])){



 }else if(($clic != $reponse['reponse']) OR ($clic != $reponse['reponse1']) OR ($clic != $reponse['reponse2'])){



Tu peux me dire ce que tu penses obtenir de différent entre ton premier IF et le second ELSEIF ?

Je pense également que tu tomberas toujours dans le premier IF .... car tes conditions, telles qu'utilisées, rendront TOUJOURS le premier IF vrai.
Je suppute qu'à la place des OR ce sont les AND que tu voulais utiliser ( AND = && )
Mais ton code, sans aucun commentaire, est trop bordélique pour que je m'y penche d'avantage.
0