tailieunhanh - Phát triển web với PHP và MySQL - p 79

Generating Personalized Documents in Portable Document Format (PDF) CHAPTER 30 755 FIGURE asks the user to answer quiz questions. Grading the Answers When the user submits his answers to the questions in , we need to grade him and calculate a score. This is done by the script called . The code for this script is shown in Listing . LISTING —Script to Mark Exams 30 GENERATING PERSONALIZED DOCUMENTS IN PDF 756 Building Practical PHP and MySQL Projects PART V LISTING Continued Sorry: ”; echo “You need to fill in your name and answer all questions”; } else { //add up the $score = 0; if($q1 == 1) $score++; if($q2. | 755 Generating Personalized Documents in Portable Document Format PDF Chapter 30 Figure asks the user to answer quiz questions. Grading the Answers When the user submits his answers to the questions in we need to grade him and calculate a score. This is done by the script called . The code for this script is shown in Listing . Listing Script to Mark Exams check that all the data was received if q1 ll q2 ll q3 ll name 11 echo h1 p align centerximg src alt 30 Generating Personalized Documents in PDF 756 Building Practical PHP and MySQL Projects Part V Listing Continued Sorry img src 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 if q3 1 the correct answer for q3 is 1 score convert score to a percentage score score 3 100 if score 50 this person failed echo h1 p align center img src alt Sorry img src alt h1 echo p You need to score at least 50 to pass the exam else create a string containing the score to one decimal place score number_format score 1 echo h1 p align center img src alt Congratulations img src 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 method get echo center 757 Generating Personalized Documents in Portable Document Format PDF Chapter 30 Listing Continued input type image src border 0 center echo input type hidden name score value score echo input type hidden name name value name echo form echo p Please click here to download your certificate as a Portable Document Format PDF file. echo form action method get echo center input type image src .

TỪ KHÓA LIÊN QUAN