<?
/*
 * Projet        : Quizz musical avec test des réponses
 * Fichier       : quizz.php
 * Auteurs       : Marc Friederich avec l'aide précieuse de Gilles Doge
 * Copyright     : 2006 (c) antistatique.net
 * Date          : 22.02.2005
 *
 * Description   : Ce code permet d'afficher un formulaire muni de mini lecteurs flash pour proposer un quizz musical via le navigateur.
 *                 Une fois le formulaire validé, la page est rechargée, les réponses vérifiées et les champs sont coloriés en fonctiont des réponses (juste = vert, faux = rouge)
 *
 * Remarque(s)   : Ce code est à disposition de tout le monde, faite vous plaisir ! Un mail ou une plaque de chocolat seront toujours appréciés
 * 
 */


# Les réponses sont stockées dans un tableau à 2 dimensions
  
$resultats = array ( array('le roi lion','roi lion','lion king'),
                       array(
'fight club','fightclub',),
                       array(
'american beauty'),
                       array(
'apollo 13','apolo 13','apollo xiii','apollo'),
                       array(
'blues brothers','blues brothers 2000','blues brother'),
                       array(
'bagdad cafe','bagdad café','bagdad'),
                       array(
'le professionnel','the professional'),
                       array(
'forest gump'),
                       array(
'conair','les ailes de l\'enfer'),
                       array(
'matrix','the matrix'),
                       array(
'the beach','la plage'),
                       array(
'reservoir dogs','tarantino'),
                       array(
'the rock')
                     );
# initialisations des variables 
$extrait "";
$nb_extraits 13
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Quizz musical</title>

</head>

<body>
<style type="text/css">
body{
    font-family:Arial, Helvetica, sans-serif;
    font-size:10px;
    background-color:#fafafa;
    }
.res{
    font-family:Arial, Helvetica, sans-serif;
    font-size:11px;
    }
.f{
    background-color:#ffadad;
    font-family:Arial, Helvetica, sans-serif;
    font-size:10px;
    }
.r{
    background-color:#d7ffad;
    font-family:Arial, Helvetica, sans-serif;
    font-size:10px;
    }
.n{
    background-color:#FFFFFF;
    font-family:Arial, Helvetica, sans-serif;
    font-size:10px;
    }
</style>
<form action="" method="post" name="quizzmusic">
<table width="420" border="0" cellspacing="0" cellpadding="4">
<?
for ($i=0$i $nb_extraits$i++) {
  
# recupere le i-ème extrait
  
$extrait strtolower($_POST['extrait'.($i+1)]); # si le premier extrait est 1 et non 0
    
echo '
          <tr>
              <td>
                '
.($i+1).'
            </td>
            <td width="155">
        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="150" height="20" id="dewplayer" align="middle">
            <param name="allowScriptAccess" value="sameDomain" />
            <param name="movie" value="swf/dewplayer-mini.swf?mp3=mp3/extrait'
.($i+1).'.mp3&amp;bgcolor=FFFFFF" />
            <param name="quality" value="high" />
            <param name="bgcolor" value="FFFFFF" />
            <embed src="swf/dewplayer-mini.swf?mp3=mp3/extrait'
.($i+1).'.mp3&amp;bgcolor=FFFFFF" quality="high" bgcolor="FFFFFF" width="150" height="20" name="dewplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">    </embed></object>
        </td>
    '
;
  
# Test si la réponse donnée par l'internaute est correcte
  
if ( in_array($extrait$resultats[$i]) ) {
     
$statut "r";
     
$totalpoints $totalpoints 1;
  } else {
      if(
$extrait){
         
$statut "f";
     }else{
         
$statut "n";
     }
  }
  
# affichage du formulaire -> coloration du champ selon le style CSS f ou r
  
echo '<td><input name="extrait'.($i+1).'" type="text" size="25" class="'.$statut.'" value="'.$extrait.'"/></td>
          </tr>    
            '
;
}                 


?>  <tr>
    <td>&nbsp;</td>
    <td class="res">
        <?
        
if($totalpoints){
            echo 
"<b>total</b> : ".$totalpoints." points / ".$nb_extraits ;
        }
        
?>    
    </td>
    <td>
        <input type="submit" name="Submit" value="Verifier" />
    </td>
  </tr>             
</table>
</form>

</body>
</html>