Guest Post | Submit   Job information   Contents   Link   Youtube Video   Photo   Practice Set   Affiliated Link   Register with us Register login Login
Join Our Telegram Group Join Our Telegram Group https://t.me/educratsweb

Php code for Online Quiz

Posted By educratsweb.comTechnology 🗓 Tuesday June 25 2019 👁 769

Php code for Online Quiz

One Question will appear on a screen when user select the option and click on next question another question appear on screen and after all opting the answer user will click on finish online test then quiz result report will be appear on screen .

Quiz.php

 

 

 

<? include("db_mysql_connect.php"); ?>

<div id="heading">Online Quiz</div>

<br />

<form name="quiz" method="post" action="quiz.php">

  <? if($_POST["do"]=="finish")

{

$rans=$_POST["rans"];

$tq=$_POST["tq"];

$end=$_POST["end"];

$startposition=$_POST["startposition"];

echo "<table cellpadding='5px' align='center' style='border:1px solid silver' width='80%' bgcolor='green'>";

echo "<tr><td>Total Question Attempt</td><td>",$tq,"</td><tr>";

echo "<tr><td>Correct Answer</td><td>",$rans,"</td></tr>";

echo "<tr><td>Wrong Answer</td><td>",$tq-$rans,"</td></tr>";

echo "<tr><td>Correct Answer Percentage</td><td>",$rans/$tq*100,"%</td></tr>";

echo "<tr><td>Wrong Answer Percenntage</td><td>",($tq-$rans)/$tq*100,"%</td></tr>";

echo "</table><br><br>";

$query="select * from quiz where qid<='$end' and qid>='$startposition'";

echo "<table cellpadding='5px' align='center' style='border:1px solid silver'>";

echo "<tr><th colspan='4' id='heading'>Online Quiz Test Question</td></tr>";

$result=mysql_query($query);

while ($row = mysql_fetch_array($result)) {

 echo "<tr><td>",$row[0],"</td><td colspan='2'>",$row[1],"</td></tr><tr><td></td>";

echo "<td colspan='2'>A. ",$row[2],"</td>";

echo "<td colspan='2'>B. ",$row[3],"</td></tr>";

echo "<tr><td></td><td colspan='2'>C. ",$row[4],"</td>";

echo "<td colspan='1'>D. ",$row[5],"</td></tr>";

echo "<tr><td colspan='4' align='right' style='color:orange'>Correct option is ",strtoupper($row[6]),"</td></tr>";

echo "<tr><td colspan='4' align='right' style='color:orange'><hr></td></tr>"; 

 }

 echo "</table>";

 echo "<p align='right'><a href='#' onclick='window.print()'>Print</a></p>"; 

 echo "<div style='visibility:hidden;display:none'>";

}

?>

 <table cellpadding="5px" width="100%" style="border:1px solid silver">

 <?

$start=$_POST["start"];

$s=$_POST["startposition"];

if($start==NULL)

{

$start=$_GET["start"];

$s=$_GET["start"];

}

$useropt=$_POST["useropt"];

$qid=$_POST["qid"];

$rans=$_POST["rans"];

$name=$_POST["name"];

$totalquestion=$_POST["totalquestion"];

if($start==NULL)

$query="select * from quiz where qid='1'";

else

{

$query="select * from quiz where qid='$start'";

}

$result=mysql_query($query);

while ($row = mysql_fetch_array($result)) {

    echo "<tr><td>",$row[0],"</td><td colspan='2'>",$row[1],"</td></tr><tr><td></td><td colspan='2'><input type='radio' name='useropt' value='a' />  ",$row[2],"</td><td colspan='2'><input type='radio' name='useropt' value='b' /> ",$row[3],"</td></tr><tr><td></td><td colspan='2'><input type='radio' name='useropt' value='c' /> ",$row[4],"</td><td colspan='2'><input type='radio' name='useropt' value='d' /> ",$row[5],"</td></tr>";

echo "<tr ><td colspan='5' align='right'><input type='hidden' name='name' value='",$name,"'><input type='hidden' name='start' value='",$row[0]+1,"'><input type='hidden' name='qid' value='",$row[0],"'><input type='hidden' name='startposition' value='",$s,"'><input type='submit' value='Next Question'><input type='hidden' name='totalquestion' value='",$totalquestion+1,"'>";

 echo "</td></tr>";

}

