Нема описа

questionnaires.php 8.0KB

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