Nenhuma descrição

viewQuestionnaire.php 26KB

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