Listing du fichier sen_quests3.php
00001 <?php
00002
00003 # connexion à la base de données statad sur forge avec l'utilisateur anonymous
00004
00005 $cnx = @mysql_connect("localhost","anonymous","anonymous") or die("problème de connexion") ;
00006 mysql_select_db("statad") or die("problème avec statad") ; ;
00007
00008 #######################################
00009
00010 function questCalcul() {
00011
00012 #######################################
00013
00014 # on affiche tous les exercices
00015
00016 h2("Questionnaire en Calcul") ;
00017 $nomtable = "sen_CALC" ;
00018 blockquote() ;
00019 $champ1 = "EXPR" ;
00020 $champ2 = "RES" ;
00021 $reqc = " SELECT $champ1 , $champ2 FROM $nomtable " ;
00022 $resc = mysql_query($reqc) ;
00023 $nbex = 0 ;
00024 while ($tabr=mysql_fetch_array($resc)) {
00025 $nbex++ ;
00026 div('cadre') ;
00027 blockquote() ;
00028 p() ;
00029 echo "\n ".em("Exercice")." $nbex " ;
00030 finp() ;
00031 $expr = $tabr[$champ1] ;
00032 $resu = $tabr[$champ2] ;
00033 p() ;
00034 echo " Combien vaut " ;
00035 echo s_span(" $expr ",'tarose') ;
00036 echo " ? " ;
00037 input_text("calc$nbex","",15,'tajaunec') ;
00038 finp() ;
00039 finblockquote() ;
00040 findiv() ;
00041 } ; # fin de tant que
00042 finblockquote() ;
00043
00044 } ; # fin de fonction questCalcul
00045
00046 #######################################
00047 #######################################
00048
00049 function questHistoire() {
00050
00051 #######################################
00052
00053
00054 # on affiche soit la première moitié, soit la deuxième moitié des exercices
00055
00056 h2("Questionnaire d'Histoire") ;
00057 $nomtable = "sen_HIST" ;
00058 blockquote() ;
00059 $champ1 = "EVENEMENT" ;
00060 $champ2 = "DATE" ;
00061 $reqh = " SELECT $champ1 , $champ2 FROM $nomtable " ;
00062
00063 $nbExoHist = 6 ;
00064 $milieu = $nbExoHist / 2 ;
00065 $ta = rand(1,2) ; # tirage aléatoire
00066 if ($ta==1) { # première moitié
00067 $lim = " LIMIT 0 , $milieu " ;
00068 } else { # deuxième moitié
00069 $lim = " LIMIT $milieu , $milieu " ;
00070 } ; # fin de si
00071
00072 # on rajoute le filtrage de lignes à la requete
00073
00074 $reqh .= $lim ;
00075
00076 /* p(); echo "$reqh" ; finp() ; */
00077
00078 $resh = mysql_query($reqh) ;
00079 $nbex = 0 ;
00080 while ($tabr=mysql_fetch_array($resh)) {
00081 $nbex++ ;
00082 div('cadre') ;
00083 blockquote() ;
00084 p() ;
00085 echo "\n ".em("Exercice")." $nbex " ;
00086 finp() ;
00087 $eve = $tabr[$champ1] ;
00088 $dat = $tabr[$champ2] ;
00089
00090 p() ;
00091 echo " En quelle année a eu lieu " ;
00092 finp() ;
00093
00094 p() ;
00095 echo s_span(" $eve ",'tarose') ;
00096 echo " ? " ;
00097 finp() ;
00098
00099 p() ;
00100 input_text("calc$nbex","",10,'tajaunec') ;
00101 finp() ;
00102
00103 finblockquote() ;
00104 findiv() ;
00105 } ; # fin de tant que
00106 finblockquote() ;
00107
00108 } ; # fin de fonction questHistoire
00109
00110 #######################################
00111 #######################################
00112
00113 function questGeographie() {
00114
00115 #######################################
00116
00117 # on affiche 1 exercice parmi les 3 premiers faciles
00118 # 1 exercice parmi les 3 suivant toujours faciles
00119 # et encore 1 exercice parmi les 3 difficiles
00120
00121 h2("Questionnaire de Géographie") ;
00122 $nomtable = "sen_GEOG" ;
00123 div('cadre') ;
00124 blockquote() ;
00125
00126 $champ1 = "PAYS" ;
00127 $champ2 = "CAPI" ;
00128 $champ3 = "DIFF" ;
00129 $reqg = " SELECT $champ1 , $champ2 , $champ3 FROM $nomtable " ;
00130 $nbex = 0 ;
00131
00132 $nbex++ ;
00133 $tira = rand(1,3) -1 ;
00134 $lim = " WHERE diff = 1 LIMIT $tira , 1 " ;
00135 $req1 = $reqg . $lim ;
00136 exoGeog($nbex,$req1) ;
00137
00138 $nbex++ ;
00139 $tira = rand(4,6) -1 ;
00140 $lim = "WHERE diff = 1 LIMIT $tira , 1 " ;
00141 $req2 = $reqg . $lim ;
00142 exoGeog($nbex,$req2) ;
00143
00144 $nbex++ ;
00145 $tira = rand(1,3) -1 ;
00146 $lim = "WHERE diff = 2 LIMIT $tira , 1 " ;
00147 $req3 = $reqg . $lim ;
00148 exoGeog($nbex,$req3) ;
00149
00150 finblockquote() ;
00151 findiv() ;
00152
00153 } ; # fin de fonction questGeographie
00154
00155 #######################################
00156
00157 function exoGeog($e,$r) {
00158
00159 $champ1 = "PAYS" ;
00160 $champ2 = "CAPI" ;
00161 $champ3 = "DIFF" ;
00162
00163 $resg = mysql_query($r) ;
00164 $tabr=mysql_fetch_array($resg) ;
00165 $pays = $tabr[$champ1] ;
00166 $capi = $tabr[$champ2] ;
00167 $diff = $tabr[$champ3] ;
00168
00169 p() ;
00170 echo "\n ".em("Exercice")." $e " ;
00171 finp() ;
00172 p() ;
00173 echo " Quelle est la capitale du pays " ;
00174 echo s_span(" $pays ",'tarose') ;
00175 input_text("calc$e","",25,'tajaunec') ;
00176 finp() ;
00177
00178 } ; # fin de fonction exoGeog
00179
00180 #######################################
00181
00182 ?>
La coloration syntaxique est réalisée par un enrobage de la function php nommée highlight_file
mais si vous préférez, vous pouvez utiliser celle de SyntaxHighlighter ou même celle de geshi.
Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.
Retour à la page principale de (gH)