Sin descripción

questionnaires.php 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <?php
  2. // Description: DISPLAY THE USER'S QUESTIONNAIRES
  3. echo "This page is no longer in use.";
  4. exit();
  5. exit();
  6. exit();
  7. exit();
  8. exit();
  9. require_once 'processes/config.php';
  10. require_once 'processes/dbh.inc.php';
  11. require_once 'processes/checkLogin.php';
  12. include_once 'header.php';
  13. // WARNING: CHANGE QUERY TO INCLUDE "`id_researcher`='".$dbUserData['id_researcher']."';"
  14. if($_SESSION['dbUserData']['admin'] === '1') {
  15. $query1 = "SELECT * FROM `questionnair`;";
  16. } else {
  17. $query1 = "SELECT * FROM `questionnair` WHERE id IN (SELECT id_questionnair FROM experience_questionnair WHERE id_experience IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "'));";
  18. }
  19. $result1 = mysqli_query($connection, $query1);
  20. ?>
  21. <!-- START OF questionnaires.php -->
  22. <body>
  23. <header id="main-header">
  24. <a id="logo" href=".">
  25. TANIA
  26. <img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
  27. </a>
  28. <div id="account">
  29. <a class="sign-out" href="./processes/logout.php">Sign Out</a>
  30. </div>
  31. </header>
  32. <div class='container' style="margin-top: 8rem; min-height: calc(100vh - 8rem - 10vh);">
  33. <div class='row'>
  34. <div class='col-sm-8'>
  35. <h2>Questionnaires</h2>
  36. <p>View, add, and delete any questionnaire you like so that, later on, you can associate them to an experience.</p>
  37. </div>
  38. <br><br>
  39. <div class='col-sm-4 btn-group'>
  40. <button type='button' class='btn btn-default' data-toggle='modal' data-target='#Import'>Import</button>
  41. <button type='button' class='btn btn-default' data-toggle='modal' data-target='#Duplicate'>Duplicate</button>
  42. <button type='button' class='btn btn-default' data-toggle='modal' data-target='#New' disabled>Create</button>
  43. </div>
  44. </div><!--row-->
  45. <div class='row'><div class='col'><br><hr><br></div></div>
  46. <?php if($result1->num_rows > 0): ?>
  47. <div class='row'>
  48. <div class='col-sm-12'>
  49. <table class='table table-hover table-striped'>
  50. <thead>
  51. <tr>
  52. <th><h4>Title</h4></th>
  53. <th><h4>Description</h4></th>
  54. <th><h4>Corresp. Experience</h4></th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. <?php while($row1 = mysqli_fetch_array($result1)): ?>
  59. <tr style="cursor: pointer;" onclick="location='viewQuestionnaire.php?view=<?php echo $row1['id']; ?>'">
  60. <td><?php echo $row1['q_title']; ?></td>
  61. <td><?php echo $row1['description']; ?></td>
  62. <?php
  63. $queryExperience = "SELECT title FROM experience WHERE id = (SELECT id_experience FROM experience_questionnair WHERE id_questionnair = '" . $row1['id'] . "')";
  64. $resultExperience = mysqli_query($connection, $queryExperience) or die("Error: Couldn't fetch experience info<br>".mysqli_error($connection));
  65. $rowExperience = mysqli_fetch_assoc($resultExperience);
  66. ?>
  67. <td style="width: 14em;"><?php echo $rowExperience['title']; ?></td>
  68. </tr>
  69. <?php endwhile; ?>
  70. </tbody>
  71. </table>
  72. </div><!--col-->
  73. </div><!--row-->
  74. <?php else: ?>
  75. <div class='row'>
  76. <div class='col text-center'>
  77. <h3><small>It seems you still don't have questionnaires...</small></h3>
  78. </div><!--col-->
  79. </div><!--row-->
  80. <?php endif; ?>
  81. <br><br><br>
  82. </div><!--container-->
  83. <!-- POPUP FOR IMPORT QUESTIONNAIRE -->
  84. <form class='form-horizontal' action='processes/importQuestionnaire.php' method='POST' enctype="multipart/form-data">
  85. <div class='modal fade' id='Import' tabindex='-1' role='dialog' aria-labelledby='ImportLabel' aria-hidden='true'>
  86. <div class='modal-dialog modal-dialog-centered modal-md' role='document'>
  87. <div class='modal-content'>
  88. <div class='modal-header'>
  89. <h3 class='modal-title' id='ImportLabel'>Import Questionnaire<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button></h3>
  90. </div>
  91. <div class='modal-body'>
  92. <div class="form-horizontal">
  93. <div class="row">
  94. <div class="col-sm-12">
  95. <h4>Download Template</h4>
  96. <p>Use this template to fill out your questionnaire and we'll do the heavy lifting for you! Once you're done, <strong>submit</strong> it using the button below.</p>
  97. <a class="btn btn-primary btn-sm btn-block" href="nameOfTheQuestionnair.xlsx">Download Template</a>
  98. </div>
  99. </div><!--row-->
  100. <br>
  101. <br>
  102. <div class="form-group">
  103. <div class="col-sm-12 col-sm-offset-2">
  104. <label for="exampleInputFile">Questionnaire in xlsx format</label>
  105. <input type="file" name='import'>
  106. <p class="help-block">Choose your .xlsx file (remember it has to have the correct format).</p>
  107. </div><!--col-->
  108. </div>
  109. </div>
  110. </div><!--modal-body-->
  111. <div class='modal-footer'>
  112. <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
  113. <button type='submit' class='btn btn-primary' name='insertQuestionnaire'>Import</button>
  114. </div>
  115. </div><!--modal-content-->
  116. </div><!--modal-dialog-->
  117. </div><!--modal-->
  118. <!-- POPUP FOR DUPLICATE QUESTIONNAIRE -->
  119. <form class='form-horizontal' action='processes/duplicateQuestionnaire.php' method='POST'>
  120. <div class='modal fade' id='Duplicate' tabindex='-1' role='dialog' aria-labelledby='DuplicateLabel' aria-hidden='true'>
  121. <div class='modal-dialog modal-dialog-centered' role='document'>
  122. <div class='modal-content'>
  123. <div class='modal-header'>
  124. <h3 class='modal-title' id='DuplicateLabel'>Duplicate Questionnaire<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button></h3>
  125. </div>
  126. <div class='modal-body'>
  127. <span class='text-center'>
  128. <h4>Copy a questionnaire from one experience to another</h4>
  129. </span>
  130. <br>
  131. <!-- FROM QUESTIONNAIRE -->
  132. <label for="fromQuestionnaireID">Which Questionnaire:</label>
  133. <select class="form-control text-center" id="fromQuestionnaireID" name="fromQuestionnaireID" style="text-align-last:center;" required>
  134. <?php
  135. $result1 = mysqli_query($connection, $query1);
  136. while($row1 = mysqli_fetch_assoc($result1)):
  137. $queryExtra = "SELECT title FROM `experience` WHERE id = (SELECT id_experience FROM experience_questionnair WHERE id_questionnair = '" . $row1['id'] . "');";
  138. $resultExtra = mysqli_query($connection, $queryExtra);
  139. $rowExtra = mysqli_fetch_assoc($resultExtra);
  140. ?>
  141. <option value="<?php echo $row1['id']; ?>"><?php echo $row1['q_title']; ?> – from <?php echo $rowExtra['title']; ?></option>
  142. <?php endwhile; ?>
  143. </select>
  144. <br>
  145. <!-- TO EXPERIENCE -->
  146. <label for="toExperienceID">To What Experience:</label>
  147. <select class="form-control text-center" id="toExperienceID" name="toExperienceID" style="text-align-last:center;" required>
  148. <?php
  149. // CHANGE QUERY DEPENDING ON IF USER IS ADMIN OR NOT
  150. if($_SESSION['dbUserData']['admin'] === '1') {
  151. $queryExperience2 = "SELECT * FROM `experience` WHERE id != '$experienceID';";
  152. } else {
  153. $queryExperience2 = "SELECT * FROM `experience` WHERE id != '$experienceID' AND id IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "');";
  154. }
  155. $resultExperience2 = mysqli_query($connection, $queryExperience2);
  156. while($rowExperience2 = mysqli_fetch_assoc($resultExperience2)):
  157. ?>
  158. <option value="<?php echo $rowExperience2['id']; ?>"><?php echo $rowExperience2['title']; ?></option>
  159. <?php endwhile; ?>
  160. </select>
  161. </div><!--modal-body-->
  162. <!-- SUBMIT OR CANCEL -->
  163. <div class='modal-footer'>
  164. <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
  165. <button type='submit' class='btn btn-primary' name='duplicateQuestionnaire'>Confirm</button>
  166. </div>
  167. </div><!--modal-content-->
  168. </div><!--modal-dialog-->
  169. </div><!--modal-->
  170. </form>
  171. <!-- END OF questionnaires.php -->
  172. <?php include_once 'footer.php'; ?>