echo "<tr><td colspan='4'>";

$query="select woptcode from quiz where qid='$qid'";

 $result=mysql_query($query);

 while ($row = mysql_fetch_array($result)) {

 if(strcmp($row[0],$useropt)==0)

 {

 echo "<input type='hidden' name='rans' value='",$rans+1,"'>";

 $rans=$rans+1;

 }

 else

 echo "<input type='hidden' name='rans' value='",$rans,"'>";

 }

 echo "</td></tr>";

?>

 </table>

 <center>

 <br />

 <br />

</form>

<form method="post" action="quiz.php">

 <input type="hidden" name="do" value="finish" />

 <input type="hidden" name="rans" value="<? echo $rans;?>" />

 <input type="hidden" name="name" value="<? echo $name;?>" />

  <input type="hidden" name="tq" value="<? echo $totalquestion;?>" />

  <input type="hidden" name="end"  value="<? echo $start-1;?>" />

  <input type="hidden" name="startposition" value="<? echo $s;?>" />

  <input type="submit" value="Finish Online Test"  />

</form>

 

 

Quiz_Entry_Admin.php

 

 

 

<? if($_POST["do"]=="quiz")

{ include("db_mysql_connect.php");

$question=$_POST["question"];

$opt1=$_POST["opt1"];

$opt2=$_POST["opt2"];

$opt3=$_POST["opt3"];

$opt4=$_POST["opt4"];

$woptcode=$_POST["woptcode"];

$query="select * from quiz ";

$temp=1;

 $result=mysql_query($query);

while ($row = mysql_fetch_array($result)) {

$temp=$temp+1;

}

$query="insert into quiz values($temp,'$question','$opt1','$opt2','$opt3','$opt4','$woptcode')";

$result=mysql_query($query);

echo "successfully Saved";

}

?>

<form method="post" action="czone-stu-admin-login.php">

  <table>

    <tr>

      <td colspan="2" id="heading">Online Quiz Test Question Entry Module</td>

    </tr>

    <tr>

      <td>Enter Question here </td>

      <td><input type="text" name="question"  id="gunjan-textbox"/></td>

    </tr>

    <tr>

      <td>Enter First option</td>

      <td><input type="text" name="opt1" id="gunjan-textbox" /></td>

    </tr>

    <tr>

      <td>Enter Second option</td>

      <td><input type="text" name="opt2" id="gunjan-textbox" /></td>

    </tr>

    <tr>

      <td>Enter Third option</td>

      <td><input type="text" name="opt3" id="gunjan-textbox" /></td>

    </tr>

    <tr>

      <td>Enter Fourth option</td>

      <td><input type="text" name="opt4" id="gunjan-textbox" /></td>

    </tr>

    <tr>

      <td>Select Right Option code</td>

      <td><select name="woptcode" id="gunjan-textbox">

          <option value="a">A</option>

          <option value="b">B</option>

          <option value="c">C</option>

          <option value="d">D</option>

        </select>

      </td>

    </tr>

    <tr>

      <td colspan="2"><input type="hidden" name="do" value="quiz" />

        <input type="submit" value="SAVE QUESTION" />

      </td>

    </tr>

  </table>

</form>

db_mysql_connect.php

 

<?

mysql_connect("localhost");

mysql_select_db("quiz") or die("database could not connect ");

?>

 

 

 

Mysql Table “Quiz”

