Geen omschrijving

respuestas.php 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. require_once 'processes/config.php';
  3. require_once 'processes/dbh.inc.php';
  4. require_once 'processes/checkLogin.php';
  5. include_once 'header.php';
  6. //include("conection.php");
  7. include("funciones.php");
  8. //SELECT a.id_question, q.premise, a.id_subquestionnair , q.id_category,q.id_subcategory FROM `answer` a, question q WHERE a.`id_student` = 1860 and a.id_question=q.id ORDER BY `a`.`id_question` ASC
  9. $id_experiencia = mysqli_real_escape_string($connection, trim($_GET['exp']));
  10. //$id_student = 1860;
  11. ///////Busca cantidad de sub cuestionarios - Empieza////////////////
  12. $sqlSelect = sprintf("SELECT count(*) FROM experience_questionnair eq, subquestionnair qs where eq.id_questionnair=qs.id_questionnair and eq.id_experience = %s",
  13. GetSQLValueString($id_experiencia, "int")
  14. );
  15. $dbresultSel = mysqli_query($connection, $sqlSelect);
  16. $row = mysqli_fetch_array($dbresultSel);
  17. $cant_sub_subquestionnair = $row[0];
  18. //print($cant_sub_subquestionnair);
  19. ///////Termina - Busca cantidad de sub cuestionarios - ////////////////
  20. ///////Busca Preguntas - Empieza////////////////
  21. $sqlSelect = sprintf("SELECT distinct q.* FROM `experience_questionnair` eq, questionnair_question qq, question q WHERE eq.id_questionnair=qq.`id_questionnair` and qq.id_question=q.id and id_experience = %s order by q.id",
  22. GetSQLValueString($id_experiencia, "int")
  23. );
  24. $dbresultSel = mysqli_query($connection, $sqlSelect);
  25. $resultados = array();
  26. $j = 1;
  27. while($row = mysqli_fetch_array($dbresultSel)) {
  28. //$preguntas[] = array($i, $row['premise']);
  29. $emas = array();
  30. $emas[] = $j;
  31. $emas[] = $row['premise'];
  32. $emas[] = " "; // PRE test
  33. // SUBQUESTIONNAIRES
  34. for($i = 1; $i <= $cant_sub_subquestionnair-2; $i++) {
  35. $emas[] = " ";
  36. }
  37. $emas[] = " "; // POST test
  38. $emas[] = " "; // Average
  39. $emas[] = " "; // Standard Deviation
  40. $emas[] = " "; // Percent Change between EMA and PRE
  41. $emas[] = " "; // Percent Change between POST and EMA
  42. $emas[] = " "; // Percent Change between POST and PRE
  43. $resultados[] = $emas;
  44. $j++;
  45. }
  46. ///////Termina - Busca Preguntas - ////////////////
  47. ///////Busca Estudiantes - Empieza////////////////
  48. $sqlSelectEst = sprintf("SELECT s.id id_stu FROM student s, student_participate_experience se WHERE s.id=se.id_student and se.id_experience = %s order by id_stu",
  49. GetSQLValueString($id_experiencia, "int")
  50. );
  51. $dbresultEst = mysqli_query($connection,$sqlSelectEst);
  52. ///////Termina - Busca Estudiantes - ////////////////
  53. ?>
  54. <!--START OF respuestas.php-->
  55. <body>
  56. <header id="main-header">
  57. <a id="logo" href=".">
  58. TANIA
  59. <img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
  60. </a>
  61. <div id="account">
  62. <a class="sign-out" href="./processes/logout.php">Sign Out</a>
  63. </div>
  64. </header>
  65. <?php if($id_experiencia == 1): ?>
  66. <div class="container" style="margin-top: 12vh;"><div class="row"><div class="col"><h4>Warning: Este script no funciona para esta experiencia en particular (la parte de escoger los resultados por cada estudiante).</h4></div></div></div>
  67. <?php endif; ?>
  68. <div class="container" style="margin-top: 12vh;">
  69. <div class="row">
  70. <div class="col">
  71. <table class="table table-bordered">
  72. <thead>
  73. <tr>
  74. <th scope="col" style="vertical-align: middle; text-align: center;" rowspan="2" style="width:30px">#</th>
  75. <th scope="col">
  76. <form>
  77. <select class="form-control" id="id_student" style="text-align-last: center;">
  78. <option disabled selected>Select Student</option>
  79. <option selected value="all">All Students</option>
  80. <?php while($rowEst = mysqli_fetch_array($dbresultEst)): ?>
  81. <option value='<?php echo $rowEst['id_stu']; ?>'><?php echo $rowEst['id_stu']; ?></option>
  82. <?php endwhile; ?>
  83. </select>
  84. <input type="hidden" value="<?php echo $id_experiencia;?>" id="id_experiencia">
  85. </form>
  86. </th>
  87. <th scope="col" rowspan="2" style="width:30px; vertical-align: middle; text-align: center;">Pre</th>
  88. <th colspan="<?php echo $cant_sub_subquestionnair - 2;?>" style="vertical-align: middle; text-align: center;">Moments</th>
  89. <th scope="col" rowspan="2" style="width:30px; vertical-align: middle; text-align: center;">Post</th>
  90. <th scope="col" rowspan="2" style="width:30px; vertical-align: middle; text-align: center;">x&#772</th>
  91. <th scope="col" rowspan="2" style="width:30px; vertical-align: middle; text-align: center;">&sigma;</th>
  92. <th scope="col" rowspan="2" style="width:30px; vertical-align: middle; text-align: center;">% &Delta;<br><small>Ema - Pre</small></th>
  93. <th scope="col" rowspan="2" style="width:30px; vertical-align: middle; text-align: center;">% &Delta;<br><small>Post - Ema</small></th>
  94. <th scope="col" rowspan="2" style="width:30px; vertical-align: middle; text-align: center;">% &Delta;<br><small>Post - Pre</small></th>
  95. </tr>
  96. <tr>
  97. <th>
  98. <form>
  99. <select class="form-control" id="tipo_resumen" style="text-align-last: center;">
  100. <option value="0" selected>Questions</option>
  101. <option value="1">Subcategories</option>
  102. <option value="2">Categories</option>
  103. </select>
  104. <input type="hidden" value="<?php echo $id_experiencia;?>" id="id_experiencia">
  105. </form>
  106. </th>
  107. <?php for($i = 1; $i <= $cant_sub_subquestionnair-2; $i++): ?>
  108. <th scope="col" style="width:30px vertical-align: middle; text-align: center;""><?php echo $i; ?></th>
  109. <?php endfor; ?>
  110. </tr>
  111. </thead>
  112. <tbody id="loqueseve">
  113. <?php foreach($resultados as $pregunta): ?>
  114. <tr>
  115. <?php foreach($pregunta as $item): ?>
  116. <td style="vertical-align: middle; text-align: center;"><?php echo $item ?></td>
  117. <?php endforeach; ?>
  118. </tr>
  119. <?php endforeach; ?>
  120. </tbody>
  121. </table>
  122. </div><!--col-->
  123. </div><!--row-->
  124. <div class="row">
  125. <div class="col">
  126. <form id="exportForm" method="POST" action="processes/export.php">
  127. <input type="hidden" name="id_student" value="all">
  128. <input type="hidden" name="id_exp" value="<?php echo $id_experiencia; ?>">
  129. <input type="hidden" name="res_type" value="0">
  130. <button type="submit" name="export" class="btn btn-info">Export</button>
  131. </form>
  132. </div><!--col-->
  133. </div><!--row-->
  134. </div><!--container-->
  135. <script>
  136. window.onload = function() {
  137. $("#tipo_resumen").change(function() {
  138. let inputs = document.querySelector('#exportForm').children;
  139. inputs[2].value = $("#tipo_resumen").val();
  140. $.post("respuestasData.php",
  141. {
  142. id_student: $("#id_student").val(),
  143. id_exp: $("#id_experiencia").val(),
  144. res_type: $("#tipo_resumen").val()
  145. },
  146. function(data, status) {
  147. $("#loqueseve").html(data);
  148. }
  149. );
  150. });
  151. $("#id_student").change(function() {
  152. let inputs = document.querySelector('#exportForm').children;
  153. inputs[0].value = $("#id_student").val();
  154. $.post("respuestasData.php",
  155. {
  156. id_student: $("#id_student").val(),
  157. id_exp: $("#id_experiencia").val(),
  158. res_type: $("#tipo_resumen").val()
  159. },
  160. function(data, status) {
  161. $("#loqueseve").html(data);
  162. }
  163. );
  164. });
  165. }
  166. </script>
  167. </body>
  168. </html>