j'aimerai faire un calcule de bonnes et mauvaises réponses, j'ai créer deux tableau et recupere avec count mais rien a faire...
<?php
$reponses = array(
'chx' => array(
'reponse' => 'une',
'mot' => 'route'
) ,
'chx_1' => array(
'reponse' => 'un',
'mot' => 'four'
) ,
'chx_2' => array(
'reponse' => 'un',
'mot' => 'bouton'
) ,
'chx_3' => array(
'reponse' => 'un',
'mot' => 'jour'
) ,
'chx_4' => array(
'reponse' => 'une',
'mot' => 'poubelle'
) ,
'chx_5' => array(
'reponse' => 'un',
'mot' => 'nouveau'
) ,
'chx_6' => array(
'reponse' => 'un',
'mot' => 'trou'
) ,
'chx_7' => array(
'reponse' => 'une',
'mot' => 'nouvelle'
) ,
'chx_8' => array(
'reponse' => 'un',
'mot' => 'tournevis'
) ,
'chx_9' => array(
'reponse' => 'une',
'mot' => 'douche'
) ,
);
foreach($reponses as $cle => $reponse)
{
if (isset($_POST['correction']))
{
$clic = $_POST[$cle];
$errors = array();
$point = array();
if (empty($clic))
{
$msg = '<p>veuillez remplir tous les champs</p>';
echo $msg;
}
else
if ($clic === $reponse['reponse'])
{
$point[$cle] = htmlspecialchars($clic);
echo '<p style="margin-left:4em;">' . $reponse['reponse'] . '</p><p>' . $reponse['reponse'] . '</p><p style="margin-left:5.3em;">' . $reponse['mot'] . '</p><br />';
}
else
if ($clic !== $reponse['reponse'])
{
$errors[$cle] = htmlspecialchars($clic);
echo '<article><p style="color:red;margin-left:3.9em;"><del>' . $errors[$cle] . '</p></del><p>' . $reponse['reponse'] . '</p><p style="text-align:right;margin-left:5em;">' . $reponse['mot'] . '</p></article>';
}
}
}
echo '<br />';
echo '<p style="display:inline-block;margin:2em 0 0 5%;padding:.5em;background:#54d0ce;font-size:1.2em;">Bonnes réponses :' . count($point[$cle]) . '-' . count($errors[$cle]) . '/10</p>';
echo '<br /><br />';
?>
merci d avance pour vos explications