No Description

viewExperience.php 50KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448
  1. <?php
  2. // Description: EXTRACT EXPERIENCE 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. $experienceID = mysqli_real_escape_string($connection, trim($_GET['view']));
  12. $query1 = "SELECT * FROM `experience` WHERE `id` = '$experienceID';";
  13. $result1 = mysqli_query($connection, $query1) or die("Error: ".mysqli_error($connection));
  14. $row1 = mysqli_fetch_array($result1);
  15. // IF EXPERIENCE NOT IN DATABASE, EXIT
  16. if($result1->num_rows !== 1) {
  17. exit();
  18. }
  19. include_once 'header.php';
  20. ?>
  21. <!--START OF viewExperience.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="nav-link" href="./questionnaires.php">Questionnaire Collection</a>
  30. <a class="sign-out" href="./processes/logout.php">Sign Out</a>
  31. </div>
  32. </header>
  33. <div class="container-fluid" id="view-experience-showcase">
  34. <div class="row">
  35. <div class="col-sm-12">
  36. <h2><?php echo $row1['title']; ?></h2>
  37. <div class="row">
  38. <div class="col-sm-7 col-md-8 col-lg-9">
  39. <blockquote style="color:rgb(216,216,216); margin: 0;">
  40. <h4><b style="color:#fff;">Description:</b> <span style="color:rgb(216,216,216);"><?php echo $row1['description']; ?></span></h4>
  41. <h4><b style="color:#fff;">Type:</b> <span style="color:rgb(216,216,216);"><?php echo $row1['type']; ?></span></h4>
  42. <h4><b style="color:#fff;">Duration:</b> <span style="color:rgb(216,216,216);"><?php echo $row1['duration_weeks']; ?> week<?php if((int)$row1['duration_weeks'] > 1) echo "s"; ?></span></h4>
  43. </blockquote>
  44. </div><!--col-->
  45. <div class="col-sm-5 col-md-4 col-lg-3">
  46. <div id="view-experience-buttons">
  47. <div data-toggle="tooltip" data-placement="top" title="View Results" id="experience-pen" onclick="window.location='respuestas.php?exp=<?php echo $experienceID; ?>'">
  48. <span class="fas fa-poll-h"></span>
  49. </div>
  50. <div data-toggle="tooltip" data-placement="top" title="Edit Experience" id="experience-pen" onclick="nextModal('#Edit')">
  51. <span class="fas fa-pen"></span>
  52. </div>
  53. <div data-toggle="tooltip" data-placement="top" title="Share Experience" id="experience-pen" onclick="prompt('Press Ctrl + C to copy to clipboard!','https://tania.uprrp.edu/enrollInExp.php?id=<?php echo $row1['hash_id']; ?>')">
  54. <span class="fas fa-link"></span>
  55. </div>
  56. </div>
  57. </div><!--col-->
  58. </div><!--row-->
  59. <br>
  60. <div class="row hidden-xs" id="view-experience-tabs">
  61. <a class="active" href="#calendar">Calendar</a>
  62. <a href="#questionnaires">Questionnaires</a>
  63. <a href="#moments">Moments</a>
  64. <a href="#milestones">Milestones</a>
  65. </div><!--row-->
  66. </div><!--col-->
  67. </div><!--row-->
  68. </div><!--container-->
  69. <br>
  70. <!-- CALENDAR-->
  71. <div id="calendar" class="main-content-box show hidden-xs">
  72. <div class="container">
  73. <div class="row">
  74. <h3 class="col-sm-12">Schedule Your Experience</h3>
  75. </div><!--row-->
  76. <br>
  77. <div class="row">
  78. <div class="col-sm-12">
  79. <div id="actualCalendar"></div>
  80. </div>
  81. </div>
  82. <br><br><br><br>
  83. </div><!--container-->
  84. </div>
  85. <!--QUESTIONNAIRES-->
  86. <div id="questionnaires" class="main-content-box">
  87. <div class="container">
  88. <div class="row">
  89. <h3 class="col-xs-7 col-sm-9 col-md-9">Active Questionnaires</h3>
  90. <div class="col-xs-5 col-sm-3 col-md-3">
  91. <!--
  92. <span data-toggle="modal" data-target="#Import" style="margin-right: 1em;">
  93. <button type="button" class="btn btn-lg btn-default" data-toggle="tooltip" data-placement="top" title="Import Questionnaire">
  94. <span class="glyphicon glyphicon-open-file"></span>
  95. </button>
  96. </span>
  97. <span data-toggle="modal" data-target="#Duplicate">
  98. <button type="button" class="btn btn-lg btn-default" data-toggle="tooltip" data-placement="top" title="Duplicate Questionnaire">
  99. <span class="glyphicon glyphicon-paste"></span>
  100. </button>
  101. </span>
  102. -->
  103. <div id="view-experience-buttons">
  104. <div data-toggle="tooltip" data-placement="top" title="Import Questionnaire" id="experience-pen" onclick="nextModal('#Import')" style="padding: 0.5em; margin: 0 auto; width: 60px;">
  105. <span class="fas fa-file-import"></span>
  106. </div>
  107. <div data-toggle="tooltip" data-placement="top" title="Duplicate Questionnaire" id="experience-pen" onclick="nextModal('#Duplicate')" style="padding: 0.5em; margin: 0 auto; width: 60px;">
  108. <span class="fas fa-copy"></span>
  109. </div>
  110. </div>
  111. </div>
  112. </div><!--row-->
  113. <br>
  114. <div class="row">
  115. <div class="col-sm-12">
  116. <?php
  117. $query2 = "SELECT * FROM questionnair WHERE `id` IN (SELECT `id_questionnair` FROM experience_questionnair WHERE `id_experience` = '$experienceID');";
  118. $result2 = mysqli_query($connection, $query2);
  119. // IF THE EXPERIENCE HAS AT LEAST ONE QUESTIONNAIRE ASSOCIATED TO IT, SHOW IT
  120. // ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
  121. if(mysqli_num_rows($result2) > 0):
  122. ?>
  123. <table class="table table-hover table-striped table-responsive">
  124. <thead>
  125. <tr>
  126. <th style="text-align: center;"><h4>Questionnaire</h4></th>
  127. <th style="text-align: center;"><h4>Questions</h4></th>
  128. </tr>
  129. </thead>
  130. <tbody>
  131. <?php while($row2 = mysqli_fetch_assoc($result2)): ?>
  132. <tr style="cursor: pointer;" onclick="location='viewQuestionnaire.php?view=<?php echo $row2['id']?>'">
  133. <td style="text-align: center;"><h5><?php echo $row2['q_title']; ?></h5></td>
  134. <?php
  135. $query3 = "SELECT * FROM questionnair_question WHERE id_questionnair = ".$row2['id'];
  136. $result3 = mysqli_query($connection, $query3);
  137. ?>
  138. <td style="text-align: center;"><h5><?php echo mysqli_num_rows($result3); ?></h5></td>
  139. </tr>
  140. <?php endwhile; ?>
  141. </tbody>
  142. </table>
  143. <?php else: ?>
  144. <h3 class="text-center"><small>It seems you still haven't added a questionnaire to this experience...</small></h3>
  145. <?php endif; ?>
  146. <br>
  147. <div class="row">
  148. <div class="col-sm-2 col-sm-offset-5">
  149. <div data-toggle="tooltip" data-placement="top" title="Create Questionnaire" onclick="nextModal('#NewQuestionnaire')" id="experience-pen" style="padding: 0.5em; margin: 0 auto; width: 60px;">
  150. <span class="fas fa-plus"></span>
  151. </div>
  152. </div>
  153. </div>
  154. </div><!--col-sm-12-->
  155. </div><!--row-->
  156. <br><br>
  157. <div class="row">
  158. <div class="col-sm-offset-2 col-sm-8">
  159. <div class="alert alert-warning alert-dismisible mb-1 hidden-xs" role="alert">
  160. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  161. <span aria-hidden="true">&times;</span>
  162. </button>
  163. <h4>Tips on Questionnaires</h4>
  164. <hr>
  165. <ul>
  166. <li>These are the questionnaires that are associated to this experience.</li>
  167. <br>
  168. <li>Once you have your questionnaire, you can create your moments.</li>
  169. <br>
  170. <li>You can create new questionnaires with the plus button...
  171. <ul>
  172. <li>or import questionnaires from an Excel file!</li>
  173. <li>or copy a questionnaire from one experience to another!</li>
  174. </ul>
  175. </li>
  176. <br>
  177. </ul>
  178. </div><!--alert-->
  179. </div><!--col-sm-8-->
  180. </div><!--row-->
  181. <br>
  182. </div><!--container-->
  183. </div>
  184. <!--MOMENTS-->
  185. <div id="moments" class="main-content-box">
  186. <div class="container">
  187. <div class="row">
  188. <h3 class="col-sm-12">Active Moments</h3>
  189. </div>
  190. <div class="row">
  191. <div class="col-sm-12">
  192. <?php
  193. $query4 = "SELECT * FROM subquestionnair WHERE `id_questionnair` IN (SELECT `id_questionnair` FROM experience_questionnair WHERE `id_experience` = '$experienceID') ORDER BY date_to_administer ASC;";
  194. $result4 = mysqli_query($connection, $query4);
  195. // IF THE EXPERIENCE HAS AT LEAST ONE MOMENT ASSOCIATED TO IT, SHOW IT
  196. // ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
  197. if(mysqli_num_rows($result4) > 0):
  198. ?>
  199. <table class="table table-hover table-striped table-responsive">
  200. <thead>
  201. <tr>
  202. <th style="text-align: center;"><h4>Moment</h4></th>
  203. <th style="text-align: center;"><h4>Questions</h4></th>
  204. <th style="text-align: center;"><h4>Date</h4></th>
  205. </tr>
  206. </thead>
  207. <tbody>
  208. <?php while($row4 = mysqli_fetch_assoc($result4)): ?>
  209. <tr style="cursor: pointer;" onclick="location='viewMoment.php?view=<?php echo $row4['id']?>'">
  210. <td style="text-align: center;"><h5><?php echo $row4['title']; ?></h5></td>
  211. <?php
  212. $query5 = "SELECT * FROM subquestionnair_question WHERE `id_subquestionnair` = ".$row4['id'];
  213. $result5 = mysqli_query($connection, $query5);
  214. ?>
  215. <td style="text-align: center;"><h5><?php echo mysqli_num_rows($result5); ?></h5></td>
  216. <td style="text-align: center;"><h5><?php echo date("M j, Y (g:i A)", strtotime($row4['date_to_administer'])); ?></h5></td>
  217. </tr>
  218. <?php endwhile; ?>
  219. </tbody>
  220. </table>
  221. <?php else: ?>
  222. <h3 class="text-center"><small>It seems you still haven't added any moments to this experience...</small></h3>
  223. <?php endif; ?>
  224. <br>
  225. <div class="row">
  226. <div class="col-sm-2 col-sm-offset-5">
  227. <div data-toggle="tooltip" data-placement="top" title="Create Moment" onclick="nextModal('#NewMoment')" id="experience-pen" style="padding: 0.5em; margin: 0 auto; width: 60px;">
  228. <span class="fas fa-plus"></span>
  229. </div>
  230. </div>
  231. </div>
  232. </div><!--col-sm-12-->
  233. </div><!--row-->
  234. <br><br>
  235. <div class="row">
  236. <div class="col-sm-offset-2 col-sm-8">
  237. <div class="alert alert-warning alert-dismisible mb-1 hidden-xs" role="alert">
  238. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  239. <span aria-hidden="true">&times;</span>
  240. </button>
  241. <h4>Tips on Moments</h4>
  242. <hr>
  243. <ul>
  244. <li>These are the moments that are associated to this experience.</li>
  245. <br>
  246. <li>Once they're answered, you can track the results with the results button above.</li>
  247. <br>
  248. <li>You can create new moments with the plus button.</li>
  249. <br>
  250. </ul>
  251. </div><!--alert-->
  252. </div><!--col-sm-8-->
  253. </div><!--row-->
  254. <br>
  255. </div><!--container-->
  256. </div>
  257. <!--MILESTONES-->
  258. <div id="milestones" class="main-content-box">
  259. <div class="container">
  260. <div class="row">
  261. <h3 class="col-sm-12">Active Milestones</h3>
  262. </div>
  263. <div class="row">
  264. <div class="col-sm-12">
  265. <?php
  266. $query6 = "SELECT * FROM `milestone` WHERE `id_experience` = '$experienceID' ORDER BY date ASC;";
  267. $result6 = mysqli_query($connection, $query6);
  268. // IF THE EXPERIENCE HAS AT LEAST ONE MILESTONE ASSOCIATED TO IT, SHOW IT
  269. // ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
  270. if(mysqli_num_rows($result6) > 0):
  271. ?>
  272. <table class="table table-hover table-striped table-responsive">
  273. <thead>
  274. <tr>
  275. <th style="text-align: center;"><h4>Milestone</h4></th>
  276. <th style="text-align: center;"><h4>Date</h4></th>
  277. </tr>
  278. </thead>
  279. <tbody>
  280. <?php while($row6 = mysqli_fetch_assoc($result6)): ?>
  281. <tr style="cursor: pointer;">
  282. <td style="text-align: center;"><h5><?php echo $row6['title']; ?></h5></td>
  283. <td style="text-align: center;"><h5><?php echo date("M j, Y", strtotime($row6['date'])); ?></h5></td>
  284. </tr>
  285. <?php endwhile; ?>
  286. </tbody>
  287. </table>
  288. <?php else: ?>
  289. <h3 class="text-center"><small>It seems you still haven't added any milestones to this experience...</small></h3>
  290. <?php endif; ?>
  291. <br>
  292. <div class="row">
  293. <div class="col-sm-2 col-sm-offset-5">
  294. <div data-toggle="tooltip" data-placement="top" title="Create Milestone" onclick="nextModal('#NewMilestone')" id="experience-pen" style="padding: 0.5em; margin: 0 auto; width: 60px;">
  295. <span class="fas fa-plus"></span>
  296. </div>
  297. </div>
  298. </div>
  299. </div><!--col-sm-12-->
  300. </div><!--row-->
  301. <br><br>
  302. <div class="row">
  303. <div class="col-sm-offset-2 col-sm-8">
  304. <div class="alert alert-warning alert-dismisible mb-1 hidden-xs" role="alert">
  305. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  306. <span aria-hidden="true">&times;</span>
  307. </button>
  308. <h4>Tips on Milestones</h4>
  309. <hr>
  310. <ul>
  311. <li>These are the milestones of the students involved in this experience.</li>
  312. <br>
  313. <li>Once your moments are answered you can track the impact the milestones had on the answers, if any.</li>
  314. <br>
  315. <li>You can create new milestones with the plus button.</li>
  316. <br>
  317. </ul>
  318. </div><!--alert-->
  319. </div><!--col-sm-8-->
  320. </div><!--row-->
  321. <br>
  322. </div><!--container-->
  323. </div>
  324. <br><br><br><br><br>
  325. <!-- POPUP FOR EDIT EXPERIENCE -->
  326. <form id="editForm"><!--method='POST' action='processes/updateExperience.php'-->
  327. <div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="EditLabel" aria-hidden="true">
  328. <div class="modal-dialog" role="document">
  329. <div class="modal-content">
  330. <div class="modal-body">
  331. <!-- CLOSE BUTTON -->
  332. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  333. <span aria-hidden="true">&times;</span>
  334. </button>
  335. <div class="row">
  336. <div class="col-sm-10">
  337. <h2>Edit Experience <small>(Basic Info)</small></h2>
  338. </div>
  339. </div><!--row-->
  340. <hr><br>
  341. <div class="form-horizontal">
  342. <!-- ID -->
  343. <input type="hidden" name="id" value="<?php echo $row1['id']; ?>">
  344. <!-- NEW TITLE -->
  345. <div class="form-group">
  346. <label class="control-label col-sm-2 col-sm-offset-1">Title:</label>
  347. <div class="col-sm-7">
  348. <input type="text" class="form-control text-center" name="newTitle" maxlength="60" value="<?php echo $row1['title']; ?>" required>
  349. </div>
  350. </div>
  351. <!-- NEW DESCRIPTION -->
  352. <div class="form-group">
  353. <label class="control-label col-sm-2 col-sm-offset-1">Description:</label>
  354. <div class="col-sm-7">
  355. <textarea class="form-control text-center" name="newDescription" rows="4" style="resize: vertical;" maxlength="100" required><?php echo $row1['description']; ?></textarea>
  356. </div>
  357. </div>
  358. <!--
  359. <!~~ NEW TYPE ~~>
  360. <div class='form-group'>
  361. <label class='control-label col-sm-2 col-sm-offset-1'>Type:</label>
  362. <div class='col-sm-7'>
  363. <input type='text' class='form-control text-center' name='newType' required value="<?php echo $row1['type']; ?>">
  364. </div>
  365. </div>
  366. <!~~ NEW DURATION ~~>
  367. <div class='form-group'>
  368. <label class='control-label col-sm-2 col-sm-offset-1'>Duration:</label>
  369. <div class='col-sm-7'>
  370. <input type='number' class='form-control text-center' name='newDuration' required value="<?php echo $row1['duration_weeks']; ?>" readonly>
  371. </div>
  372. </div>
  373. <!~~ NEW START DATE ~~>
  374. <div class='form-group'>
  375. <label class='control-label col-sm-2 col-sm-offset-1'>Start Date:</label>
  376. <div class='col-sm-7'>
  377. <input type='date' class='form-control text-center' name='newStart' required value="<?php echo $row1['start_date']; ?>">
  378. </div>
  379. </div>
  380. <!~~ NEW END DATE ~~>
  381. <div class='form-group'>
  382. <label class='control-label col-sm-2 col-sm-offset-1'>End Date:</label>
  383. <div class='col-sm-7'>
  384. <input type='date' class='form-control text-center' name='newEnd' required value="<?php echo $row1['end_date']; ?>">
  385. </div>
  386. </div>
  387. -->
  388. </div><!--form-horizontal-->
  389. <!-- ERROR ALERT FOR USER -->
  390. <div id="error-editForm" class="row" style="display: none;">
  391. <div class="col-sm-12">
  392. <div class="alert alert-danger mb-1" role="alert">
  393. <h4 class="error-lead">Error!</h4>
  394. <p class="error-description"></p>
  395. </div>
  396. </div>
  397. </div>
  398. </div><!--modal-body-->
  399. <!-- SUBMIT OR CANCEL -->
  400. <div class="modal-footer">
  401. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  402. <button type="submit" class="btn btn-primary" name="updateExperience" disabled>Save Changes</button>
  403. </div>
  404. </div><!--modal-content-->
  405. </div><!--modal-dialog-->
  406. </div><!--modal-->
  407. </form><!--form-->
  408. <!--FORM VALIDATION FOR EDIT EXPERIENCE-->
  409. <script>
  410. let newTitle = document.querySelector('[name=newTitle]');
  411. let newDescription = document.querySelector('[name=newDescription]');
  412. // let newType = document.querySelector('[name=newType]');
  413. newTitle.addEventListener('keyup', validateEditExperience);
  414. newTitle.addEventListener('change', validateEditExperience);
  415. newDescription.addEventListener('keyup', validateEditExperience);
  416. newDescription.addEventListener('change', validateEditExperience);
  417. // newType.addEventListener('keyup', validateEditExperience);
  418. // newType.addEventListener('change', validateEditExperience);
  419. // Only enable submit button when:
  420. // 1) changes are detected,
  421. // 2) and both strings (title and description) are not empty
  422. function validateEditExperience() {
  423. let updateExperience = document.querySelector('[name=updateExperience]');
  424. updateExperience.disabled = !newTitle.checkValidity() || !newDescription.checkValidity();
  425. }
  426. </script>
  427. <!-- POPUP FOR NEW QUESTIONNAIRE 1 -->
  428. <div class="modal fade" id="NewQuestionnaire" tabindex="-1" role="dialog" aria-labelledby="NewQuestionnaireLabel" aria-hidden="true">
  429. <div class="modal-dialog modal-lg" role="document">
  430. <div class="modal-content">
  431. <div class="modal-body">
  432. <!-- CLOSE BUTTON -->
  433. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  434. <span aria-hidden='true'>&times;</span>
  435. </button>
  436. <div class="row">
  437. <div class="col-sm-10">
  438. <h2>New Questionnaire <small>(Basic Info – <em>Part 1</em>)</small></h2>
  439. </div>
  440. </div><!--row-->
  441. <hr><br>
  442. <div class="form-horizontal">
  443. <!-- TITLE -->
  444. <div class="form-group">
  445. <label class="control-label col-sm-2">Title:</label>
  446. <div class="col-sm-9">
  447. <input type="text" class="form-control text-center" name="q_title_tentative" placeholder="Title" maxlength="100" required>
  448. </div>
  449. </div>
  450. <!-- DESCRIPTION -->
  451. <div class="form-group">
  452. <label class="control-label col-sm-2">Description:</label>
  453. <div class="col-sm-9">
  454. <textarea class="form-control text-center" name="description_tentative" rows="1" placeholder="Description" maxlength="200" required></textarea>
  455. </div>
  456. </div>
  457. <!-- REFERENCE -->
  458. <div class="form-group">
  459. <label class="control-label col-sm-2">Reference:</label>
  460. <div class="col-sm-9">
  461. <input type="text" class="form-control text-center" name="referencia_tentative" placeholder="Reference" maxlength="60" required>
  462. </div>
  463. </div>
  464. <br>
  465. <!-- CATEGORIES -->
  466. <div class="form-group">
  467. <label class="control-label col-sm-2">Categories:</label>
  468. <div class="col-sm-9">
  469. <textarea id="q_categories_tentative" class="form-control text-center" name="q_categories_tentative" rows="1" placeholder="Categories (comma separated)" required></textarea>
  470. </div>
  471. </div>
  472. <!-- SUBCATEGORIES -->
  473. <div class="form-group">
  474. <label class="control-label col-sm-2">Subcategories:</label>
  475. <div class="col-sm-9">
  476. <textarea id="q_subcategories_tentative" class="form-control text-center" name="q_subcategories_tentative" rows="1" placeholder="Subcategories (comma separated)" required></textarea>
  477. </div>
  478. </div>
  479. </div>
  480. <div class="row">
  481. <div class="col col-sm-offset-2 col-sm-9">
  482. <p class="alert alert-warning text-justify">
  483. <strong>Note:</strong> You should at least have the same number of subcategories as categories.
  484. </p>
  485. </div>
  486. </div>
  487. </div><!--modal-body-->
  488. <!-- NEXT OR CANCEL -->
  489. <div class="modal-footer">
  490. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  491. <button id="nextQuestionnaire" type="button" class='btn btn-primary' data-dismiss="modal" onclick="nextModal('#NewQuestionnaire_2')" disabled>Next</button>
  492. </div>
  493. </div><!--modal-content-->
  494. </div><!--modal-dialog-->
  495. </div><!--modal-->
  496. <!-- FORM VALIDATION FOR NEW QUESTIONNAIRE (BASIC INFO) -->
  497. <script>
  498. // Fetch the inputs in the first modal
  499. let questionnaireTitle = document.querySelector('[name=q_title_tentative]');
  500. let questionnaireDescription = document.querySelector('[name=description_tentative]');
  501. let questionnaireReference = document.querySelector('[name=referencia_tentative]');
  502. let categories = document.querySelector('[name=q_categories_tentative]');
  503. let subcategories = document.querySelector('[name=q_subcategories_tentative]');
  504. // Add onchange and onkeyup event listeners to each input in the first modal
  505. questionnaireTitle.addEventListener('keyup', validateNewQuestionnaire);
  506. questionnaireTitle.addEventListener('change', validateNewQuestionnaire);
  507. questionnaireDescription.addEventListener('keyup', validateNewQuestionnaire);
  508. questionnaireDescription.addEventListener('change', validateNewQuestionnaire);
  509. questionnaireReference.addEventListener('keyup', validateNewQuestionnaire);
  510. questionnaireReference.addEventListener('change', validateNewQuestionnaire);
  511. categories.addEventListener('keyup', validateNewQuestionnaire);
  512. categories.addEventListener('change', validateNewQuestionnaire);
  513. subcategories.addEventListener('keyup', validateNewQuestionnaire);
  514. subcategories.addEventListener('change', validateNewQuestionnaire);
  515. // Pass the values from the first modal to the second, where the actual (hidden) inputs reside
  516. questionnaireTitle.addEventListener('keyup', function() {
  517. document.querySelector('[name=q_title]').value = questionnaireTitle.value;
  518. });
  519. questionnaireDescription.addEventListener('keyup', function() {
  520. document.querySelector('[name=description]').value = questionnaireDescription.value;
  521. });
  522. questionnaireReference.addEventListener('keyup', function() {
  523. document.querySelector('[name=referencia]').value = questionnaireReference.value;
  524. });
  525. categories.addEventListener('keyup', function() {
  526. document.querySelector('[name=q_categories]').value = categories.value;
  527. });
  528. subcategories.addEventListener('keyup', function() {
  529. document.querySelector('[name=q_subcategories]').value = subcategories.value;
  530. });
  531. // First modal's validation function
  532. // This basically enables the "Next" button if certain conditions are met
  533. function validateNewQuestionnaire() {
  534. // Fetch "Next" button in modal
  535. let nextButton = document.querySelector('#nextQuestionnaire');
  536. // Check validity of each input (valid if not empty strings)
  537. let validity = questionnaireTitle.checkValidity();
  538. validity &= questionnaireDescription.checkValidity();
  539. validity &= questionnaireReference.checkValidity();
  540. validity &= categories.checkValidity();
  541. validity &= subcategories.checkValidity();
  542. // Questionnaire should have at least the same number of subcategories as categories
  543. let rawCategories = categories.value.split(',');
  544. let rawSubcategories = subcategories.value.split(',');
  545. let categoriesArray = new Array();
  546. let subcategoriesArray = new Array();
  547. // IF clause is necessary to avoid array WARNINGS and ERRORS
  548. if(categories.value != '' && subcategories.value != '') {
  549. // Store the "trimmed" categories in categoriesArray
  550. for(let i = 0; i < rawCategories.length; i++) {
  551. rawCategories[i] = rawCategories[i].trim();
  552. // if string not empty and not whitespace, insert as category option
  553. if(/\S/.test(rawCategories[i])) {
  554. categoriesArray.push(rawCategories[i]);
  555. }
  556. }
  557. // Store the "trimmed" subcategories in subcategoriesArray
  558. for(let i = 0; i < rawSubcategories.length; i++) {
  559. rawSubcategories[i] = rawSubcategories[i].trim();
  560. // if string not empty and not whitespace, insert as subcategory option
  561. if(/\S/.test(rawSubcategories[i])) {
  562. subcategoriesArray.push(rawSubcategories[i]);
  563. }
  564. }
  565. // Only valid if there are less or equal number of categories to subcategories
  566. validity &= categoriesArray.length <= subcategoriesArray.length;
  567. }
  568. // Disabled if not valid, enabled otherwise
  569. nextButton.disabled = !validity;
  570. }
  571. </script>
  572. <form id="newQuestionnaire"><!--method="POST" action="processes/insertQuestionnaire.php"-->
  573. <!-- POPUP FOR NEW QUESTIONNAIRE 2 -->
  574. <div class="modal fade" id="NewQuestionnaire_2" tabindex="-1" role="dialog" aria-labelledby="NewQuestionnaireLabel_2" aria-hidden="true">
  575. <div class="modal-dialog modal-lg" role="document">
  576. <div class="modal-content">
  577. <div class="modal-body">
  578. <!-- CLOSE BUTTON -->
  579. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  580. <span aria-hidden="true">&times;</span>
  581. </button>
  582. <div class="row">
  583. <div class="col-sm-10">
  584. <h2>New Questionnaire <small>(Questions – <em>Part 2</em>)</small></h2>
  585. </div>
  586. </div><!--row-->
  587. <hr>
  588. <!-- EXPERIENCE ID -->
  589. <input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>">
  590. <!-- QUESTIONNAIRE TITLE -->
  591. <input type="hidden" name="q_title" maxlength="100" required>
  592. <!-- QUESTIONNAIRE DESCRIPTION --->
  593. <input type="hidden" name="description" maxlength="200" required>
  594. <!-- QUESTIONNAIRE REFERENCE -->
  595. <input type="hidden" name="referencia" maxlength="60" required>
  596. <!-- QUESTIONNAIRE CATEGORIES -->
  597. <input id="q_categories" type="hidden" name="q_categories" required>
  598. <!-- QUESTIONNAIRE SUBCATEGORIES -->
  599. <input id="q_subcategories" type="hidden" name="q_subcategories" required>
  600. <!-- QUESTION -->
  601. <div id="q1">
  602. <div class="row">
  603. <div class="col col-sm-offset-1">
  604. <h4>Question 1</h4>
  605. </div>
  606. </div>
  607. <div class="form-horizontal">
  608. <!-- PREMISE -->
  609. <div class="form-group">
  610. <label class="col-sm-offset-1 control-label col-sm-2">Premise:</label>
  611. <div class="col-sm-8">
  612. <input id="q_premise1" type="text" class="form-control text-center" name="q_premise1" placeholder="Premise" maxlength="600" required>
  613. </div>
  614. </div>
  615. <!-- TYPE -->
  616. <div class="form-group">
  617. <label class="col-sm-offset-1 control-label col-sm-2">Question Type:</label>
  618. <div class="col-sm-8">
  619. <select class="form-control text-center" id="q_type1" name="q_type1" style="width:100%; text-align-last:center;" onchange="newThing(event)" required>
  620. <!-- <option disabled selected value="">Type</option> -->
  621. <option value="1">Scaled</option>
  622. <option value="2">Open Answer</option>
  623. </select>
  624. </div>
  625. </div>
  626. </div>
  627. <!-- MIN/MAX VALUES/TEXT (OPTIONAL) -->
  628. <div id="range1">
  629. <div class="form-inline col col-sm-offset-2">
  630. <div class="form-group">
  631. <label class="control-label col-sm-2">Min. Value:</label>
  632. <div class="col-sm-8">
  633. <input type="number" class="form-control text-center" id="min_val1" name="min_val1" value="1" readonly>
  634. </div>
  635. </div>
  636. <div class="form-group">
  637. <label class="control-label col-sm-2">Min. Text:</label>
  638. <div class="col-sm-8">
  639. <input type="text" class="form-control text-center" id="min_text1" name="min_text1" maxlength="40" placeholder="Very Dissatisfied">
  640. </div>
  641. </div>
  642. </div>
  643. <div class="form-inline col col-sm-offset-2">
  644. <div class="form-group">
  645. <label class="control-label col-sm-2">Max. Value:</label>
  646. <div class="col-sm-1">
  647. <input type="number" class="form-control text-center" id="max_val1" name="max_val1" value="5" min="2">
  648. </div>
  649. </div>
  650. <div class="form-group">
  651. <label class="control-label col-sm-2">Max. Text:</label>
  652. <div class="col-sm-1">
  653. <input type="text" class="form-control text-center" id="max_text1" name="max_text1" maxlength="40" placeholder="Very Satisfied">
  654. </div>
  655. </div>
  656. </div>
  657. <br>
  658. </div>
  659. <div class="form-horizontal">
  660. <!-- CORRESPONDING CATEGORY -->
  661. <div class="form-group">
  662. <label class="col-sm-offset-1 control-label col-sm-2">Category:</label>
  663. <div class="col-sm-8">
  664. <select class="form-control text-center" id="q_category1" name="q_category1" style="width: 100%; text-align-last:center;" required>
  665. <!-- <option disabled selected value="">Category</option> -->
  666. </select>
  667. </div>
  668. </div>
  669. <!-- CORRESPONDING SUBCATEGORY -->
  670. <div class="form-group">
  671. <label class="col-sm-offset-1 control-label col-sm-2">Subcategory:</label>
  672. <div class="col-sm-8">
  673. <select class="form-control text-center" id="q_subcategory1" name="q_subcategory1" style="width: 100%; text-align-last:center;" required>
  674. <!-- <option disabled selected value="">Subcategory</option> -->
  675. </select>
  676. </div>
  677. </div>
  678. </div>
  679. </div>
  680. <br>
  681. <div class="row">
  682. <div class="col-sm-offset-9 col-sm-2">
  683. <button type="button" class="btn btn-xs btn-default" onclick="addQuestion()">Add Question</button>
  684. </div>
  685. </div>
  686. <!-- ERROR ALERT FOR USER -->
  687. <div id="error-newQuestionnaire" class="row" style="display: none;">
  688. <div class="col-sm-12">
  689. <div class="alert alert-danger mb-1" role="alert">
  690. <h4 class="error-lead">Error!</h4>
  691. <p class="error-description"></p>
  692. </div>
  693. </div>
  694. </div>
  695. </div><!--modal-body-->
  696. <!-- SUBMIT OR PREVIOUS -->
  697. <div class="modal-footer">
  698. <button type="button" class="btn btn-default" data-dismiss="modal" onclick="nextModal('#NewQuestionnaire')">Previous</button>
  699. <button type="submit" class="btn btn-primary" name="createQuestionnaire">Create</button>
  700. </div>
  701. </div><!--modal-content-->
  702. </div><!--modal-dialog-->
  703. </div><!--modal-->
  704. </form>
  705. <!-- POPUP FOR IMPORT QUESTIONNAIRE -->
  706. <form class='form-horizontal' action='processes/importQuestionnaire.php' method='POST' enctype="multipart/form-data">
  707. <div class='modal fade' id='Import' tabindex='-1' role='dialog' aria-labelledby='ImportLabel' aria-hidden='true'>
  708. <div class='modal-dialog modal-dialog-centered modal-md' role='document'>
  709. <div class='modal-content'>
  710. <div class='modal-header'>
  711. <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>
  712. </div>
  713. <div class='modal-body'>
  714. <div class="form-horizontal">
  715. <input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>">
  716. <div class="row">
  717. <div class="col-sm-12">
  718. <h4>Download Template</h4>
  719. <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 "<em>import</em>" button below.</p>
  720. <a class="btn btn-primary btn-sm btn-block" href="nameOfTheQuestionnair.xlsx">Download Template</a>
  721. </div>
  722. </div><!--row-->
  723. <br>
  724. <br>
  725. <div class="form-group">
  726. <div class="col-sm-10 col-sm-offset-2">
  727. <label for="exampleInputFile">Questionnaire in xlsx format</label>
  728. <input type="file" name='import'>
  729. <p class="help-block">Choose your .xlsx file (remember it has to have the correct format).</p>
  730. </div>
  731. </div><!--form-group-->
  732. </div>
  733. </div><!--modal-body-->
  734. <div class='modal-footer'>
  735. <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
  736. <button type='submit' class='btn btn-primary' name='insertQuestionnaire'>Import</button>
  737. </div>
  738. </div><!--modal-content-->
  739. </div><!--modal-dialog-->
  740. </div><!--modal-->
  741. <!-- POPUP FOR DUPLICATE QUESTIONNAIRE -->
  742. <form class='form-horizontal' action='processes/duplicateQuestionnaire.php' method='POST'>
  743. <div class='modal fade' id='Duplicate' tabindex='-1' role='dialog' aria-labelledby='DuplicateLabel' aria-hidden='true'>
  744. <div class='modal-dialog modal-dialog-centered' role='document'>
  745. <div class='modal-content'>
  746. <div class='modal-header'>
  747. <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>
  748. </div>
  749. <div class='modal-body'>
  750. <span class='text-center'>
  751. <h4>Copy a questionnaire from one experience to another</h4>
  752. </span>
  753. <br>
  754. <!-- FROM QUESTIONNAIRE -->
  755. <label for="fromQuestionnaireID">Which Questionnaire:</label>
  756. <select class="form-control text-center" id="fromQuestionnaireID" name="fromQuestionnaireID" style="text-align-last:center;" required>
  757. <?php
  758. $queryQuestionnaires = "SELECT * FROM `questionnair` WHERE id IN (SELECT id_questionnair FROM experience_questionnair WHERE id_experience = '$experienceID');";
  759. $resultQuestionnaires = mysqli_query($connection, $queryQuestionnaires);
  760. while($rowQuestionnaires = mysqli_fetch_assoc($resultQuestionnaires)):
  761. ?>
  762. <option value="<?php echo $rowQuestionnaires['id']; ?>"><?php echo $rowQuestionnaires['q_title']; ?></option>
  763. <?php endwhile; ?>
  764. </select>
  765. <br>
  766. <!-- TO EXPERIENCE -->
  767. <label for="toExperienceID">To What Experience:</label>
  768. <select class="form-control text-center" id="toExperienceID" name="toExperienceID" style="text-align-last:center;" required>
  769. <?php
  770. // WARNING: CHANGE QUERY TO INCLUDE "`id_researcher`='".$dbUserData['id_researcher']."';"
  771. $queryExperience2 = "SELECT * FROM `experience` WHERE id != '$experienceID';";
  772. $resultExperience2 = mysqli_query($connection, $queryExperience2);
  773. while($rowExperience2 = mysqli_fetch_assoc($resultExperience2)):
  774. ?>
  775. <option value="<?php echo $rowExperience2['id']; ?>"><?php echo $rowExperience2['title']; ?></option>
  776. <?php endwhile; ?>
  777. </select>
  778. </div><!--modal-body-->
  779. <!-- SUBMIT OR CANCEL -->
  780. <div class='modal-footer'>
  781. <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
  782. <button type='submit' class='btn btn-primary' name='duplicateQuestionnaire'>Confirm</button>
  783. </div>
  784. </div><!--modal-content-->
  785. </div><!--modal-dialog-->
  786. </div><!--modal-->
  787. </form>
  788. <!-- POPUP FOR NEW MOMENT 1 -->
  789. <form id="newMoment"><!--method='POST' action='processes/insertMoment.php'-->
  790. <div class="modal fade" id="NewMoment" tabindex="-1" role="dialog" aria-labelledby="NewMomentLabel" aria-hidden="true">
  791. <div class="modal-dialog modal-lg" role="document">
  792. <div class="modal-content">
  793. <div class="modal-body">
  794. <!-- CLOSE BUTTON -->
  795. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  796. <span aria-hidden='true'>&times;</span>
  797. </button>
  798. <div class="row">
  799. <div class="col-sm-10">
  800. <h2>New Moment <small>(Basic Info – <em>Part 1</em>)</small></h2>
  801. </div>
  802. </div><!--row-->
  803. <hr><br>
  804. <div class="form-horizontal">
  805. <!--EXPERIENCE ID-->
  806. <input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>">
  807. <!-- TITLE -->
  808. <div class="form-group">
  809. <label class="control-label col-sm-2">Title:</label>
  810. <div class="col-sm-9">
  811. <input type="text" class="form-control text-center" name="m_title" maxlength="60" placeholder="Title" required>
  812. </div>
  813. </div>
  814. <!-- DESCRIPTION -->
  815. <div class="form-group">
  816. <label class="control-label col-sm-2">Description:</label>
  817. <div class="col-sm-9">
  818. <textarea class="form-control text-center" name="m_description" rows="1" style="resize:vertical;" maxlength="100" placeholder="Description" required></textarea>
  819. </div>
  820. </div>
  821. <!-- DATE TO ADMINISTER -->
  822. <div class="form-group">
  823. <label class="control-label col-sm-2">Date to Administer:</label>
  824. <div class="col-sm-9">
  825. <input type="datetime-local" class="form-control text-center" name="m_date" maxlength="16" placeholder="YYYY-MM-DDThh:mm" required>
  826. </div>
  827. </div>
  828. <!-- CORRESPONDING QUESTIONNAIRE -->
  829. <?php
  830. $query7 = "SELECT * FROM `questionnair` WHERE `id` IN (SELECT `id_questionnair` FROM `experience_questionnair` WHERE `id_experience` = '$experienceID');";
  831. $result7 = mysqli_query($connection, $query7);
  832. // IF THE EXPERIENCE HAS AT LEAST ONE QUESTIONNAIRE ASSOCIATED TO IT, SHOW IT
  833. // ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
  834. if(mysqli_num_rows($result7) > 0):
  835. ?>
  836. <div class="form-group">
  837. <label class="control-label col-sm-2">Questionnaire:</label>
  838. <div class="col-sm-9">
  839. <select class="form-control" id="m_questionnaire" name="m_questionnaire" style="width:100%; text-align-last:center;" required>
  840. <option disabled selected value>Corresponding Questionnaire</option>
  841. <?php while($row7 = mysqli_fetch_assoc($result7)): ?>
  842. <option value="<?php echo $row7['id']; ?>"><?php echo $row7['q_title']; ?></option>
  843. <?php endwhile; ?>
  844. </select>
  845. </div>
  846. </div>
  847. <?php else: ?>
  848. <div class="text-center">
  849. <h3><small>First add a questionnaire!</small></h3>
  850. </div>
  851. <?php endif; ?>
  852. </div><!--form-horizontal-->
  853. </div><!--modal-body-->
  854. <!-- NEXT OR CANCEL -->
  855. <div class="modal-footer">
  856. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  857. <button id="nextMoment" type="button" class="btn btn-primary" data-dismiss="modal" onclick="nextModal('#NewMoment_2')" disabled>Next</button>
  858. </div>
  859. </div><!--modal-content-->
  860. </div><!--modal-dialog-->
  861. </div><!--modal-->
  862. <!-- FORM VALIDATION FOR NEW MOMENT (BASIC INFO) -->
  863. <script>
  864. // Fetch the inputs in the first modal
  865. let momentTitle = document.querySelector('[name=m_title]');
  866. let momentDescription = document.querySelector('[name=m_description]');
  867. let momentDate = document.querySelector('[name=m_date]');
  868. let momentQuestionnaire = document.querySelector('[name=m_questionnaire]');
  869. // Add onchange and onkeyup event listeners to each input in the first modal
  870. momentTitle.addEventListener('keyup', validateNewMoment);
  871. momentTitle.addEventListener('change', validateNewMoment);
  872. momentDescription.addEventListener('keyup', validateNewMoment);
  873. momentDescription.addEventListener('change', validateNewMoment);
  874. momentDate.addEventListener('keyup', validateNewMoment);
  875. momentDate.addEventListener('change', validateNewMoment);
  876. momentQuestionnaire.addEventListener('keyup', validateNewMoment);
  877. momentQuestionnaire.addEventListener('change', validateNewMoment);
  878. // First modal's validation function
  879. // This basically enables the "Next" button if certain conditions are met
  880. function validateNewMoment() {
  881. // Fetch "Next" button in modal
  882. let nextButton = document.querySelector('#nextMoment');
  883. // Check validity of each input (valid if not empty strings & "maxlength" is set)
  884. let validity = momentTitle.checkValidity();
  885. validity &= momentDescription.checkValidity();
  886. validity &= momentDate.checkValidity();
  887. validity &= momentQuestionnaire.checkValidity();
  888. // Disabled if not valid, enabled otherwise
  889. nextButton.disabled = !validity;
  890. }
  891. </script>
  892. <!-- POPUP FOR NEW MOMENT 2 -->
  893. <div class="modal fade" id="NewMoment_2" tabindex="-1" role="dialog" aria-labelledby="NewMomentLabel_2" aria-hidden="true">
  894. <div class="modal-dialog modal-lg" role="document">
  895. <div class="modal-content">
  896. <div class="modal-body">
  897. <!-- CLOSE BUTTON -->
  898. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  899. <span aria-hidden='true'>&times;</span>
  900. </button>
  901. <div class="row">
  902. <div class="col-sm-10">
  903. <h2>New Moment <small>(Questions – <em>Part 2</em>)</small></h2>
  904. </div>
  905. </div><!--row-->
  906. <hr><br>
  907. <!-- QUESTION -->
  908. <div id="qq1" >
  909. <div class="row">
  910. <div class="col col-sm-offset-1">
  911. <h4>Question 1</h4>
  912. </div>
  913. </div>
  914. <!-- CHOOSE QUESTION FROM CORRESPONDING QUESTIONNAIRE -->
  915. <div class="form-horizontal">
  916. <div class="form-group">
  917. <div class='col-sm-offset-2 col-sm-9'>
  918. <select class="form-control" id="m_question_1" name="m_question_1" style="width:100%; text-align-last:center;" required>
  919. <option disabled selected value>Select Question</option>
  920. </select>
  921. </div>
  922. </div>
  923. </div>
  924. </div>
  925. <br>
  926. <div class="row">
  927. <div class="col-sm-offset-9 col-sm-2">
  928. <button type='button' class='btn btn-xs btn-default' onclick='addSelectableQuestion()'>Add Question</button>
  929. </div>
  930. </div>
  931. <!-- ERROR ALERT FOR USER -->
  932. <div id="error-newMoment" class="row" style="display: none;">
  933. <div class="col-sm-12">
  934. <div class="alert alert-danger mb-1" role="alert">
  935. <h4 class="error-lead">Error!</h4>
  936. <p class="error-description"></p>
  937. </div>
  938. </div>
  939. </div>
  940. </div><!--modal-body-->
  941. <!-- NEXT OR CANCEL -->
  942. <div class="modal-footer">
  943. <button type="button" class="btn btn-default" data-dismiss="modal" onclick="nextModal('#NewMoment')">Previous</button>
  944. <button type="submit" class="btn btn-primary" name="newMoment" <?php if(mysqli_num_rows($result7) == 0) { echo 'disabled'; } ?>>Create</button>
  945. </div>
  946. </div><!--modal-content-->
  947. </div><!--modal-dialog-->
  948. </div><!--modal-->
  949. </form>
  950. <!-- POPUP FOR NEW MILESTONE -->
  951. <form id="newMilestone">
  952. <div class="modal fade" id="NewMilestone" tabindex="-1" role="dialog" aria-labelledby="NewMilestoneLabel" aria-hidden="true">
  953. <div class="modal-dialog" role="document"">
  954. <div class="modal-content">
  955. <div class="modal-body">
  956. <!-- CLOSE BUTTON -->
  957. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  958. <span aria-hidden="true">&times;</span>
  959. </button>
  960. <div class="row">
  961. <div class="col-sm-10">
  962. <h2>New Milestone</h2>
  963. </div>
  964. </div><!--row-->
  965. <hr><br>
  966. <div class="form-horizontal">
  967. <!-- EXPERIENCE ID -->
  968. <input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>">
  969. <!-- TITLE -->
  970. <div class="form-group">
  971. <label class="control-label col-sm-2">Title:</label>
  972. <div class="col-sm-9">
  973. <input type="text" class="form-control text-center" name="mil_title" maxlength="256" placeholder="Title" required>
  974. </div>
  975. </div>
  976. <!-- DATE -->
  977. <div class="form-group">
  978. <label class="control-label col-sm-2">Date:</label>
  979. <div class="col-sm-9">
  980. <input type="date" class="form-control text-center" name="mil_date" placeholder="YYYY-MM-DD" required>
  981. </div>
  982. </div>
  983. </div>
  984. <!-- ERROR ALERT FOR USER -->
  985. <div id="error-newMilestone" class="row" style="display: none;">
  986. <div class="col-sm-12">
  987. <div class="alert alert-danger mb-1" role="alert">
  988. <h4 class="error-lead">Error!</h4>
  989. <p class="error-description"></p>
  990. </div>
  991. </div>
  992. </div>
  993. </div><!--modal-body-->
  994. <!-- NEXT OR CANCEL -->
  995. <div class="modal-footer">
  996. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  997. <button type="submit" class="btn btn-primary" name="newMilestone">Create</button>
  998. </div>
  999. </div><!--modal-content-->
  1000. </div><!--modal-dialog-->
  1001. </div><!--modal-->
  1002. </form>
  1003. <!-- STORE START DATE FOR CALENDAR RERENDERING LATER -->
  1004. <input id="experience_start_date" type="hidden" value="<?php echo $row1['start_date']; ?>">
  1005. <!-- FULL CALENDAR IMPORTS -->
  1006. <script src="processes/fullcalendar/packages/core/main.min.js"></script>
  1007. <script src="processes/fullcalendar/packages/daygrid/main.min.js"></script>
  1008. <script src="processes/fullcalendar/packages/timegrid/main.min.js"></script>
  1009. <script src="processes/fullcalendar/packages/interaction/main.min.js"></script>
  1010. <!-- <script src="https://unpkg.com/@fullcalendar/core/main.min.js"></script> -->
  1011. <!-- <script src="https://unpkg.com/@fullcalendar/daygrid/main.min.js"></script> -->
  1012. <!-- <script src="https://unpkg.com/@fullcalendar/timegrid@4.3.0/main.min.js"></script> -->
  1013. <!-- <script src="https://unpkg.com/@fullcalendar/interaction@4.3.0/main.min.js"></script> -->
  1014. <script src="js/viewExperience.js"></script>
  1015. <script src="js/handleSubmit.js"></script>
  1016. <script>
  1017. ["editForm", "newQuestionnaire", "newMoment", "newMilestone"].forEach(function(formName) {
  1018. var form = document.getElementById(formName);
  1019. if(form) {
  1020. form.addEventListener('submit', function(e) {
  1021. handleSubmit(e, formName);
  1022. });
  1023. }
  1024. });
  1025. //window.onload = function() {
  1026. // First load an empty calendar
  1027. var calendarElement = document.getElementById('actualCalendar');
  1028. var calendar = new FullCalendar.Calendar(calendarElement, {
  1029. plugins: [ 'dayGrid', 'timeGrid', 'interaction' ],
  1030. header: {
  1031. left: 'prev,next today',
  1032. center: 'title',
  1033. right: 'dayGridMonth,timeGridWeek,timeGridDay'
  1034. },
  1035. defaultDate: document.getElementById('experience_start_date').value,
  1036. businessHours: true,
  1037. editable: true,
  1038. dragScroll: true,
  1039. eventDrop: function(eventDropInfo) {
  1040. $.post(document.location.protocol + "//tania.uprrp.edu/admin_nuevo/special4.php", {
  1041. id: eventDropInfo.event.id,
  1042. experienceID: document.querySelector('input[name=id_experience]').value,
  1043. newStartDate: Date.parse(eventDropInfo.event.start), // convert to UNIX timestamp
  1044. newEndDate: Date.parse(eventDropInfo.event.end) // convert to UNIX timestamp
  1045. }).fail(function() {
  1046. alert('An error occurred! Resetting calendar...');
  1047. eventDropInfo.revert();
  1048. });
  1049. }
  1050. });
  1051. calendar.render();
  1052. // After the rest of the page has loaded, fetch events from DB & re-render calendar
  1053. var calendarConfig;
  1054. $.post(document.location.protocol + "//tania.uprrp.edu/admin_nuevo/special2.php",
  1055. {
  1056. experienceID: document.querySelector('input[name=id_experience]').value
  1057. },
  1058. function(data, status) {
  1059. if(!isJSON(data)) {
  1060. return;
  1061. }
  1062. calendarConfig = JSON.parse(data);
  1063. }
  1064. ).done(function() {
  1065. // console.log(calendarConfig);
  1066. if(calendarConfig === undefined) {
  1067. alert("Couldn't fetch your events! Please refresh this page. If this keeps ocurring, contact the page administrator.");
  1068. return;
  1069. }
  1070. calendarConfig.events.forEach(calendarEvent => {
  1071. calendar.addEvent(calendarEvent);
  1072. });
  1073. calendar.render();
  1074. }).fail(function() {
  1075. alert("Couldn't fetch your events! Please refresh this page. If this keeps ocurring, contact the page administrator.");
  1076. });
  1077. //}//domcontentloaded//onload
  1078. </script>
  1079. <?php include_once 'footer.php'; ?>