Ei kuvausta

viewQuestionnaire.php 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. <?php
  2. // Description: EXTRACT QUESTIONNAIRE ID, AND IF VALID, DISPLAY ITS INFO
  3. require_once 'processes/config.php';
  4. require_once 'processes/dbh.inc.php';
  5. require_once 'processes/checkLogin.php';
  6. // IF VIEW VARIABLE NOT GIVEN, EXIT
  7. if(!isset($_GET['view'])) {
  8. exit();
  9. }
  10. // WARNING: CHANGE QUERY TO INCLUDE "`id_researcher` = '".$dbUserData['id_researcher']."';"
  11. $questionnaireID = mysqli_real_escape_string($connection, trim($_GET['view']));
  12. $query1 = "SELECT * FROM questionnair WHERE id = '$questionnaireID';";
  13. $result1 = mysqli_query($connection, $query1) or die("Error: ".mysqli_error($connection));
  14. $row1 = mysqli_fetch_array($result1);
  15. // IF QUESTIONNAIRE NOT IN DATABASE, EXIT
  16. if($result1->num_rows !== 1) {
  17. exit();
  18. }
  19. // EXTRACT & DISPLAY THE NUMBER OF QUESTIONS IN THE QUESTIONNAIRE
  20. $queryNumQuestions = "SELECT * FROM question WHERE id IN (SELECT id_question FROM questionnair_question WHERE id_questionnair = '$questionnaireID');";
  21. $resultNumQuestions = mysqli_query($connection, $queryNumQuestions);
  22. $numQuestions = $resultNumQuestions->num_rows;
  23. include_once 'header.php';
  24. ?>
  25. <!-- START OF viewQuestionnaire.php -->
  26. <body>
  27. <header id="main-header">
  28. <a id="logo" href=".">
  29. TANIA
  30. <img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
  31. </a>
  32. <div id="account">
  33. <a class="nav-link" href="./questionnaires.php">Questionnaire Collection</a>
  34. <a class="sign-out" href="./processes/logout.php">Sign Out</a>
  35. </div>
  36. </header>
  37. <div class="container" style="margin-top: 8rem; min-height: calc(100vh - 8rem - 10vh);">
  38. <div class="row">
  39. <div class="col-sm-8">
  40. <h2>Questionnaire</h2>
  41. <p><font size="4"><b> Title: </b> <?php echo $row1['q_title']; ?></font></p>
  42. <p><font size="4"><b> Description: </b> <?php echo $row1['description']; ?></font></p>
  43. <p><font size="4"><b> Amount of Questions: </b> <?php echo $numQuestions; ?></font></p>
  44. </div>
  45. <div class="col-sm-4">
  46. <div class="hidden-xs">
  47. <br><br><br>
  48. </div>
  49. <div id="view-experience-buttons" style="max-width: 18rem;">
  50. <div data-toggle="tooltip" data-placement="top" title="Create Question" id="experience-pen" onclick="nextModal('#AddQuestion')">
  51. <span class="fas fa-plus"></span>
  52. </div>
  53. <div data-toggle="tooltip" data-placement="top" title="Edit Questionnaire" id="experience-pen" onclick="nextModal('#Edit')">
  54. <span class="fas fa-pen"></span>
  55. </div>
  56. </div>
  57. </div>
  58. </div><!--row-->
  59. <br>
  60. <div class="row">
  61. <div class="col-sm-12">
  62. <?php if($numQuestions > 0): ?>
  63. <table class="table table-hover table-striped" id="tableEvaluations">
  64. <thead>
  65. <tr>
  66. <th><h4>#</h4></th>
  67. <th><h4>Question</h4></th>
  68. </tr>
  69. </thead>
  70. <tbody>
  71. <?php
  72. $query2 = "SELECT * FROM question WHERE id IN (SELECT id_question FROM questionnair_question WHERE id_questionnair = '$questionnaireID');";
  73. $result2 = mysqli_query($connection, $query2);
  74. $x = 1;
  75. while($row2 = mysqli_fetch_array($result2)):
  76. $queryMinText = "SELECT value FROM question_type WHERE label = 'min_texto' AND id_question = '" . $row2['id'] . "';";
  77. $resultMinText = mysqli_query($connection, $queryMinText);
  78. $rowMinText = mysqli_fetch_array($resultMinText);
  79. $queryMaxVal = "SELECT value FROM question_type WHERE label = 'max_val' AND id_question = '" . $row2['id'] . "';";
  80. $resultMaxVal = mysqli_query($connection, $queryMaxVal);
  81. $rowMaxVal = mysqli_fetch_array($resultMaxVal);
  82. $queryMaxText = "SELECT value FROM question_type WHERE label = 'max_texto' AND id_question = '" . $row2['id']. "';";
  83. $resultMaxText = mysqli_query($connection, $queryMaxText);
  84. $rowMaxText = mysqli_fetch_array($resultMaxText);
  85. ?>
  86. <tr style="cursor: pointer;" data-toggle="modal" data-target="#EditQuestion" data-question-number="<?php echo $x; ?>" data-questionnaire-id="<?php echo $questionnaireID; ?>" data-question-id="<?php echo $row2['id']; ?>" data-premise="<?php echo $row2['premise']; ?>" data-type="<?php echo $row2['id_type']; ?>" data-min_text="<?php echo $rowMinText['value']; ?>" data-max_val="<?php echo $rowMaxVal['value']; ?>" data-max_text="<?php echo $rowMaxText['value']; ?>" data-categoryid="<?php echo $row2['id_category']; ?>" data-subcategoryid="<?php echo $row2['id_subcategory']; ?>">
  87. <th><?php echo $x; ?></th>
  88. <td><p><?php echo $row2['premise']; ?></p></td>
  89. <!-- <td><button class='btn btn-danger btn-sm' data-toggle='modal' data-target='#Delete' data-questionnaire-id="<?php echo $questionnaireID; ?>" data-question-id="<?php echo $row2['id']; ?>" data-premise="<?php echo $row2['premise']; ?>">Delete</button></td> -->
  90. <!--<a class='btn btn-danger btn-sm' href='confirmDeleteQuestionQuestionnaire.php?del=<?php echo $row2['id']; ?>&quest=$id_questionnaire'>Delete</a>-->
  91. </tr>
  92. <?php $x++; endwhile; ?>
  93. </tbody>
  94. </table>
  95. <?php else: ?>
  96. <h3 class="text-center"><small>It seems you haven't added any questions to this questionnaire...</small></h3>
  97. <?php endif; ?>
  98. </div><!--col-->
  99. </div><!--row-->
  100. <br>
  101. <div class="row">
  102. <div class="col-sm-2 col-sm-offset-5">
  103. <div data-toggle="tooltip" data-placement="top" title="Create Question" id="experience-pen" onclick="nextModal('#AddQuestion')" style="padding: 0.5em; margin: 0 auto; width: 60px;">
  104. <span class="fas fa-plus"></span>
  105. </div>
  106. </div>
  107. </div>
  108. <br><br>
  109. </div><!--container-->
  110. <!-- POPUP FOR NEW QUESTION -->
  111. <form id="newQuestion">
  112. <div class='modal fade' id='AddQuestion' tabindex='-1' role='dialog' aria-labelledby='AddQuestionLabel' aria-hidden='true'>
  113. <div class='modal-dialog modal-lg' role='document'>
  114. <div class='modal-content'>
  115. <div class='modal-body'>
  116. <!-- CLOSE BUTTON -->
  117. <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
  118. <div class='row'>
  119. <div class='col-sm-10'>
  120. <h3>Add New Question</h3>
  121. </div>
  122. </div><!--row-->
  123. <hr>
  124. <!-- QUESTION -->
  125. <div id="q">
  126. <div class="row">
  127. <div class="col-sm-12 col-sm-offset-1">
  128. <h4>New Question</h4>
  129. </div>
  130. </div>
  131. <!-- QUESTIONNAIRE ID -->
  132. <input type="hidden" name="questionnaireID" value="<?php echo $questionnaireID; ?>">
  133. <div class="form-horizontal">
  134. <!-- PREMISE -->
  135. <div class="form-group">
  136. <label class='col-sm-offset-1 control-label col-sm-2'>Premise:</label>
  137. <div class='col-sm-8'>
  138. <input id="q_premise" type="text" class="form-control text-center" name="q_premise" placeholder="Premise" required>
  139. </div>
  140. </div>
  141. <!-- TYPE -->
  142. <div class="form-group">
  143. <label class='col-sm-offset-1 control-label col-sm-2'>Question Type:</label>
  144. <div class='col-sm-8'>
  145. <select class="form-control text-center" id="q_type" name="q_type" style="width:100%; text-align-last:center;" onchange="newThing(event)" required>
  146. <!-- <option disabled selected value="">Type</option> -->
  147. <option value="1">Scaled</option>
  148. <option value="2">Open Answer</option>
  149. </select>
  150. </div>
  151. </div>
  152. </div>
  153. <!-- MIN/MAX VALUES/TEXT (OPTIONAL) -->
  154. <div class="range">
  155. <div class="form-inline col col-sm-offset-2">
  156. <div class="form-group">
  157. <label class='control-label col-sm-2'>Min. Value:</label>
  158. <div class="col-sm-8">
  159. <input type="number" class="form-control text-center" id="min_val" name="min_val" value="1" readonly>
  160. </div>
  161. </div>
  162. <div class="form-group">
  163. <label class='control-label col-sm-2'>Min. Text:</label>
  164. <div class="col-sm-8">
  165. <input type="text" class="form-control text-center" id="min_text" name="min_text" placeholder="Very Dissatisfied">
  166. </div>
  167. </div>
  168. </div>
  169. <div class="form-inline col col-sm-offset-2">
  170. <div class="form-group">
  171. <label class='control-label col-sm-2'>Max. Value:</label>
  172. <div class="col-sm-1">
  173. <input type="number" class="form-control text-center" id="max_val" name="max_val" value="5" min="2">
  174. </div>
  175. </div>
  176. <div class="form-group">
  177. <label class='control-label col-sm-2'>Max. Text:</label>
  178. <div class="col-sm-1">
  179. <input type="text" class="form-control text-center" id="max_text" name="max_text" placeholder="Very Satisfied">
  180. </div>
  181. </div>
  182. </div>
  183. <br>
  184. </div>
  185. <div class="form-horizontal">
  186. <!-- CORRESPONDING CATEGORY -->
  187. <div class="form-group">
  188. <label class='col-sm-offset-1 control-label col-sm-2'>Category:</label>
  189. <div class='col-sm-8'>
  190. <select class="form-control text-center" id="q_category" name="q_category" style="width: 100%; text-align-last:center;" required>
  191. <!-- <option disabled selected value="">Category</option> -->
  192. <?php
  193. $queryCategories = "SELECT * FROM category WHERE id IN (SELECT id_category FROM question WHERE id IN (SELECT id_question FROM questionnair_question WHERE id_questionnair = '$questionnaireID'));";
  194. $resultCategories = mysqli_query($connection, $queryCategories);
  195. while($rowCategories = mysqli_fetch_array($resultCategories)):
  196. ?>
  197. <option value="<?php echo $rowCategories['id']; ?>"><?php echo $rowCategories['categoria']; ?></option>
  198. <?php endwhile; ?>
  199. </select>
  200. </div>
  201. </div>
  202. <!-- CORRESPONDING SUBCATEGORY -->
  203. <div class="form-group">
  204. <label class='col-sm-offset-1 control-label col-sm-2'>Subcategory:</label>
  205. <div class='col-sm-8'>
  206. <select class="form-control text-center" id="q_subcategory" name="q_subcategory" style="width: 100%; text-align-last:center;" required>
  207. <!-- <option disabled selected value="">Subcategory</option> -->
  208. <?php
  209. $querySubcategories = "SELECT * FROM subcategory WHERE id IN (SELECT id_subcategory FROM question WHERE id IN (SELECT id_question FROM questionnair_question WHERE id_questionnair = '$questionnaireID'));";
  210. $resultSubcategories = mysqli_query($connection, $querySubcategories);
  211. while($rowSubcategories = mysqli_fetch_array($resultSubcategories)):
  212. ?>
  213. <option value="<?php echo $rowSubcategories['id']; ?>"><?php echo $rowSubcategories['subcategoria']; ?></option>
  214. <?php endwhile; ?>
  215. </select>
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. <br>
  221. <!-- ERROR ALERT FOR USER -->
  222. <div id="error-newQuestion" class="row" style="display: none;">
  223. <div class="col-sm-12">
  224. <div class="alert alert-danger mb-1" role="alert">
  225. <h4 class="error-lead">Error!</h4>
  226. <p class="error-description"></p>
  227. </div>
  228. </div>
  229. </div>
  230. </div><!--modal-body-->
  231. <!-- SUBMIT OR PREVIOUS -->
  232. <div class='modal-footer'>
  233. <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
  234. <button type="submit" class='btn btn-primary' name='insertQuestionToQuestionnaire'>Add</button>
  235. </div>
  236. </div><!--modal-content-->
  237. </div><!--modal-dialog-->
  238. </div><!--modal-->
  239. </form>
  240. <!-- POPUP FOR EDIT QUESTIONNAIRE -->
  241. <form id="updateQuestionnaire" class="form-horizontal">
  242. <div class='modal fade' id='Edit' tabindex='-1' role='dialog' aria-labelledby='EditLabel' aria-hidden='true'>
  243. <div class='modal-dialog' role='document'>
  244. <div class='modal-content'>
  245. <div class='modal-header'>
  246. <h3 class='modal-title' id='EditLabel'>Edit Questionnaire<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button></h3>
  247. </div>
  248. <div class='modal-body'>
  249. <!-- QUESTIONNAIRE ID -->
  250. <input type='hidden' name='questionnaireID' value='<?php echo $questionnaireID; ?>'>
  251. <!-- TITLE -->
  252. <br>
  253. <div class='form-group'>
  254. <label class='col-sm-offset-1 control-label col-sm-2' for='newTitle'>Title:</label>
  255. <div class='col-sm-7'>
  256. <input type='text' class='form-control text-center' id='newTitle' name='newTitle' value='<?php echo $row1['q_title']; ?>'>
  257. </div>
  258. </div>
  259. <!-- DESCRIPTION -->
  260. <div class='form-group'>
  261. <label class='col-sm-offset-1 control-label col-sm-2' for='newDescription'>Description:</label>
  262. <div class='col-sm-7'>
  263. <textarea class='form-control text-center' id='newDescription' name='newDescription' rows='3' style='resize:vertical;'><?php echo $row1['description']; ?></textarea>
  264. </div>
  265. </div>
  266. <br>
  267. <!-- ERROR ALERT FOR USER -->
  268. <div id="error-updateQuestionnaire" class="row" style="display: none;">
  269. <div class="col-sm-12">
  270. <div class="alert alert-danger mb-1" role="alert">
  271. <h4 class="error-lead">Error!</h4>
  272. <p class="error-description"></p>
  273. </div>
  274. </div>
  275. </div>
  276. </div><!--modal-body-->
  277. <!-- SUBMIT OR CANCEL -->
  278. <div class='modal-footer'>
  279. <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
  280. <button type='button' class='btn btn-danger' data-dismiss='modal' onclick="nextModal('#DeleteQuestionnaire')">Delete</button>
  281. <button type='submit' class='btn btn-primary' name='updateQuestionnaire'>Save Changes</button>
  282. </div>
  283. </div><!--modal-content-->
  284. </div><!--modal-dialog-->
  285. </div><!--modal-->
  286. </form>
  287. <!-- POPUP FOR DELETE QUESTIONNAIRE -->
  288. <form id="deleteQuestionnaire">
  289. <div class='modal fade' id='DeleteQuestionnaire' tabindex='-1' role='dialog' aria-labelledby='DeleteQuestionnaireLabel' aria-hidden='true'>
  290. <div class='modal-dialog modal-dialog-centered' role='document'>
  291. <div class='modal-content'>
  292. <div class='modal-header'>
  293. <h3 class='modal-title' id='DeleteQuestionnaireLabel'>Delete Question<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button></h3>
  294. </div>
  295. <div class='modal-body'>
  296. <!-- QUESTIONNAIRE ID -->
  297. <input type='hidden' name='questionnaireID' value="<?php echo $questionnaireID; ?>">
  298. <span class='text-center'>
  299. <h3>Are you sure you want to delete this Questionnaire?</h3>
  300. <!-- <h3 id="deletePremise" style='color:#ff8f00;'></h3> -->
  301. </span>
  302. <br>
  303. <p class='alert alert-warning text-justify'>This action will delete the questionnaire and all of its questions and moments. If you have any problems, contact technical support at: <a class='alert-link' href='#'>support@tania.uprrp.edu</a>.</p>
  304. <br>
  305. <!--You should be aware of this and opt to edit manually any affected moments and experiences in the following pages: <a class='alert-link' href='#'>experience</a>.-->
  306. <!-- ERROR ALERT FOR USER -->
  307. <div id="error-deleteQuestionnaire" class="row" style="display: none;">
  308. <div class="col-sm-12">
  309. <div class="alert alert-danger mb-1" role="alert">
  310. <h4 class="error-lead">Error!</h4>
  311. <p class="error-description"></p>
  312. </div>
  313. </div>
  314. </div>
  315. </div><!--modal-body-->
  316. <!-- SUBMIT OR CANCEL -->
  317. <div class='modal-footer'>
  318. <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
  319. <button type='submit' class='btn btn-danger' name='deleteQuestionnaire'>Delete Anyway</button>
  320. </div>
  321. </div><!--modal-content-->
  322. </div><!--modal-dialog-->
  323. </div><!--modal-->
  324. </form>
  325. <!-- POPUP FOR EDIT QUESTION FROM QUESTIONNAIRE -->
  326. <form id="updateQuestion">
  327. <div class='modal fade' id='EditQuestion' tabindex='-1' role='dialog' aria-labelledby='EditQuestionLabel' aria-hidden='true'>
  328. <div class='modal-dialog modal-lg' role='document'>
  329. <div class='modal-content'>
  330. <div class='modal-header'>
  331. <h3 class='modal-title' id='EditQuestionLabel'>Edit Question<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button></h3>
  332. </div>
  333. <div class='modal-body'>
  334. <!-- QUESTIONNAIRE ID -->
  335. <!-- <input type='hidden' name='questionnaireID'> -->
  336. <!-- QUESTION ID -->
  337. <input type='hidden' name='questionID'>
  338. <br>
  339. <div class="row">
  340. <div class="col-sm-12 col-sm-offset-1">
  341. <h4>Question <span class="question-number"></span></h4>
  342. </div>
  343. </div>
  344. <div class="form-horizontal">
  345. <!-- PREMISE -->
  346. <div class="form-group">
  347. <label class='col-sm-offset-1 control-label col-sm-2'>Premise:</label>
  348. <div class='col-sm-8'>
  349. <input id="update_q_premise" type="text" class="form-control text-center" name="update_q_premise" placeholder="Premise" maxlength="600" required>
  350. </div>
  351. </div>
  352. <!-- TYPE -->
  353. <div class="form-group">
  354. <label class='col-sm-offset-1 control-label col-sm-2'>Question Type:</label>
  355. <div class='col-sm-8'>
  356. <select class="form-control text-center" id="update_q_type" name="update_q_type" style="width:100%; text-align-last:center;" onchange="newThing(event)" required>
  357. <!-- <option disabled selected value="">Type</option> -->
  358. <option value="1">Scaled</option>
  359. <option value="2">Open Answer</option>
  360. </select>
  361. </div>
  362. </div>
  363. </div>
  364. <!-- MIN/MAX VALUES/TEXT (OPTIONAL) -->
  365. <div class="range">
  366. <div class="form-inline col col-sm-offset-2">
  367. <div class="form-group">
  368. <label class='control-label col-sm-2'>Min. Value:</label>
  369. <div class="col-sm-8">
  370. <input type="number" class="form-control text-center" id="update_min_val" name="update_min_val" value="1" readonly>
  371. </div>
  372. </div>
  373. <div class="form-group">
  374. <label class='control-label col-sm-2'>Min. Text:</label>
  375. <div class="col-sm-8">
  376. <input type="text" class="form-control text-center" id="update_min_text" name="update_min_text" maxlength="40" placeholder="Very Dissatisfied">
  377. </div>
  378. </div>
  379. </div>
  380. <div class="form-inline col col-sm-offset-2">
  381. <div class="form-group">
  382. <label class='control-label col-sm-2'>Max. Value:</label>
  383. <div class="col-sm-1">
  384. <input type="number" class="form-control text-center" id="update_max_val" name="update_max_val" value="5" min="2">
  385. </div>
  386. </div>
  387. <div class="form-group">
  388. <label class='control-label col-sm-2'>Max. Text:</label>
  389. <div class="col-sm-1">
  390. <input type="text" class="form-control text-center" id="update_max_text" name="update_max_text" maxlength="40" placeholder="Very Satisfied">
  391. </div>
  392. </div>
  393. </div>
  394. <br>
  395. </div>
  396. <div class="form-horizontal">
  397. <!-- CORRESPONDING CATEGORY -->
  398. <div class="form-group">
  399. <label class='col-sm-offset-1 control-label col-sm-2'>Category:</label>
  400. <div class='col-sm-8'>
  401. <select class="form-control text-center" id="update_q_category" name="update_q_category" style="width: 100%; text-align-last:center;" required>
  402. <!-- <option disabled selected value="">Category</option> -->
  403. <?php
  404. $queryCategories = "SELECT * FROM category WHERE id IN (SELECT id_category FROM question WHERE id IN (SELECT id_question FROM questionnair_question WHERE id_questionnair = '$questionnaireID'));";
  405. $resultCategories = mysqli_query($connection, $queryCategories);
  406. while($rowCategories = mysqli_fetch_array($resultCategories)):
  407. ?>
  408. <option value="<?php echo $rowCategories['id']; ?>"><?php echo $rowCategories['categoria']; ?></option>
  409. <?php endwhile; ?>
  410. </select>
  411. </div>
  412. </div>
  413. <!-- CORRESPONDING SUBCATEGORY -->
  414. <div class="form-group">
  415. <label class='col-sm-offset-1 control-label col-sm-2'>Subcategory:</label>
  416. <div class='col-sm-8'>
  417. <select class="form-control text-center" id="update_q_subcategory" name="update_q_subcategory" style="width: 100%; text-align-last:center;" required>
  418. <!-- <option disabled selected value="">Subcategory</option> -->
  419. <?php
  420. $querySubcategories = "SELECT * FROM subcategory WHERE id IN (SELECT id_subcategory FROM question WHERE id IN (SELECT id_question FROM questionnair_question WHERE id_questionnair = '$questionnaireID'));";
  421. $resultSubcategories = mysqli_query($connection, $querySubcategories);
  422. while($rowSubcategories = mysqli_fetch_array($resultSubcategories)):
  423. ?>
  424. <option value="<?php echo $rowSubcategories['id']; ?>"><?php echo $rowSubcategories['subcategoria']; ?></option>
  425. <?php endwhile; ?>
  426. </select>
  427. </div>
  428. </div>
  429. </div>
  430. <br>
  431. <!-- ERROR ALERT FOR USER -->
  432. <div id="error-updateQuestion" class="row" style="display: none;">
  433. <div class="col-sm-12">
  434. <div class="alert alert-danger mb-1" role="alert">
  435. <h4 class="error-lead">Error!</h4>
  436. <p class="error-description"></p>
  437. </div>
  438. </div>
  439. </div>
  440. </div><!--modal-body-->
  441. <!-- SUBMIT OR CANCEL -->
  442. <div class='modal-footer'>
  443. <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
  444. <button type='button' class='btn btn-danger' data-dismiss='modal' onclick="nextModal('#Delete')">Delete</button>
  445. <button type='submit' class='btn btn-primary' name='updateQuestion'>Save Changes</button>
  446. </div>
  447. </div><!--modal-content-->
  448. </div><!--modal-dialog-->
  449. </div><!--modal-->
  450. </form>
  451. <!-- POPUP FOR DELETE QUESTION FROM QUESTIONNAIRE -->
  452. <form id="deleteQuestion" class='form-horizontal'>
  453. <div class='modal fade' id='Delete' tabindex='-1' role='dialog' aria-labelledby='DeleteLabel' aria-hidden='true'>
  454. <div class='modal-dialog modal-dialog-centered' role='document'>
  455. <div class='modal-content'>
  456. <div class='modal-header'>
  457. <h3 class='modal-title' id='DeleteLabel'>Delete Question<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button></h3>
  458. </div>
  459. <div class='modal-body'>
  460. <!-- QUESTION ID -->
  461. <input type='hidden' name='questionID'>
  462. <span class='text-center'>
  463. <h3>Are you sure you want to delete Question <span class="question-number"></span>?</h3>
  464. <!-- <h3 id="deletePremise" style='color:#ff8f00;'></h3> -->
  465. </span>
  466. <br>
  467. <p class='alert alert-warning text-justify'>This action will delete the question from this questionnaire (and from its moments). If you have any problems, contact technical support at: <a class='alert-link' href='#'>support@tania.uprrp.edu</a>.</p>
  468. <br>
  469. <!--You should be aware of this and opt to edit manually any affected moments and experiences in the following pages: <a class='alert-link' href='#'>experience</a>.-->
  470. <!-- ERROR ALERT FOR USER -->
  471. <div id="error-deleteQuestion" class="row" style="display: none;">
  472. <div class="col-sm-12">
  473. <div class="alert alert-danger mb-1" role="alert">
  474. <h4 class="error-lead">Error!</h4>
  475. <p class="error-description"></p>
  476. </div>
  477. </div>
  478. </div>
  479. </div><!--modal-body-->
  480. <!-- SUBMIT OR CANCEL -->
  481. <div class='modal-footer'>
  482. <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
  483. <button type='submit' class='btn btn-danger' name='deleteQuestion'>Delete Anyway</button>
  484. </div>
  485. </div><!--modal-content-->
  486. </div><!--modal-dialog-->
  487. </div><!--modal-->
  488. </form>
  489. <script src="js/viewQuestionnaire.js"></script>
  490. <script src="js/handleSubmit.js"></script>
  491. <script src="js/editQuestion.js"></script>
  492. <script>
  493. ["updateQuestionnaire", "newQuestion", "updateQuestion", "deleteQuestionnaire", "deleteQuestion"].forEach(function(formName) {
  494. var form = document.getElementById(formName);
  495. if(form) {
  496. form.addEventListener('submit', function(e) {
  497. handleSubmit(e, formName);
  498. });
  499. }
  500. });
  501. </script>
  502. <!-- END OF viewQuestionnaire.php -->
  503. <?php include_once 'footer.php'; ?>