$config[2]$config[3]


"); if ($Validate != "Validate") { $fp = fopen("$path/quizz$voir_num/quizz_data$voir_num.dat","r"); $nbq = fgets($fp,10000); if ($page=="") { $page=1; } if ( ($Validate=="Previous") && ($page>1) ) { $page-=$max_q_page; } if ( ($Validate=="Next") && (($page+$max_q_page-1)<$nbq) ) { $page+=$max_q_page; } print ("

"); print "\n"; if ($page==1) { print ("\n


Enter your name/nickname: "); print ("\n
Enter your teacher's email: "); } else { /* Data validity test **********************/ function error($error) { print ("

 

$error

 

 

"); exit; } if (($Email == "") || ($Name == "")) { $error="You must enter your name/nickname and your email"; error($error); } if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$", $Email)) { $error="Invalid email"; error($error); } $reponses = fopen("$path/quizz$voir_num/quizz_reponses$voir_num.dat", "r"); while(!feof($reponses)) { $ligne = fgets($reponses, 10000); /* if (strpos($ligne,$Email) != 0) { $error="You have already participated to the quiz!"; error($error); }*/ } fclose($reponses); print ("\n"); print ("\n"); } /* Questions display *********************/ echo "\n


There are $nbq question(s) in the quiz...
(Question coefficient between brackets)"; echo "\n


question $page to "; if (($page+$max_q_page-1)<$nbq) { echo $page+$max_q_page-1; } else { echo $nbq; } echo "


"; for ($question=1; $question <=$nbq; $question++) { $data = fgetcsv($fp,10000,";"); $num = count($data); $temp_rep="q$question"; $temp_rep=$$temp_rep; if (($question<$page)||($question>($page+$max_q_page-1))) { print "\n"; } else { print "\n\nQuestion $question : "; echo stripslashes($data[0]); print " ($data[2])"; for ( $c=4; $c<$num; $c++ ) { print "\n$config[4]$data[$c]"; } print "\n$config[5]"; } } fclose($fp); print "

"; if ($page>1) { print ""; } if (($page+$max_q_page)>$nbq) { print ""; } else { print ""; } print "
"; print (""); print "$config[6]"; } else { /* Data validity test (2) ********************************/ function error($error) { print ("

 

$error

 

 

"); exit; } $complet=1; for ($question=1; $question <=$nbq; $question++) { $temp = "q".$question; if ($$temp == "") { $complet=0; }; } if ($complet == 0) { $error="Please try to answer all the questions!"; error($error); } /* Answers analysis *****************/ $score=0; $score_tot=0; $mailBody_Reponses=""; $fp = fopen("$path/quizz$voir_num/quizz_data$voir_num.dat","r"); $nbq = fgets($fp,10000); for ($question=1; $question <=$nbq; $question++) { $data = fgetcsv($fp,10000,";"); $num = count($data); $reponse = "q".$question; $reponse = $$reponse; $mailBody_Reponses .= "Question: $data[0] : $reponse. The right answer is: $data[1]\n"; if ($config[8] == "Yes") { print "\n\n

Question: $question : "; echo stripslashes($data[0]); print "\n
You have answered: $reponse"; } if (strcasecmp($reponse, $data[1]) != 0) { if ($config[8] == "Yes") { print "\n
The right answer was "; echo stripslashes($data[1]); echo stripslashes($data[3]); } $score_tot +=$data[2]; } else { if ($config[8] == "Yes") { print "\n
Congratulations, it is the right answer!"; echo stripslashes($data[3]); } $score += $data[2]; $score_tot +=$data[2]; } } if ($config[8] == "Yes") { print "\n\n

Your score: $score/$score_tot

"; } fclose($fp); /* Scores update ******************/ $date = Date("d/m/Y"); $reponses = fopen ("$path/quizz$voir_num/quizz_reponses$voir_num.dat","a"); fputs($reponses, "$score;$Name;$Email;$date\n"); fclose($reponses); if ($config[8] == "Oui") { $classement = file ("$path/quizz$voir_num/quizz_reponses$voir_num.dat"); function cmp ($a, $b) { $c=explode(';',$a); $d=explode(';',$b); return ($c[0] > $d[0]) ? -1 : 1; } usort ($classement, cmp); $np=count($classement); if ($config[7] > 0) { print "\n\n


Ranking - Top $config[7]
"; if ($np < $config[7]) { $config[7]=$np; } for ($i=0; $i<$config[7]; $i++) { $temp=explode(';',$classement[$i]); if ($temp[2] == $Email) { $temp[1]="$temp[1]"; } print "\n

  • $temp[1] a obtenu $temp[0] point(s) le $temp[3]"; } } } else { print "\n
    Thank you for participating to the quiz


    "; } print "\n


    $config[6]

    © 2000, PHP Vault

    "; /* Sends confirmation email ****************************/ $mailTo_1 = "$Email"; $mailTo_2 = "$config[11]"; $mailHeaders = "From : $config[11]"; $mailSubject = "[ $config[0] ]"; $mailBody_1 = "$config[0] ------------------------------ You have answered: $mailBody_Reponses Your score: $score point(s) / $score_tot Thank you for participating! ------------------------------------------------- $config_gen[0] $config_gen[1] "; $mailBody_2 = "$config[0] ------------------------------ This is an automatic email to notify you a participation to the quiz on $date. Name: $Name Email: $Email IP: $REMOTE_ADDR He answered: $mailBody_Reponses His score: $score point(s) / $score_tot"; $mailBody_3 = "$config[0] ------------------------------ This is a confirmation to your participation to the quiz on $date. Thank you for using PHPVault Quiz ! ------------------------------------------------- $config_gen[0] $config_gen[1]"; if ($config[9] == "Yes") { if ($config[8] == "Yes") { mail($mailTo_1, $mailSubject, $mailBody_1, $mailHeaders); } else { mail($mailTo_1, $mailSubject, $mailBody_3, $mailHeaders); } } if ($config[10] == "Yes") { mail($mailTo_2, $mailSubject, $mailBody_2, $mailHeaders); } } print (""); ?>