Advertisement
mobilefish

Untitled

Jan 1st, 2021
1,260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.79 KB | None | 0 0
  1. <?php
  2. include 'include.php';
  3. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  4. mysql_select_db("$db_name")or die("cannot select DB");
  5. $sc_id='';
  6. $sc_name='';
  7. $sc_description='';
  8. $sc_active='';
  9. $op_mode='';
  10.  
  11. //question
  12. $qm_id='';
  13. $qm_text='';
  14. $qm_active='';
  15. $sm_active='';
  16. //answer
  17. $row_count=0;
  18.  
  19. session_start();
  20. if(!isset($_SESSION['username']) || trim($_SESSION['username'])=='')
  21. {
  22.     header("location:index.php");
  23. }
  24. else
  25. {
  26.     $uid=$_SESSION['userid'];
  27.     $username=$_SESSION['username'];
  28.     $usertype=$_SESSION['usertype'];
  29.  
  30. }
  31. ?>
  32.  
  33. <?php
  34.      if(!isset($_SESSION))
  35.      {
  36.        session_start();
  37.      }
  38.     $currind=0;
  39.     $currind=$_SESSION['currind'];
  40.     $next_id=$currind;//$_GET["next_id"];
  41.     $id=$_GET["id"];
  42.    
  43.     if($_POST['BtnNext']=='  Next >  ')
  44.     {
  45.         $row_count=0;
  46.         $next_id=0;
  47.         $currind=0;
  48.         $currind=$_SESSION['currind'];
  49.         $next_id=$currind;
  50.        
  51.  
  52.    
  53.    
  54.         $next_id=$next_id+1;
  55.         $_SESSION['currind']=$next_id;
  56.        
  57.        
  58.         $sql="SELECT  q.*,e.* FROM user_question_master q, exam_master e
  59.         where q.um_q_exam_id=e.e_id and e.e_id=".$id." and um_u_id=".$uid;
  60.                 //echo($id);
  61.                  $result=mysql_query($sql) or die(mysql_error());
  62.         //row count
  63.         $row_count=mysql_num_rows($result);
  64.         //echo($row_count-1);
  65.        
  66.        
  67.         //-----------------
  68.                 //update answers
  69.                 for($i=1;$i<=4;$i++)
  70.                 {                  
  71.                         $checkbox="Chk".$i;
  72.                         $radiobutton="Rd".$i;
  73.                         //check the question type and save                 
  74.                         //if ( $_POST[$radiobutton]='ON' || $_POST[$checkbox]!='' )
  75.                         if ( $_POST['Rd1']==$i || $_POST[$checkbox]=='1' )
  76.                         {
  77.                                 $chk_dis=1;
  78.                         }
  79.                         else
  80.                         {
  81.                                 $chk_dis=0;
  82.                         }
  83.                
  84.                     $sql=" update user_answer_master set um_selected = ".$chk_dis." where um_seq=". $i." and um_u_id=".$uid." and um_a_question_id= ".$_SESSION['currentqstid'];
  85.                        
  86.                
  87.                     $result1=mysql_query($sql) or die(mysql_error());  
  88.                     //s.`usd_id`, s.`usd_us_id`, s.`usd_o_id`, s.`usd_o_select`, s.`usd_text`
  89.                     $last_detail_id=$last_detail_id+1;                 
  90.                 }              
  91.                
  92.             //echo (" >>> ". $next_id." ...".$row_count);
  93.         if($next_id> $row_count-1)
  94.         {
  95.                         //echo (" >>> ". $next_id);
  96.             header("location:exam_complete.php?id=".$id);
  97.              
  98.         }
  99.        
  100.  
  101.  
  102.        
  103.        
  104.     }
  105.    
  106.     if($_POST['BtnPrevious']=='< Previous')
  107.     {
  108.        
  109.         $currind=0;
  110.         $currind=$_SESSION['currind'];
  111.         $next_id=$currind;
  112.         if ($next_id>0)
  113.         {
  114.        
  115.             $next_id=$next_id-1;
  116.             $_SESSION['currind']=$next_id;
  117.                        
  118.                        
  119.                                         //update answers
  120.                     for($i=1;$i<=4;$i++)
  121.                     {                  
  122.                             $checkbox="Chk".$i;
  123.                             $radiobutton="Rd".$i;
  124.                             //check the question type and save                 
  125.                             //if ( $_POST[$radiobutton]='ON' || $_POST[$checkbox]!='' )
  126.                             if ( $_POST['Rd1']==$i || $_POST[$checkbox]=='1' )
  127.                             {
  128.                                     $chk_dis=1;
  129.                             }
  130.                             else
  131.                             {
  132.                                     $chk_dis=0;
  133.                             }
  134.  
  135.                         $sql=" update user_answer_master set um_selected = ".$chk_dis." where um_seq=". $i." and um_u_id=".$uid." and um_a_question_id= ".$_SESSION['currentqstid'];
  136.  
  137. //echo($sql);
  138. //exit;
  139.                         $result1=mysql_query($sql) or die(mysql_error());  
  140.                         //s.`usd_id`, s.`usd_us_id`, s.`usd_o_id`, s.`usd_o_select`, s.`usd_text`
  141.                         $last_detail_id=$last_detail_id+1;                 
  142.                     }
  143.            
  144.         }
  145.  
  146.     }
  147.    
  148.  
  149.  
  150. ?>
  151.  
  152. <?php
  153.     $sql="SELECT  q.*,e.* FROM user_question_master q, exam_master e
  154.         where q.um_q_exam_id=e.e_id and um_u_id =".$uid;
  155.     //echo($sql);
  156.     $result=mysql_query($sql) or die(mysql_error());
  157.     //row count
  158.     $row_count_disp=mysql_num_rows($result);
  159.  
  160.  
  161.     $id=$_GET["id"];
  162.    
  163.     if(!isset($_SESSION))
  164.     {
  165.     session_start();
  166.     }
  167.     $currind=0;
  168.     $currind=$_SESSION['currind'];
  169.     $next_id=$currind;
  170.          
  171.        
  172.     $sql="SELECT  q.*,e.* FROM user_question_master q, exam_master e
  173.         where q.um_q_exam_id=e.e_id and um_u_id =".$uid;
  174.     //echo($sql);
  175.     $result=mysql_query($sql) or die(mysql_error());
  176.     //row count
  177.     $row_count=mysql_num_rows($result);
  178.    
  179.     //$qm_id=mysql_num_rows($result);
  180.     $qm_id=mysql_result($result,$next_id,"um_q_id");
  181.     $_SESSION['currentqstid']=$qm_id;
  182.     $qm_text=mysql_result($result,$next_id,"um_q_text");
  183.     $qm_type=mysql_result($result,$next_id,"um_q_type");
  184.     $e_name=mysql_result($result,$next_id,"e_name");
  185.     //echo($sql);
  186.    
  187.     $sql="SELECT  * FROM user_answer_master  
  188.         where um_a_question_id=".$qm_id." and um_u_id=".$uid." order by um_seq";
  189.    
  190.     //echo($sql);
  191.         $result=mysql_query($sql) or die(mysql_error());
  192.        
  193.         $op_text1=mysql_result($result,0,"um_a_answer");
  194.     $op_text2=mysql_result($result,1,"um_a_answer");
  195.     $op_text3=mysql_result($result,2,"um_a_answer");
  196.     $op_text4=mysql_result($result,3,"um_a_answer");
  197.    
  198.    
  199.         $is_checked1="";
  200.         $is_checked2="";
  201.         $is_checked3="";
  202.         $is_checked4="";
  203.        
  204.         $sql2=" select * from user_answer_master
  205.              where um_u_id=".$uid." and um_a_question_id= ".$qm_id." order by um_seq " ;
  206.        
  207.                 echo($sql12);
  208.                 $result2=mysql_query($sql2) or die(mysql_error());
  209.         $row_count2=mysql_num_rows($result2);
  210.         //echo($row_count2);
  211.         if ($row_count2>0)
  212.         {
  213.             if (mysql_result($result2,0,"um_selected")==1)
  214.             {
  215.                 $is_checked1="checked";
  216.             }
  217.             if (mysql_result($result2,1,"um_selected")==1)
  218.             {
  219.                 $is_checked2="checked";
  220.             }
  221.             if (mysql_result($result2,2,"um_selected")==1)
  222.             {
  223.                 $is_checked3="checked";
  224.             }
  225.             if (mysql_result($result2,3,"um_selected")==1)
  226.             {
  227.                 $is_checked4="checked";
  228.             }
  229.            
  230.         }
  231.         //echo ("type =".$qm_type);
  232.         if ($qm_type=='SINGLE')
  233.         {
  234.             $text_display=" ";
  235.             $file_display="style='display:none'";
  236.             $chk_display="style='display:none'";
  237.             $rd_display=" ";
  238.            
  239.                 $link1=" ";
  240.             $link2=" ";
  241.             $link3=" ";
  242.             $link4=" ";
  243.         }
  244.        
  245.        
  246.         if ($qm_type=='MULTIPLE')
  247.         {
  248.         $text_display=" ";
  249.             $file_display="style='display:none'";
  250.             $chk_display=" ";
  251.             $rd_display="style='display:none'";
  252.            
  253.                     $link1=" ";
  254.             $link2=" ";
  255.             $link3=" ";
  256.             $link4=" ";
  257.            
  258.         }
  259.        
  260.  
  261.  
  262.  
  263. ?>
  264.  
  265.  
  266.  
  267. <html>
  268.  
  269. <head>
  270. <meta http-equiv="Content-Language" content="en-us">
  271. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  272. <title>eExamination :: Examination Main</title>
  273. <link href="style/Style1.css" rel="stylesheet" type="text/css" />
  274.  
  275.  
  276.  
  277.  
  278.  
  279. </head>
  280.  
  281. <body>
  282. <form name="form1"  method="post" action="exam_main.php?id=<?php echo($id)?>&next_id=<?php echo($next_id)?>" >
  283. <div align="center">
  284.     <table border="0" width="100%" cellspacing="1" height="100%" id="table1">
  285.         <tr>
  286.             <td  align="center" class ="td_top">
  287.             <?php
  288.             include 'header.php';
  289.             ?>  
  290.                            
  291.                         </td>
  292.         </tr>
  293.         <tr>
  294.             <td  align="left" class ="td_topvav" >
  295.             <table width ="100%" align ="left">
  296.                 <tr>
  297.                     <td width="33%" align ="left" style="padding-left: 10px" valign="top">
  298.                         Welcome <b><?php echo($username.'</b> ('.$usertype.')') ?>  
  299.                     </td>
  300.                     <td  width="64%" align="right" style="padding-right: 10px" valign="top">
  301.                    
  302.                     <?php
  303.                                             include 'menu.php';
  304.                     ?>
  305.                     </td>
  306.                 </tr>
  307.  
  308.  
  309.             </table>
  310.            
  311.            
  312.            
  313.             </td>
  314.         </tr>
  315.        
  316.         <tr >
  317.             <td align="center" >
  318.             &nbsp;
  319.  
  320.                
  321.                 <br>
  322.  
  323.             <p>
  324.            
  325.            
  326.            
  327. <table border="0" width="497" id="table9">
  328.                     <tr>
  329.                         <td width="491">
  330.                         <table border="0" width="100%" id="table10" style="border: 1px solid #00CC99">
  331.                             <tr>
  332.                                 <td>
  333.                                 <table border="0" width="483" id="table11" cellpadding="2">
  334.  
  335.                                     <tr>
  336.                                         <td align="left" valign="bottom" style="padding-left: 10px" width="467" class="td_tablecap1" >
  337.                                         <b>Examination</b> :  <?php  echo($e_name) ?>
  338.                                         </td>
  339.                                     </tr>
  340.                                     <tr>
  341.                                         <td align="left" valign="bottom" style="padding-left: 10px" width="467">
  342.                                         <b>Question No</b> : <?php echo($next_id+1);?>
  343.                                             </td>
  344.                                     </tr>
  345.                                     <tr>
  346.                                         <td align="left" valign="bottom" style="padding-left: 10px" width="467">
  347.                                             <b>Question</b> : <?php echo($qm_text); ?></td>
  348.                                     </tr>
  349.                                     <tr>
  350.                                         <td align="left" valign="bottom" style="padding-left: 10px" width="467">
  351.                                         &nbsp;
  352.                                         </td>
  353.                                     </tr>
  354.                                     <tr>
  355.                                         <td align="left" valign="bottom" style="padding-left: 10px" width="467">
  356.                                         <u><b>Options</b></u></td>
  357.                                     </tr>
  358.                                     <tr>
  359.                                         <td align="left" valign="bottom" style="padding-left: 10px" width="467">
  360.                                         <table border="0" width="100%" id="table12">
  361.                                             <tr>
  362.                                                 <td width="4" align="left" valign="top">
  363.                                             <b>A.</b></td>
  364.                                                 <td width="4" align="left" valign="top">
  365.                                             <input type="checkbox" name="Chk1" value="1"  <?php echo($chk_display); echo(" "); echo($is_checked1);?> ><input type="radio" value="1" name="Rd1"  <?php echo($rd_display); echo(" "); echo($is_checked1);?> ></td>
  366.                                                 <td align="left" valign="top"> <?php echo($op_text1); ?> <div id="div1"><?php echo($link1); ?></div></td>
  367.                                             </tr>
  368.                                             <tr>
  369.                                                 <td width="4" align="left" valign="top">
  370.                                             <b>B.</b></td>
  371.                                                 <td width="4" align="left" valign="top">
  372.                                             <input type="checkbox" name="Chk2" value="1" <?php echo($chk_display); echo(" "); echo($is_checked2); ?> ><input type="radio" value="2" name="Rd1"  <?php echo($rd_display); echo(" "); echo($is_checked2); ?> ></td>
  373.                                                 <td align="left" valign="top"> <?php echo($op_text2);?><div id="div2"><?php echo($link2); ?></div> </td>
  374.                                             </tr>
  375.                                             <tr>
  376.                                                 <td width="4" align="left" valign="top">
  377.                                             <b>C.</b></td>
  378.                                                 <td width="4" align="left" valign="top">
  379.                                             <input type="checkbox" name="Chk3" value="1" <?php echo($chk_display); echo(" "); echo($is_checked3); ?> ><input type="radio" value="3" name="Rd1"  <?php echo($rd_display); echo(" "); echo($is_checked3); ?> ></td>
  380.                                                 <td align="left" valign="top"><?php echo($op_text3);?><div id="div3"><?php echo($link3); ?>
  381.                                                 </td>
  382.                                             </tr>
  383.                                             <tr>
  384.                                                 <td width="4" align="left" valign="top">
  385.                                             <b>D.</b></td>
  386.                                                 <td width="4" align="left" valign="top">
  387.                                             <input type="checkbox" name="Chk4" value="1" <?php echo($chk_display); echo(" "); echo($is_checked4); ?> ><input type="radio" value="4" name="Rd1"  <?php echo($rd_display); echo(" "); echo($is_checked4); ?> ></td>
  388.                                                 <td align="left" valign="top"> <?php echo($op_text4);?><div id="div4"><?php echo($link4); ?></div>
  389.                                                  </td>
  390.                                             </tr>
  391.                                         </table>
  392.                                         </td>
  393.                                     </tr>
  394.                                     <tr>
  395.                                         <td align="left" style="padding-left: 10px" width="467">
  396.                                             &nbsp;</td>
  397.                                     </tr>
  398.                                     <tr>
  399.                                         <td align="left" style="padding-left: 10px" width="467">
  400.                                             <input type="submit" value="< Previous" name="BtnPrevious" class="ButtonStyle">&nbsp; &nbsp; <?php echo(($next_id+1)."/".$row_count_disp) ?> &nbsp; &nbsp;
  401.                                             <input type="submit" value="  Next >  " name="BtnNext" class="ButtonStyle">&nbsp;&nbsp;
  402.                                             </td>
  403.                                     </tr>
  404.                                     </table>
  405.                                 </td>
  406.                             </tr>
  407.                         </table>
  408.                         </td>
  409.                     </tr>
  410.                 </table>           
  411.            
  412.            
  413.            
  414.             <p>&nbsp;</td>
  415.         </tr>
  416.         <tr>
  417.             <td  align="center" class ="td_copyright">
  418.                           <?php
  419.             include 'footer.php';
  420.             ?>                          
  421.                            
  422.                         </td>
  423.         </tr>
  424.        
  425.        
  426.     </table>
  427. </div>
  428. </form>
  429. </body>
  430.  
  431. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement