PageRenderTime 53ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/createTEST_sql.php

https://bitbucket.org/krishna2793/aces
PHP | 176 lines | 134 code | 36 blank | 6 comment | 4 complexity | 37c0c5e11ea270ac70acd876c4d75741 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. <!-- Navbar
  34. ================================================== -->
  35. <div class="navbar navbar-fixed-top">
  36. <div class="navbar-inner">
  37. <div class="container">
  38. <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
  39. <span class="icon-bar"></span>
  40. <span class="icon-bar"></span>
  41. <span class="icon-bar"></span>
  42. </a>
  43. <a class="brand" href="http://www.amrita.edu/">AMRITA</a>
  44. <div class="nav-collapse" id="main-menu">
  45. <ul class="drop" id="main-menu-left">
  46. <li><a id="swatch-link" href="/staff_select_test.php" >Scores Mcq</a></li>
  47. <li class="dropdown" id="test-menu">
  48. <a class="dropdown-toggle" data-toggle="" href="#"> Add Question <b class="caret"></b></a>
  49. <ul id="take_test" class="dropdown-toggle" >
  50. <li><a href="/Code_Ques_set.php">Test Code</a></li>
  51. <li><a href="/enter_pool.php">MCQs</a></li>
  52. <li><a href="/Query_ques_set.php">Test Query</a></li>
  53. </ul>
  54. </li>
  55. <li class="dropdown" id="test-menu">
  56. <a class="dropdown-toggle" data-toggle="" href="#"> New Test <b class="caret"></b></a>
  57. <ul id="take_test" class="dropdown-toggle" >
  58. <li><a href="/make_test.php">Test Code</a></li>
  59. <li><a href="/test_maker.php">MCQs</a></li>
  60. <li><a href="/make_test_sql.php">Test Query</a></li>
  61. </ul>
  62. </li>
  63. </ul>
  64. <ul class="nav pull-right" id="main-menu-right">
  65. <li><a rel="tooltip" href="#"><?php echo date("d.m.Y") ;?> <i class="icon-share-alt"></i></a></li>
  66. <li><a rel="tooltip" href="#">Welcome <?php echo $_SESSION['name']; ?> <i class="icon-share-alt"></i></a></li>
  67. <li><a rel="tooltip" href="/logout_staff.php">Logout <i class="icon-share-alt"></i></a></li>
  68. </ul>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="container">
  74. <div class="container">
  75. <p> </p>
  76. <h1 style="font-size:46px" align="center" >&nbsp;</h1>
  77. <h1 style="font-size:46px" align="center" >&nbsp;</h1>
  78. <h1 style="font-size:46px" align="center" >ACES</h1>
  79. <h4 align="center"> Automated Code Evaluation System</h4>
  80. <p></p>
  81. <h6 align="left">AMRITA SHOOL OF ENGINEERING</h6>
  82. <h6 align="left" >COIMBATORE <small></h6>
  83. <!-- Forms
  84. ================================================== -->
  85. <section id="forms">
  86. <div class="page-header">
  87. <h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Test Creation Successful</h1>
  88. </div>
  89. <div class="row">
  90. <div class="span10 offset1">
  91. <form class="form-horizontal well" method="post" action="ans_code.php">
  92. <fieldset>
  93. <div class="control-group">
  94. <label class="control-label" for="textarea"> Tests</label>
  95. <div class="controls">
  96. <p>
  97. <?php
  98. $con = mysql_connect('localhost','root','mysql');
  99. if (!$con)
  100. {
  101. die('Could not connect: ' . mysql_error());
  102. }
  103. mysql_select_db("aces", $con) or die('db con faild');
  104. $see = $_POST['no_pr'];
  105. $pick=mysql_query("select * from problem_pool order by rand() limit $see") or die(mysql_error());
  106. $i=1;
  107. $test_name = $_POST[t_name];
  108. echo '<br>'.$test_name;
  109. mysql_query( "insert into test_pool_sql(test_name,staff_id) values ('$test_name','$_SESSION[user_id]')" ) or die("ERR:".mysql_error());
  110. $curr_test_id=mysql_result(mysql_query("select max(test_id) from test_pool_sql") ,0);
  111. while($info = mysql_fetch_array($pick) )
  112. {
  113. echo "..................";
  114. echo "<br>...".$info['pid']."...<br>";
  115. mysql_query("insert into test_prob_sql values('$curr_test_id','$info[pid]')") or die("ERR::::::".mysql_error());
  116. $i++;
  117. }
  118. ?>
  119. </p>
  120. </div>
  121. </div>
  122. </fieldset>
  123. </form>
  124. </div>
  125. </div>
  126. </section>
  127. <!-- Footer
  128. ================================================== -->
  129. <hr>
  130. <footer id="footer">
  131. <p class="pull-right"><a href="boot.html">Back to top</a></p>
  132. <div class="links"></div>
  133. Made by <a href="http://www.amrita.edu">Amrita</a>. Contact him <a href="mailto:amrita.edu">hello@admin_asec</a>.<br/>
  134. 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>
  135. </footer>
  136. </body>
  137. </html>
  138. <?php }
  139. }
  140. ?>