<?
تولید مستندات ذات طابع شخصي في تنسيق المستند المحمول (PDF)
الفصل 30
السرد (230) score.php - نص برمجي لاحتساب علامات الامتحانات
// check that all the data was received
if($ql==''|| $q2==' ' || $q3==' ' || $name=='')
{
}
echo "<h1><p align=center><img src='rosette.gif' alt=''>
Sorry:
<img src='rosette.gif' alt=''></h1>";
echo "<p>You need to fill in your name and answer all questions";
else
{
//add up the scores
$score = 0;
if($q1 == 1) // the correct answer for q1 is 1 $score++;
if($q2 == 1) // the correct answer for q2 is 1 $score++;
==
1) // the correct answer for q3 is 1
if($q3 $score++;
//convert score to a percentage
$ score
=
$score 3 * 100;
if($score < 50)
{
}
// this person failed
echo "<h1><p align=center><img src= 'rosette.gif' alt=''>
Sorry:
<img src='rosette.gif' alt
echo "<p>You need to score at least 50% to pass the exam";
else
{
= ''></h1>";
// create a string containing the score to one decimal place $score = number_format($score, 1);
echo "<h1><p align =
center><img src='r osette.gif' alt=''> Congratulations
<img src= 'rosette.gif' alt=''></h1>";
echo "<p>Well done $name, with a score of $score%, you have passed the exam. ";
// provide links to scripts that generate the certificates echo "<p>Please click here to download your certificate as a Microsoft Word (RTF) file. ":
echo "<form action = 'rtf.php' method echo "<center>
=
get>";
=
<input type = image src = 'certificate.gif' border 0> </center>";
=
echo "<input type = hidden name = score value = '$score'>"; echo "<input type = hidden name = name value '$name'>"; echo "</form>";
796
ص٧٨٠