CREATE TABLE `quiz` (

  `qid` int(5) default NULL,

  `Question` text,

  `opt1` text,

  `opt2` text,

  `opt3` text,

  `opt4` text,

  `woptcode` varchar(5) default NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Php code for Online Quiz
Contents shared By educratsweb.com
if you have any information regarding Job, Study Material or any other information related to career. you can Post your article on our website. Click here to Register & Share your contents.
For Advertisment or any query email us at bharatpages.in@gmail.com

RELATED POST
  1. Send personalized email messages to your contacts with Mail Merge for Gmail
  2. Gmail Online Support Australia 1800826163 Gmail Toll Free Phone Number
  3. AVG Support Canada 1-844-780-0303 | AVG Support Canada Phone Number
  4. 5 Ways To Redirect A Website URL
  5. AnyDesk Software
  6. BOOST YOUR WINDOWS PC SPEED / INCREASE COMPUTER SPEED
  7. Requirement of Browser & Java Version for EPF Unified Portal
  8. National Laboratory Directory
  9. Top 15 Online Grocery Stores (Websites + Apps) in India
  10. Classified WordPress Theme
  11. Google Translator Toolkit to be shut down on December 4, 2019
  12. Extracting Data from Dynamic Websites in Real Time
  13. NASA launches satellite to explore where air meets space
  14. Cyotek WebCopy - Copy websites locally for offline browsing
  15. Top 20 Web Crawling Tools to Scrape the Websites Quickly
  16. Best Selenium Training in Chennai
  17. Buy Redmi 6 Pro starts from Rs.10999
  18. Agricultural Technology Information Centre (ATIC)
  19. Php code for Online Quiz
  20. Php code example for login
  21. Agricultural Technology Information Centre (ATIC)
  22. Php code for Comment on Webpage
  23. BEST WAY TO COLLECT PAYMENTS ON YOUR WEBSITE
  24. Dual WhatsApp
  25. Agricultural Technology Information Centre (ATIC)
  26. HTML – Hyper Text Markup Language
  27. Php code for Online Quiz
  28. What You Must Know About Social Media Analysis
  29. 9 Emerging Technologies to Lookout for in 2019
  30. nofollow : Concept and specification
  31. Faculty vacancy posts in Gujarat Technological University (GTU) - 13 Days Remaining for Apply
  32. Technical and Non-Teaching Vacancy Recruitment in Gujarat Vidyapith 2020 - 27 Days Remaining for Apply
  33. Junior Judicial Assistant/Restorer (Open) Examination 2020 by Delhi High Court - 15 Days Remaining for Apply
  34. Recruitment for Scientist and Scientific/Technical Assistant vacancy in NIC - 30 Days Remaining for Apply
  35. Central Teacher Eligibility Test (CTET)July 2020 for Primary/ Elementary Teachers by CBSE - 6 Days Remaining for Apply
  36. Recruitment for Project Manager DIC Vacancy by Bihar PSC - 20 Days Remaining for Apply
  37. Recruitment of Graduate and Management Trainee vacancy in MOIL 2020 - 13 Days Remaining for Apply
  38. ISRO USRC Recruitment 2020: Apply Online for 182 Technician, Scientific Assistant and Various Other Posts - 10 Days Remaining for Apply
  39. Recruitment of Professor Teaching Facultyin Ch. Ranbir Singh University (CRSU), Jind, Haryana 2020 - 10 Days Remaining for Apply
  40. Recruitment of Manager Job Vacancy in TNPL 2020 - 26 Days Remaining for Apply
  41. Non Faculty vacancy in NIT Meghalaya 2020 - 41 Days Remaining for Apply
  42. APSSB Recruitment 2020: Apply Online for Total 944 Vacancies - 11 Days Remaining for Apply
  43. Recruitment of Sub-Inspector, Head-Constable, Constable in BSF Water Wing 2020 - 20 Days Remaining for Apply
  44. Technical Assistant and Technician Recruitment in BIS 2020 - 12 Days Remaining for Apply
  45. Trainee and Plant Engineer job vacancy recruitment in TNPL 2020 - 27 Days Remaining for Apply
  46. Recruitment for the post of Peon vide order dated 10.02.2020 OFFICE OF THE DISTRICT & SESSIONS JUDGE : SAS NAGAR PUNJAB - 3 Days Remaining for Apply
  47. Recruitment of Scientist and JRF in NE-SAC 2020 - 25 Days Remaining for Apply
  48. Government Jobs Vacancy Recruitment by Haryana SSC Advt. No. 1/2020 - 28 Days Remaining for Apply
  49. COMEDK UGET 2020 Examination: Notification, Application Form, Eligibility, Exam Date, Pattern & Syllabus - 52 Days Remaining for Apply
  50. Recruitment of Jr. Engineer Job Vacancy by RSMSSB 2020 - 37 Days Remaining for Apply
Save this page as PDF | Recommend to your Friends

http://educratsweb(dot)com http://educratsweb.com/content.php?id=669 http://educratsweb.com educratsweb.com educratsweb