Нет описания

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