PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/enterques.php

https://bitbucket.org/krishna2793/aces
PHP | 177 lines | 123 code | 32 blank | 22 comment | 7 complexity | a0b004851d883f0edb22ad71610ed85f MD5 | raw file
  1. <?php
  2. //error_reporting(E_ALL);
  3. //ini_set('display_errors', '1');
  4. require_once ('Auth_staff.php');
  5. session_start();
  6. $auth = new Auth_staff();
  7. if (!isset($_SESSION['user_id']))
  8. {
  9. //Not logged in, send to login page.
  10. header( 'Location: login.php' );
  11. }
  12. else
  13. {
  14. //Check we have the right user
  15. $logged_in = $auth->checkSession();
  16. if(empty($logged_in)){
  17. //Bad session, ask to login
  18. $auth->logout();
  19. header( 'Location: login.php' );
  20. }
  21. else
  22. {
  23. //User is logged in, show the page
  24. ?>
  25. <!DOCTYPE html>
  26. <html>
  27. <head>
  28. <title>ACES : HOME</title>
  29. <!-- Include the bootstrap stylesheets -->
  30. <link rel="stylesheet" href="bootstrapnew.css"/>
  31. </head>
  32. <body>
  33. <div class="navbar navbar-fixed-top">
  34. <div class="navbar-inner">
  35. <div class="container">
  36. <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
  37. <span class="icon-bar"></span>
  38. <span class="icon-bar"></span>
  39. <span class="icon-bar"></span>
  40. </a>
  41. <a class="brand" href="http://www.amrita.edu/">AMRITA</a>
  42. <div class="nav-collapse" id="main-menu">
  43. <ul class="drop" id="main-menu-left">
  44. <li><a id="swatch-link" href="/staff_mcq_score.php" >Scores Mcq</a></li>
  45. <li class="dropdown" id="test-menu">
  46. <a class="dropdown-toggle" data-toggle="" href="#"> Add Question <b class="caret"></b></a>
  47. <ul id="take_test" class="dropdown-toggle" >
  48. <li><a href="/Code_Ques_set.php">Test Code</a></li>
  49. <li><a href="/enter_pool.php">MCQs</a></li>
  50. <li><a href="/Query_ques_set.php">Test Query</a></li>
  51. </ul>
  52. </li>
  53. <li class="dropdown" id="test-menu">
  54. <a class="dropdown-toggle" data-toggle="" href="#"> New Test <b class="caret"></b></a>
  55. <ul id="take_test" class="dropdown-toggle" >
  56. <li><a href="/make_test.php">Test Code</a></li>
  57. <li><a href="/test_maker.php">MCQs</a></li>
  58. <li><a href="/make_test_sql.php">Test Query</a></li>
  59. </ul>
  60. </li>
  61. </ul>
  62. <ul class="nav pull-right" id="main-menu-right">
  63. <li><a rel="tooltip" href="#"><?php echo date("d.m.Y") ;?> <i class="icon-share-alt"></i></a></li>
  64. <li><a rel="tooltip" href="#">Welcome <?php echo $_SESSION['name']; ?> <i class="icon-share-alt"></i></a></li>
  65. <li><a rel="tooltip" href="/logout_staff.php">Logout <i class="icon-share-alt"></i></a></li>
  66. </ul>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <div class="container">
  72. <div class="container">
  73. <p> </p>
  74. <h1 style="font-size:46px" align="center" >&nbsp;</h1>
  75. <h1 style="font-size:46px" align="center" >&nbsp;</h1>
  76. <h1 style="font-size:46px" align="center" >ACES</h1>
  77. <h4 align="center"> Automated Code Evaluation System</h4>
  78. <p></p>
  79. <h6 align="left">AMRITA SHOOL OF ENGINEERING</h6>
  80. <h6 align="left" >COIMBATORE <small></h6>
  81. <section id="forms">
  82. <div class="page-header">
  83. <h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Insert into question pool</h1>
  84. </div>
  85. <div class="row">
  86. <div class="span10 offset1">
  87. <form class="form-horizontal well" action="enterques.php" method="POST">
  88. <fieldset>
  89. <legend >Feedback :</legend>
  90. <?php
  91. //error_reporting(E_ALL);
  92. //ini_set('display_errors','1');
  93. //session_start();
  94. $ques=explode(',',$_SESSION['ques_pool']);
  95. $op=explode(',',$_SESSION['option_feed']);
  96. $ch=0;
  97. /*for($i=0;$i<count($op);$i++)
  98. {
  99. if(isset($_POST[$op[$i]]))
  100. {
  101. $ch=$op[$i];
  102. array_push($correctans,$ch);
  103. }
  104. }
  105. $cor=implode(',',$correctans);
  106. echo $cor;
  107. $ins= '{'.$cor.'}';
  108. echo $ins;*/
  109. $auth->connect();
  110. $query1 = "INSERT INTO ques_pool(ques_id,ques,max_marks,neg_marks,ans) VALUES ('$ques[0]','$ques[1]','$ques[2]','$ques[3]','$_POST[ans]')";
  111. $query = mysql_query($query1) or die("The question ID you entered is already entered. Please try another question ID. Sorry for the inconvienience. We are trying to fix this.");
  112. //array_push($ques_pool,$_POST['ques_id'],$_POST['ques'],$_POST['max_marks'],$_POST['neg_marks']);
  113. if(!$query) {echo 'error'; exit; }
  114. $a=1;
  115. for($i=0;$i<count($op);$i++)
  116. { $j=$a.$op[$i];
  117. $q=mysql_query("INSERT INTO option_feed(ques_id,option_no,option1) VALUES ('$ques[0]','$op[$i]','$_POST[$j]')");
  118. if(!$q) {echo 'error'; exit; }
  119. }
  120. ?>
  121. <label class="control-groups" > Question added to pool.</label>
  122. <div class="form-actions">
  123. <button type="submit" class="btn btn-primary" formaction="enter_pool.php">Add another question</button>
  124. <button type="submit" class="btn btn-primary" formaction="test_maker.php">Create test</button>
  125. </div>
  126. </fieldset>
  127. </form>
  128. </div>
  129. </div>
  130. </section>
  131. <!-- Footer
  132. ================================================== -->
  133. <hr>
  134. <footer id="footer">
  135. <p class="pull-right"><a href="#">Back to top</a></p>
  136. <div class="links"></div>
  137. Made by <a href="http://www.amrita.edu">Amrita</a>. Contact him <a href="mailto:amrita.edu">hello@admin_asec</a>.<br/>
  138. Based on <a target="_blank" href="http://twitter.github.com/bootstrap/">Bootstrap</a>. Icons from <a target="_blank" href="http://glyphicons.com/">Glyphicons</a>. Web fonts from <a target="_blank" href="http://www.google.com/webfonts">Google</a>.</p>
  139. </footer>
  140. </body>
  141. </html>
  142. <?php
  143. }
  144. }
  145. ?>