12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478 |
- <?php
-
- // Description: EXTRACT EXPERIENCE ID, AND IF VALID, DISPLAY ITS INFO
-
- require_once 'processes/config.php';
- require_once 'processes/dbh.inc.php';
- require_once 'processes/checkLogin.php';
-
- // IF VIEW VARIABLE NOT GIVEN, EXIT
- if(!isset($_GET['view'])) {
- exit();
- }
-
- // FETCH EXPERIENCE
- $experienceID = mysqli_real_escape_string($connection, trim($_GET['view']));
- $query1 = "SELECT * FROM `experience` WHERE `id` = '$experienceID';";
- $result1 = mysqli_query($connection, $query1) or die("Error: ".mysqli_error($connection));
- $row1 = mysqli_fetch_array($result1);
-
- // IF EXPERIENCE NOT IN DATABASE, EXIT
- if($result1->num_rows !== 1) {
- echo "Requested experience does not exist.";
- exit();
- }
-
- // IF EXPERIENCE DOESN'T BELONG TO USER (WHO IS NOT AN ADMIN), EXIT
- if($_SESSION['dbUserData']['admin'] !== '1') {
-
- $queryCheckUser = "SELECT id FROM experience WHERE id = '$experienceID' AND id IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "');";
- if(mysqli_query($connection, $queryCheckUser)->num_rows === 0) {
- echo "You are not authorized to view this experience.";
- exit();
- }
-
- }
-
-
- include_once 'header.php';
-
- ?>
- <!--START OF viewExperience.php -->
- <body>
-
- <header id="main-header">
- <a id="logo" href=".">
- TANIA
- <img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
- </a>
- <div id="account">
- <a class="sign-out" href="./processes/logout.php">Sign Out</a>
- </div>
- </header>
-
- <div class="container-fluid" id="view-experience-showcase">
- <div class="row">
- <div class="col-sm-12">
-
- <h2><?php echo $row1['title']; ?></h2>
- <div class="row">
-
- <div class="col-sm-7 col-md-8 col-lg-9">
-
- <blockquote style="color:rgb(216,216,216); margin: 0;">
- <h4><b style="color:#fff;">Description:</b> <span style="color:rgb(216,216,216);"><?php echo $row1['description']; ?></span></h4>
- <h4><b style="color:#fff;">Type:</b> <span style="color:rgb(216,216,216);"><?php echo $row1['type']; ?></span></h4>
- <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>
- </blockquote>
-
- </div><!--col-->
-
-
- <div class="col-sm-5 col-md-4 col-lg-3">
-
- <div id="view-experience-buttons">
- <div data-toggle="tooltip" data-placement="top" title="View Results" id="experience-pen" onclick="window.location='respuestas.php?exp=<?php echo $experienceID; ?>'">
- <span class="fas fa-poll-h"></span>
- </div>
- <div data-toggle="tooltip" data-placement="top" title="Edit Experience" id="experience-pen" onclick="nextModal('#Edit')">
- <span class="fas fa-pen"></span>
- </div>
- <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']; ?>')">
- <span class="fas fa-link"></span>
- </div>
- </div>
-
- </div><!--col-->
-
- </div><!--row-->
-
- <br>
-
- <div class="row hidden-xs" id="view-experience-tabs">
- <a class="active" href="#calendar">Calendar</a>
- <a href="#questionnaires">Questionnaires</a>
- <a href="#moments">Moments</a>
- <a href="#milestones">Milestones</a>
- </div><!--row-->
-
- </div><!--col-->
- </div><!--row-->
- </div><!--container-->
-
- <br>
-
- <!-- CALENDAR-->
- <div id="calendar" class="main-content-box show hidden-xs">
- <div class="container">
-
- <div class="row">
- <h3 class="col-sm-12">Schedule Your Experience</h3>
- </div><!--row-->
-
- <br>
-
- <div class="row">
- <div class="col-sm-12">
- <div id="actualCalendar"></div>
- </div>
- </div>
-
- <br><br><br><br>
-
- </div><!--container-->
- </div>
-
-
-
- <!--QUESTIONNAIRES-->
- <div id="questionnaires" class="main-content-box">
- <div class="container">
-
- <div class="row">
- <h3 class="col-xs-7 col-sm-9 col-md-9">Active Questionnaires</h3>
- <div class="col-xs-5 col-sm-3 col-md-3">
- <!--
- <span data-toggle="modal" data-target="#Import" style="margin-right: 1em;">
- <button type="button" class="btn btn-lg btn-default" data-toggle="tooltip" data-placement="top" title="Import Questionnaire">
- <span class="glyphicon glyphicon-open-file"></span>
- </button>
- </span>
- <span data-toggle="modal" data-target="#Duplicate">
- <button type="button" class="btn btn-lg btn-default" data-toggle="tooltip" data-placement="top" title="Duplicate Questionnaire">
- <span class="glyphicon glyphicon-paste"></span>
- </button>
- </span>
- -->
- <div id="view-experience-buttons">
- <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;">
- <span class="fas fa-file-import"></span>
- </div>
- <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;">
- <span class="fas fa-copy"></span>
- </div>
- </div>
- </div>
- </div><!--row-->
-
- <br>
-
- <div class="row">
-
- <div class="col-sm-12">
- <?php
-
- $query2 = "SELECT * FROM questionnair WHERE `id` IN (SELECT `id_questionnair` FROM experience_questionnair WHERE `id_experience` = '$experienceID');";
- $result2 = mysqli_query($connection, $query2);
-
- // IF THE EXPERIENCE HAS AT LEAST ONE QUESTIONNAIRE ASSOCIATED TO IT, SHOW IT
- // ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
- if(mysqli_num_rows($result2) > 0):
-
- ?>
- <table class="table table-hover table-striped table-responsive">
- <thead>
- <tr>
- <th style="text-align: center;"><h4>Questionnaire</h4></th>
- <th style="text-align: center;"><h4>Questions</h4></th>
- </tr>
- </thead>
- <tbody>
- <?php while($row2 = mysqli_fetch_assoc($result2)): ?>
- <tr style="cursor: pointer;" onclick="location='viewQuestionnaire.php?view=<?php echo $row2['id']?>'">
- <td style="text-align: center;"><h5><?php echo $row2['q_title']; ?></h5></td>
- <?php
- $query3 = "SELECT * FROM questionnair_question WHERE id_questionnair = ".$row2['id'];
- $result3 = mysqli_query($connection, $query3);
- ?>
- <td style="text-align: center;"><h5><?php echo mysqli_num_rows($result3); ?></h5></td>
- </tr>
- <?php endwhile; ?>
- </tbody>
- </table>
-
- <?php else: ?>
- <h3 class="text-center"><small>It seems you still haven't added a questionnaire to this experience...</small></h3>
- <?php endif; ?>
-
- <br>
- <div class="row">
- <div class="col-sm-2 col-sm-offset-5">
- <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;">
- <span class="fas fa-plus"></span>
- </div>
- </div>
- </div>
-
- </div><!--col-sm-12-->
-
- </div><!--row-->
-
- <br><br>
-
- <div class="row">
- <div class="col-sm-offset-2 col-sm-8">
- <div class="alert alert-warning alert-dismisible mb-1 hidden-xs" role="alert">
- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- <h4>Tips on Questionnaires</h4>
- <hr>
- <ul>
- <li>These are the questionnaires that are associated to this experience.</li>
- <br>
- <li>Once you have your questionnaire, you can create your moments.</li>
- <br>
- <li>You can create new questionnaires with the plus button...
- <ul>
- <li>or import questionnaires from an Excel file!</li>
- <li>or copy a questionnaire from one experience to another!</li>
- </ul>
- </li>
- <br>
- </ul>
- </div><!--alert-->
- </div><!--col-sm-8-->
- </div><!--row-->
-
- <br>
-
- </div><!--container-->
-
- </div>
-
-
-
- <!--MOMENTS-->
- <div id="moments" class="main-content-box">
- <div class="container">
-
- <div class="row">
- <h3 class="col-sm-12">Active Moments</h3>
- </div>
-
-
- <div class="row">
-
-
- <div class="col-sm-12">
- <?php
-
- $query4 = "SELECT * FROM subquestionnair WHERE `id_questionnair` IN (SELECT `id_questionnair` FROM experience_questionnair WHERE `id_experience` = '$experienceID') ORDER BY date_to_administer ASC;";
- $result4 = mysqli_query($connection, $query4);
-
- // IF THE EXPERIENCE HAS AT LEAST ONE MOMENT ASSOCIATED TO IT, SHOW IT
- // ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
- if(mysqli_num_rows($result4) > 0):
-
- ?>
- <table class="table table-hover table-striped table-responsive">
- <thead>
- <tr>
- <th style="text-align: center;"><h4>Moment</h4></th>
- <th style="text-align: center;"><h4>Questions</h4></th>
- <th style="text-align: center;"><h4>Date</h4></th>
- </tr>
- </thead>
- <tbody>
- <?php while($row4 = mysqli_fetch_assoc($result4)): ?>
- <tr style="cursor: pointer;" onclick="location='viewMoment.php?view=<?php echo $row4['id']?>'">
- <td style="text-align: center;"><h5><?php echo $row4['title']; ?></h5></td>
- <?php
- $query5 = "SELECT * FROM subquestionnair_question WHERE `id_subquestionnair` = ".$row4['id'];
- $result5 = mysqli_query($connection, $query5);
- ?>
- <td style="text-align: center;"><h5><?php echo mysqli_num_rows($result5); ?></h5></td>
- <td style="text-align: center;"><h5><?php echo date("M j, Y (g:i A)", strtotime($row4['date_to_administer'])); ?></h5></td>
- </tr>
- <?php endwhile; ?>
- </tbody>
- </table>
-
- <?php else: ?>
- <h3 class="text-center"><small>It seems you still haven't added any moments to this experience...</small></h3>
- <?php endif; ?>
-
- <br>
-
- <div class="row">
- <div class="col-sm-2 col-sm-offset-5">
- <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;">
- <span class="fas fa-plus"></span>
- </div>
- </div>
- </div>
-
-
- </div><!--col-sm-12-->
-
- </div><!--row-->
-
-
- <br><br>
-
- <div class="row">
- <div class="col-sm-offset-2 col-sm-8">
- <div class="alert alert-warning alert-dismisible mb-1 hidden-xs" role="alert">
- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- <h4>Tips on Moments</h4>
- <hr>
- <ul>
- <li>These are the moments that are associated to this experience.</li>
- <br>
- <li>Once they're answered, you can track the results with the results button above.</li>
- <br>
- <li>You can create new moments with the plus button.</li>
- <br>
- </ul>
- </div><!--alert-->
- </div><!--col-sm-8-->
- </div><!--row-->
-
- <br>
-
- </div><!--container-->
-
- </div>
-
-
-
- <!--MILESTONES-->
- <div id="milestones" class="main-content-box">
- <div class="container">
-
- <div class="row">
- <h3 class="col-sm-12">Active Milestones</h3>
- </div>
-
- <div class="row">
-
-
- <div class="col-sm-12">
- <?php
-
- $query6 = "SELECT * FROM `milestone` WHERE `id_experience` = '$experienceID' ORDER BY date ASC;";
- $result6 = mysqli_query($connection, $query6);
-
- // IF THE EXPERIENCE HAS AT LEAST ONE MILESTONE ASSOCIATED TO IT, SHOW IT
- // ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
- if(mysqli_num_rows($result6) > 0):
-
- ?>
- <table class="table table-hover table-striped table-responsive">
- <thead>
- <tr>
- <th style="text-align: center;"><h4>Milestone</h4></th>
- <th style="text-align: center;"><h4>Date</h4></th>
- </tr>
- </thead>
- <tbody>
- <?php while($row6 = mysqli_fetch_assoc($result6)): ?>
- <tr style="cursor: pointer;">
- <td style="text-align: center;"><h5><?php echo $row6['title']; ?></h5></td>
- <td style="text-align: center;"><h5><?php echo date("M j, Y", strtotime($row6['date'])); ?></h5></td>
- </tr>
- <?php endwhile; ?>
- </tbody>
- </table>
-
- <?php else: ?>
- <h3 class="text-center"><small>It seems you still haven't added any milestones to this experience...</small></h3>
- <?php endif; ?>
-
- <br>
-
- <div class="row">
- <div class="col-sm-2 col-sm-offset-5">
- <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;">
- <span class="fas fa-plus"></span>
- </div>
- </div>
- </div>
-
-
- </div><!--col-sm-12-->
- </div><!--row-->
-
- <br><br>
-
- <div class="row">
- <div class="col-sm-offset-2 col-sm-8">
- <div class="alert alert-warning alert-dismisible mb-1 hidden-xs" role="alert">
- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- <h4>Tips on Milestones</h4>
- <hr>
- <ul>
- <li>These are the milestones of the students involved in this experience.</li>
- <br>
- <li>Once your moments are answered you can track the impact the milestones had on the answers, if any.</li>
- <br>
- <li>You can create new milestones with the plus button.</li>
- <br>
- </ul>
- </div><!--alert-->
- </div><!--col-sm-8-->
- </div><!--row-->
-
- <br>
-
- </div><!--container-->
-
- </div>
-
-
-
- <br><br><br><br><br>
-
-
-
- <!-- POPUP FOR EDIT EXPERIENCE -->
- <form id="editForm"><!--method='POST' action='processes/updateExperience.php'-->
- <div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="EditLabel" aria-hidden="true">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
-
- <div class="modal-body">
-
- <!-- CLOSE BUTTON -->
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
-
- <div class="row">
- <div class="col-sm-10">
- <h2>Edit Experience <small>(Basic Info)</small></h2>
- </div>
- </div><!--row-->
-
- <hr><br>
-
- <div class="form-horizontal">
-
- <!-- ID -->
- <input type="hidden" name="id" value="<?php echo $row1['id']; ?>">
-
- <!-- NEW TITLE -->
- <div class="form-group">
- <label class="control-label col-sm-2 col-sm-offset-1">Title:</label>
- <div class="col-sm-7">
- <input type="text" class="form-control text-center" name="newTitle" maxlength="60" value="<?php echo $row1['title']; ?>" required>
- </div>
- </div>
-
- <!-- NEW DESCRIPTION -->
- <div class="form-group">
- <label class="control-label col-sm-2 col-sm-offset-1">Description:</label>
- <div class="col-sm-7">
- <textarea class="form-control text-center" name="newDescription" rows="4" style="resize: vertical;" maxlength="100" required><?php echo $row1['description']; ?></textarea>
- </div>
- </div>
-
- <!--
- <!~~ NEW TYPE ~~>
- <div class='form-group'>
- <label class='control-label col-sm-2 col-sm-offset-1'>Type:</label>
- <div class='col-sm-7'>
- <input type='text' class='form-control text-center' name='newType' required value="<?php echo $row1['type']; ?>">
- </div>
- </div>
-
- <!~~ NEW DURATION ~~>
- <div class='form-group'>
- <label class='control-label col-sm-2 col-sm-offset-1'>Duration:</label>
- <div class='col-sm-7'>
- <input type='number' class='form-control text-center' name='newDuration' required value="<?php echo $row1['duration_weeks']; ?>" readonly>
- </div>
- </div>
-
- <!~~ NEW START DATE ~~>
- <div class='form-group'>
- <label class='control-label col-sm-2 col-sm-offset-1'>Start Date:</label>
- <div class='col-sm-7'>
- <input type='date' class='form-control text-center' name='newStart' required value="<?php echo $row1['start_date']; ?>">
- </div>
- </div>
-
- <!~~ NEW END DATE ~~>
- <div class='form-group'>
- <label class='control-label col-sm-2 col-sm-offset-1'>End Date:</label>
- <div class='col-sm-7'>
- <input type='date' class='form-control text-center' name='newEnd' required value="<?php echo $row1['end_date']; ?>">
- </div>
- </div>
- -->
-
- </div><!--form-horizontal-->
-
-
-
- <!-- ERROR ALERT FOR USER -->
- <div id="error-editForm" class="row" style="display: none;">
- <div class="col-sm-12">
- <div class="alert alert-danger mb-1" role="alert">
- <h4 class="error-lead">Error!</h4>
- <p class="error-description"></p>
- </div>
- </div>
- </div>
-
-
- </div><!--modal-body-->
-
- <!-- SUBMIT OR CANCEL -->
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
- <button type="submit" class="btn btn-primary" name="updateExperience" disabled>Save Changes</button>
- </div>
-
- </div><!--modal-content-->
- </div><!--modal-dialog-->
- </div><!--modal-->
- </form><!--form-->
-
-
- <!--FORM VALIDATION FOR EDIT EXPERIENCE-->
- <script>
-
- let newTitle = document.querySelector('[name=newTitle]');
- let newDescription = document.querySelector('[name=newDescription]');
- // let newType = document.querySelector('[name=newType]');
-
- newTitle.addEventListener('keyup', validateEditExperience);
- newTitle.addEventListener('change', validateEditExperience);
- newDescription.addEventListener('keyup', validateEditExperience);
- newDescription.addEventListener('change', validateEditExperience);
- // newType.addEventListener('keyup', validateEditExperience);
- // newType.addEventListener('change', validateEditExperience);
-
- // Only enable submit button when:
- // 1) changes are detected,
- // 2) and both strings (title and description) are not empty
- function validateEditExperience() {
- let updateExperience = document.querySelector('[name=updateExperience]');
- updateExperience.disabled = !newTitle.checkValidity() || !newDescription.checkValidity();
- }
-
- </script>
-
-
-
- <!-- POPUP FOR NEW QUESTIONNAIRE 1 -->
- <div class="modal fade" id="NewQuestionnaire" tabindex="-1" role="dialog" aria-labelledby="NewQuestionnaireLabel" aria-hidden="true">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
-
- <div class="modal-body">
-
- <!-- CLOSE BUTTON -->
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden='true'>×</span>
- </button>
-
- <div class="row">
- <div class="col-sm-10">
- <h2>New Questionnaire <small>(Basic Info – <em>Part 1</em>)</small></h2>
- </div>
- </div><!--row-->
-
- <hr><br>
-
- <div class="form-horizontal">
-
-
- <!-- TITLE -->
- <div class="form-group">
- <label class="control-label col-sm-2">Title:</label>
- <div class="col-sm-9">
- <input type="text" class="form-control text-center" name="q_title_tentative" placeholder="Title" maxlength="100" required>
- </div>
- </div>
-
- <!-- DESCRIPTION -->
- <div class="form-group">
- <label class="control-label col-sm-2">Description:</label>
- <div class="col-sm-9">
- <textarea class="form-control text-center" name="description_tentative" rows="1" placeholder="Description" maxlength="200" required></textarea>
- </div>
- </div>
-
- <!-- REFERENCE -->
- <div class="form-group">
- <label class="control-label col-sm-2">Reference:</label>
- <div class="col-sm-9">
- <input type="text" class="form-control text-center" name="referencia_tentative" placeholder="Reference" maxlength="60" required>
- </div>
- </div>
-
- <br>
-
- <!-- CATEGORIES -->
- <div class="form-group">
- <label class="control-label col-sm-2">Categories:</label>
- <div class="col-sm-9">
- <textarea id="q_categories_tentative" class="form-control text-center" name="q_categories_tentative" rows="1" placeholder="Categories (comma separated)" required></textarea>
- </div>
- </div>
-
- <!-- SUBCATEGORIES -->
- <div class="form-group">
- <label class="control-label col-sm-2">Subcategories:</label>
- <div class="col-sm-9">
- <textarea id="q_subcategories_tentative" class="form-control text-center" name="q_subcategories_tentative" rows="1" placeholder="Subcategories (comma separated)" required></textarea>
- </div>
- </div>
-
- </div>
-
- <div class="row">
- <div class="col col-sm-offset-2 col-sm-9">
- <p class="alert alert-warning text-justify">
- <strong>Note:</strong> You should at least have the same number of subcategories as categories.
- </p>
- </div>
- </div>
-
-
- </div><!--modal-body-->
-
- <!-- NEXT OR CANCEL -->
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
- <button id="nextQuestionnaire" type="button" class='btn btn-primary' data-dismiss="modal" onclick="nextModal('#NewQuestionnaire_2')" disabled>Next</button>
- </div>
-
- </div><!--modal-content-->
- </div><!--modal-dialog-->
- </div><!--modal-->
-
-
- <!-- FORM VALIDATION FOR NEW QUESTIONNAIRE (BASIC INFO) -->
- <script>
-
-
- // Fetch the inputs in the first modal
- let questionnaireTitle = document.querySelector('[name=q_title_tentative]');
- let questionnaireDescription = document.querySelector('[name=description_tentative]');
- let questionnaireReference = document.querySelector('[name=referencia_tentative]');
- let categories = document.querySelector('[name=q_categories_tentative]');
- let subcategories = document.querySelector('[name=q_subcategories_tentative]');
-
-
- // Add onchange and onkeyup event listeners to each input in the first modal
- questionnaireTitle.addEventListener('keyup', validateNewQuestionnaire);
- questionnaireTitle.addEventListener('change', validateNewQuestionnaire);
- questionnaireDescription.addEventListener('keyup', validateNewQuestionnaire);
- questionnaireDescription.addEventListener('change', validateNewQuestionnaire);
- questionnaireReference.addEventListener('keyup', validateNewQuestionnaire);
- questionnaireReference.addEventListener('change', validateNewQuestionnaire);
- categories.addEventListener('keyup', validateNewQuestionnaire);
- categories.addEventListener('change', validateNewQuestionnaire);
- subcategories.addEventListener('keyup', validateNewQuestionnaire);
- subcategories.addEventListener('change', validateNewQuestionnaire);
-
-
- // Pass the values from the first modal to the second, where the actual (hidden) inputs reside
- questionnaireTitle.addEventListener('keyup', function() {
- document.querySelector('[name=q_title]').value = questionnaireTitle.value;
- });
- questionnaireDescription.addEventListener('keyup', function() {
- document.querySelector('[name=description]').value = questionnaireDescription.value;
- });
- questionnaireReference.addEventListener('keyup', function() {
- document.querySelector('[name=referencia]').value = questionnaireReference.value;
- });
- categories.addEventListener('keyup', function() {
- document.querySelector('[name=q_categories]').value = categories.value;
- });
- subcategories.addEventListener('keyup', function() {
- document.querySelector('[name=q_subcategories]').value = subcategories.value;
- });
-
-
- // First modal's validation function
- // This basically enables the "Next" button if certain conditions are met
- function validateNewQuestionnaire() {
-
-
- // Fetch "Next" button in modal
- let nextButton = document.querySelector('#nextQuestionnaire');
-
-
- // Check validity of each input (valid if not empty strings)
- let validity = questionnaireTitle.checkValidity();
- validity &= questionnaireDescription.checkValidity();
- validity &= questionnaireReference.checkValidity();
- validity &= categories.checkValidity();
- validity &= subcategories.checkValidity();
-
-
- // Questionnaire should have at least the same number of subcategories as categories
- let rawCategories = categories.value.split(',');
- let rawSubcategories = subcategories.value.split(',');
- let categoriesArray = new Array();
- let subcategoriesArray = new Array();
-
-
- // IF clause is necessary to avoid array WARNINGS and ERRORS
- if(categories.value != '' && subcategories.value != '') {
-
- // Store the "trimmed" categories in categoriesArray
- for(let i = 0; i < rawCategories.length; i++) {
-
- rawCategories[i] = rawCategories[i].trim();
-
- // if string not empty and not whitespace, insert as category option
- if(/\S/.test(rawCategories[i])) {
- categoriesArray.push(rawCategories[i]);
- }
-
- }
-
- // Store the "trimmed" subcategories in subcategoriesArray
- for(let i = 0; i < rawSubcategories.length; i++) {
-
- rawSubcategories[i] = rawSubcategories[i].trim();
-
- // if string not empty and not whitespace, insert as subcategory option
- if(/\S/.test(rawSubcategories[i])) {
- subcategoriesArray.push(rawSubcategories[i]);
- }
-
- }
-
- // Only valid if there are less or equal number of categories to subcategories
- validity &= categoriesArray.length <= subcategoriesArray.length;
-
- }
-
-
- // Disabled if not valid, enabled otherwise
- nextButton.disabled = !validity;
-
- }
- </script>
-
-
- <form id="newQuestionnaire"><!--method="POST" action="processes/insertQuestionnaire.php"-->
- <!-- POPUP FOR NEW QUESTIONNAIRE 2 -->
- <div class="modal fade" id="NewQuestionnaire_2" tabindex="-1" role="dialog" aria-labelledby="NewQuestionnaireLabel_2" aria-hidden="true">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
-
- <div class="modal-body">
-
- <!-- CLOSE BUTTON -->
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
-
- <div class="row">
- <div class="col-sm-10">
- <h2>New Questionnaire <small>(Questions – <em>Part 2</em>)</small></h2>
- </div>
- </div><!--row-->
-
- <hr>
-
-
- <!-- EXPERIENCE ID -->
- <input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>">
-
- <!-- QUESTIONNAIRE TITLE -->
- <input type="hidden" name="q_title" maxlength="100" required>
-
- <!-- QUESTIONNAIRE DESCRIPTION --->
- <input type="hidden" name="description" maxlength="200" required>
-
- <!-- QUESTIONNAIRE REFERENCE -->
- <input type="hidden" name="referencia" maxlength="60" required>
-
- <!-- QUESTIONNAIRE CATEGORIES -->
- <input id="q_categories" type="hidden" name="q_categories" required>
-
- <!-- QUESTIONNAIRE SUBCATEGORIES -->
- <input id="q_subcategories" type="hidden" name="q_subcategories" required>
-
-
- <!-- QUESTION -->
- <div id="q1">
-
- <div class="row">
- <div class="col col-sm-offset-1">
- <h4>Question 1</h4>
- </div>
- </div>
-
- <div class="form-horizontal">
-
- <!-- PREMISE -->
- <div class="form-group">
- <label class="col-sm-offset-1 control-label col-sm-2">Premise:</label>
- <div class="col-sm-8">
- <input id="q_premise1" type="text" class="form-control text-center" name="q_premise1" placeholder="Premise" maxlength="600" required>
- </div>
- </div>
-
- <!-- TYPE -->
- <div class="form-group">
- <label class="col-sm-offset-1 control-label col-sm-2">Question Type:</label>
- <div class="col-sm-8">
- <select class="form-control text-center" id="q_type1" name="q_type1" style="width:100%; text-align-last:center;" onchange="newThing(event)" required>
- <!-- <option disabled selected value="">Type</option> -->
- <option value="1">Scaled</option>
- <option value="2">Open Answer</option>
- </select>
- </div>
- </div>
-
- </div>
-
- <!-- MIN/MAX VALUES/TEXT (OPTIONAL) -->
- <div id="range1">
- <div class="form-inline col col-sm-offset-2">
- <div class="form-group">
- <label class="control-label col-sm-2">Min. Value:</label>
- <div class="col-sm-8">
- <input type="number" class="form-control text-center" id="min_val1" name="min_val1" value="1" readonly>
- </div>
- </div>
- <div class="form-group">
- <label class="control-label col-sm-2">Min. Text:</label>
- <div class="col-sm-8">
- <input type="text" class="form-control text-center" id="min_text1" name="min_text1" maxlength="40" placeholder="Very Dissatisfied">
- </div>
- </div>
- </div>
-
- <div class="form-inline col col-sm-offset-2">
- <div class="form-group">
- <label class="control-label col-sm-2">Max. Value:</label>
- <div class="col-sm-1">
- <input type="number" class="form-control text-center" id="max_val1" name="max_val1" value="5" min="2">
- </div>
- </div>
- <div class="form-group">
- <label class="control-label col-sm-2">Max. Text:</label>
- <div class="col-sm-1">
- <input type="text" class="form-control text-center" id="max_text1" name="max_text1" maxlength="40" placeholder="Very Satisfied">
- </div>
- </div>
- </div>
-
- <br>
-
- </div>
-
- <div class="form-horizontal">
-
- <!-- CORRESPONDING CATEGORY -->
- <div class="form-group">
- <label class="col-sm-offset-1 control-label col-sm-2">Category:</label>
- <div class="col-sm-8">
- <select class="form-control text-center" id="q_category1" name="q_category1" style="width: 100%; text-align-last:center;" required>
- <!-- <option disabled selected value="">Category</option> -->
- </select>
- </div>
- </div>
-
- <!-- CORRESPONDING SUBCATEGORY -->
- <div class="form-group">
- <label class="col-sm-offset-1 control-label col-sm-2">Subcategory:</label>
- <div class="col-sm-8">
- <select class="form-control text-center" id="q_subcategory1" name="q_subcategory1" style="width: 100%; text-align-last:center;" required>
- <!-- <option disabled selected value="">Subcategory</option> -->
- </select>
- </div>
- </div>
-
- </div>
-
- </div>
-
-
- <br>
-
- <div class="row">
- <div class="col-sm-offset-9 col-sm-2">
- <button type="button" class="btn btn-xs btn-default" onclick="addQuestion()">Add Question</button>
- </div>
- </div>
-
-
-
-
- <!-- ERROR ALERT FOR USER -->
- <div id="error-newQuestionnaire" class="row" style="display: none;">
- <div class="col-sm-12">
- <div class="alert alert-danger mb-1" role="alert">
- <h4 class="error-lead">Error!</h4>
- <p class="error-description"></p>
- </div>
- </div>
- </div>
-
-
- </div><!--modal-body-->
-
- <!-- SUBMIT OR PREVIOUS -->
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" onclick="nextModal('#NewQuestionnaire')">Previous</button>
- <button type="submit" class="btn btn-primary" name="createQuestionnaire">Create</button>
- </div>
-
- </div><!--modal-content-->
- </div><!--modal-dialog-->
- </div><!--modal-->
- </form>
-
-
-
-
-
- <!-- POPUP FOR IMPORT QUESTIONNAIRE -->
- <form class='form-horizontal' action='processes/importQuestionnaire.php' method='POST' enctype="multipart/form-data">
- <div class='modal fade' id='Import' tabindex='-1' role='dialog' aria-labelledby='ImportLabel' aria-hidden='true'>
- <div class='modal-dialog modal-dialog-centered modal-md' role='document'>
- <div class='modal-content'>
-
- <div class='modal-header'>
- <h3 class='modal-title' id='ImportLabel'>Import Questionnaire<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button></h3>
- </div>
-
- <div class='modal-body'>
-
- <div class="form-horizontal">
-
- <input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>">
-
- <div class="row">
- <div class="col-sm-12">
- <h4>Download Template</h4>
- <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>
- <a class="btn btn-primary btn-sm btn-block" href="nameOfTheQuestionnair.xlsx">Download Template</a>
- </div>
- </div><!--row-->
-
- <br>
- <br>
-
- <div class="form-group">
- <div class="col-sm-10 col-sm-offset-2">
- <label for="exampleInputFile">Questionnaire in xlsx format</label>
- <input type="file" name='import'>
- <p class="help-block">Choose your .xlsx file (remember it has to have the correct format).</p>
- </div>
- </div><!--form-group-->
-
- </div>
-
-
- </div><!--modal-body-->
-
- <div class='modal-footer'>
- <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
- <button type='submit' class='btn btn-primary' name='insertQuestionnaire'>Import</button>
- </div>
-
- </div><!--modal-content-->
- </div><!--modal-dialog-->
- </div><!--modal-->
-
-
-
-
-
- <!-- POPUP FOR DUPLICATE QUESTIONNAIRE -->
- <form class='form-horizontal' action='processes/duplicateQuestionnaire.php' method='POST'>
- <div class='modal fade' id='Duplicate' tabindex='-1' role='dialog' aria-labelledby='DuplicateLabel' aria-hidden='true'>
- <div class='modal-dialog modal-dialog-centered' role='document'>
- <div class='modal-content'>
-
- <div class='modal-header'>
- <h3 class='modal-title' id='DuplicateLabel'>Duplicate Questionnaire<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button></h3>
- </div>
-
- <div class='modal-body'>
-
- <span class='text-center'>
- <h4>Copy a questionnaire from one experience to another</h4>
- </span>
-
- <br>
-
- <!-- FROM QUESTIONNAIRE -->
- <label for="fromQuestionnaireID">Which Questionnaire:</label>
- <?php
- // FIRST ASSUME FALSE
- $errorDuplicate = false;
-
- $queryQuestionnaires = "SELECT * FROM `questionnair` WHERE id IN (SELECT id_questionnair FROM experience_questionnair WHERE id_experience = '$experienceID');";
- $resultQuestionnaires = mysqli_query($connection, $queryQuestionnaires);
-
- if($resultQuestionnaires->num_rows > 0):
- ?>
- <select class="form-control text-center" id="fromQuestionnaireID" name="fromQuestionnaireID" style="text-align-last:center;" required>
- <?php while($rowQuestionnaires = mysqli_fetch_assoc($resultQuestionnaires)): ?>
- <option value="<?php echo $rowQuestionnaires['id']; ?>"><?php echo $rowQuestionnaires['q_title']; ?></option>
- <?php endwhile; ?>
- </select>
- <?php
- else:
- $errorDuplicate = true;
- ?>
- <h3 class="text-center"><small>It seems you still haven't added any questionnaires to this experience...</small></h3>
- <?php endif; ?>
-
- <br>
-
- <!-- TO EXPERIENCE -->
- <label for="toExperienceID">To What Experience:</label>
- <?php
-
- // CHANGE QUERY DEPENDING ON IF USER IS ADMIN OR NOT
- if($_SESSION['dbUserData']['admin'] === '1') {
- $queryExperience2 = "SELECT * FROM `experience` WHERE id != '$experienceID';";
- } else {
- $queryExperience2 = "SELECT * FROM `experience` WHERE id != '$experienceID' AND id IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "');";
- }
-
- $resultExperience2 = mysqli_query($connection, $queryExperience2);
-
- if($resultExperience2->num_rows > 0):
- ?>
- <select class="form-control text-center" id="toExperienceID" name="toExperienceID" style="text-align-last:center;" required>
- <?php while($rowExperience2 = mysqli_fetch_assoc($resultExperience2)): ?>
- <option value="<?php echo $rowExperience2['id']; ?>"><?php echo $rowExperience2['title']; ?></option>
- <?php endwhile; ?>
- </select>
- <?php
- else:
- $errorDuplicate = true;
- ?>
- <h3 class="text-center"><small>You don't have another experience to duplicate to...</small></h3>
- <?php endif; ?>
-
-
- </div><!--modal-body-->
-
- <!-- SUBMIT OR CANCEL -->
- <div class='modal-footer'>
- <button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
- <button type='submit' class='btn btn-primary' name='duplicateQuestionnaire' <?php if($errorDuplicate === true) echo "disabled"; ?>>Confirm</button>
- </div>
-
- </div><!--modal-content-->
- </div><!--modal-dialog-->
- </div><!--modal-->
- </form>
-
-
-
-
-
- <!-- POPUP FOR NEW MOMENT 1 -->
- <form id="newMoment"><!--method='POST' action='processes/insertMoment.php'-->
- <div class="modal fade" id="NewMoment" tabindex="-1" role="dialog" aria-labelledby="NewMomentLabel" aria-hidden="true">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
-
- <div class="modal-body">
-
- <!-- CLOSE BUTTON -->
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden='true'>×</span>
- </button>
-
- <div class="row">
- <div class="col-sm-10">
- <h2>New Moment <small>(Basic Info – <em>Part 1</em>)</small></h2>
- </div>
- </div><!--row-->
-
- <hr><br>
-
-
- <div class="form-horizontal">
-
- <!--EXPERIENCE ID-->
- <input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>">
-
- <!-- TITLE -->
- <div class="form-group">
- <label class="control-label col-sm-2">Title:</label>
- <div class="col-sm-9">
- <input type="text" class="form-control text-center" name="m_title" maxlength="60" placeholder="Title" required>
- </div>
- </div>
-
- <!-- DESCRIPTION -->
- <div class="form-group">
- <label class="control-label col-sm-2">Description:</label>
- <div class="col-sm-9">
- <textarea class="form-control text-center" name="m_description" rows="1" style="resize:vertical;" maxlength="100" placeholder="Description" required></textarea>
- </div>
- </div>
-
- <!-- DATE TO ADMINISTER -->
- <div class="form-group">
- <label class="control-label col-sm-2">Date to Administer:</label>
- <div class="col-sm-9">
- <input type="datetime-local" class="form-control text-center" name="m_date" maxlength="16" placeholder="YYYY-MM-DDThh:mm" required>
- </div>
- </div>
-
- <!-- CORRESPONDING QUESTIONNAIRE -->
- <?php
-
- $query7 = "SELECT * FROM `questionnair` WHERE `id` IN (SELECT `id_questionnair` FROM `experience_questionnair` WHERE `id_experience` = '$experienceID');";
- $result7 = mysqli_query($connection, $query7);
-
- // IF THE EXPERIENCE HAS AT LEAST ONE QUESTIONNAIRE ASSOCIATED TO IT, SHOW IT
- // ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
- if(mysqli_num_rows($result7) > 0):
-
- ?>
- <div class="form-group">
- <label class="control-label col-sm-2">Questionnaire:</label>
- <div class="col-sm-9">
- <select class="form-control" id="m_questionnaire" name="m_questionnaire" style="width:100%; text-align-last:center;" required>
- <option disabled selected value>Corresponding Questionnaire</option>
- <?php while($row7 = mysqli_fetch_assoc($result7)): ?>
- <option value="<?php echo $row7['id']; ?>"><?php echo $row7['q_title']; ?></option>
- <?php endwhile; ?>
- </select>
- </div>
- </div>
- <?php else: ?>
- <div class="text-center">
- <h3><small>First add a questionnaire!</small></h3>
- </div>
- <?php endif; ?>
-
-
- </div><!--form-horizontal-->
-
- </div><!--modal-body-->
-
- <!-- NEXT OR CANCEL -->
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
- <button id="nextMoment" type="button" class="btn btn-primary" data-dismiss="modal" onclick="nextModal('#NewMoment_2')" disabled>Next</button>
- </div>
-
- </div><!--modal-content-->
- </div><!--modal-dialog-->
- </div><!--modal-->
-
-
-
- <!-- FORM VALIDATION FOR NEW MOMENT (BASIC INFO) -->
- <script>
-
-
- // Fetch the inputs in the first modal
- let momentTitle = document.querySelector('[name=m_title]');
- let momentDescription = document.querySelector('[name=m_description]');
- let momentDate = document.querySelector('[name=m_date]');
- let momentQuestionnaire = document.querySelector('[name=m_questionnaire]');
-
-
- // Add onchange and onkeyup event listeners to each input in the first modal
- momentTitle.addEventListener('keyup', validateNewMoment);
- momentTitle.addEventListener('change', validateNewMoment);
- momentDescription.addEventListener('keyup', validateNewMoment);
- momentDescription.addEventListener('change', validateNewMoment);
- momentDate.addEventListener('keyup', validateNewMoment);
- momentDate.addEventListener('change', validateNewMoment);
- momentQuestionnaire.addEventListener('keyup', validateNewMoment);
- momentQuestionnaire.addEventListener('change', validateNewMoment);
-
-
-
- // First modal's validation function
- // This basically enables the "Next" button if certain conditions are met
- function validateNewMoment() {
-
- // Fetch "Next" button in modal
- let nextButton = document.querySelector('#nextMoment');
-
- // Check validity of each input (valid if not empty strings & "maxlength" is set)
- let validity = momentTitle.checkValidity();
- validity &= momentDescription.checkValidity();
- validity &= momentDate.checkValidity();
- validity &= momentQuestionnaire.checkValidity();
-
- // Disabled if not valid, enabled otherwise
- nextButton.disabled = !validity;
-
- }
-
-
- </script>
-
-
-
- <!-- POPUP FOR NEW MOMENT 2 -->
- <div class="modal fade" id="NewMoment_2" tabindex="-1" role="dialog" aria-labelledby="NewMomentLabel_2" aria-hidden="true">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
-
- <div class="modal-body">
-
- <!-- CLOSE BUTTON -->
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden='true'>×</span>
- </button>
-
- <div class="row">
- <div class="col-sm-10">
- <h2>New Moment <small>(Questions – <em>Part 2</em>)</small></h2>
- </div>
- </div><!--row-->
-
- <hr><br>
-
- <!-- QUESTION -->
- <div id="qq1" >
-
- <div class="row">
- <div class="col col-sm-offset-1">
- <h4>Question 1</h4>
- </div>
- </div>
-
-
- <!-- CHOOSE QUESTION FROM CORRESPONDING QUESTIONNAIRE -->
- <div class="form-horizontal">
- <div class="form-group">
- <div class='col-sm-offset-2 col-sm-9'>
- <select class="form-control" id="m_question_1" name="m_question_1" style="width:100%; text-align-last:center;" required>
- <option disabled selected value>Select Question</option>
- </select>
- </div>
- </div>
- </div>
-
- </div>
-
-
- <br>
-
- <div class="row">
- <div class="col-sm-offset-9 col-sm-2">
- <button type='button' class='btn btn-xs btn-default' onclick='addSelectableQuestion()'>Add Question</button>
- </div>
- </div>
-
-
-
- <!-- ERROR ALERT FOR USER -->
- <div id="error-newMoment" class="row" style="display: none;">
- <div class="col-sm-12">
- <div class="alert alert-danger mb-1" role="alert">
- <h4 class="error-lead">Error!</h4>
- <p class="error-description"></p>
- </div>
- </div>
- </div>
-
-
-
- </div><!--modal-body-->
-
- <!-- NEXT OR CANCEL -->
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" onclick="nextModal('#NewMoment')">Previous</button>
- <button type="submit" class="btn btn-primary" name="newMoment" <?php if(mysqli_num_rows($result7) == 0) { echo 'disabled'; } ?>>Create</button>
- </div>
-
- </div><!--modal-content-->
- </div><!--modal-dialog-->
- </div><!--modal-->
- </form>
-
-
-
- <!-- POPUP FOR NEW MILESTONE -->
- <form id="newMilestone">
- <div class="modal fade" id="NewMilestone" tabindex="-1" role="dialog" aria-labelledby="NewMilestoneLabel" aria-hidden="true">
- <div class="modal-dialog" role="document"">
- <div class="modal-content">
-
- <div class="modal-body">
-
- <!-- CLOSE BUTTON -->
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
-
- <div class="row">
- <div class="col-sm-10">
- <h2>New Milestone</h2>
- </div>
- </div><!--row-->
-
- <hr><br>
-
-
- <div class="form-horizontal">
-
- <!-- EXPERIENCE ID -->
- <input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>">
-
- <!-- TITLE -->
- <div class="form-group">
- <label class="control-label col-sm-2">Title:</label>
- <div class="col-sm-9">
- <input type="text" class="form-control text-center" name="mil_title" maxlength="256" placeholder="Title" required>
- </div>
- </div>
-
- <!-- DATE -->
- <div class="form-group">
- <label class="control-label col-sm-2">Date:</label>
- <div class="col-sm-9">
- <input type="date" class="form-control text-center" name="mil_date" placeholder="YYYY-MM-DD" required>
- </div>
- </div>
-
- </div>
-
-
- <!-- ERROR ALERT FOR USER -->
- <div id="error-newMilestone" class="row" style="display: none;">
- <div class="col-sm-12">
- <div class="alert alert-danger mb-1" role="alert">
- <h4 class="error-lead">Error!</h4>
- <p class="error-description"></p>
- </div>
- </div>
- </div>
-
-
- </div><!--modal-body-->
-
- <!-- NEXT OR CANCEL -->
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
- <button type="submit" class="btn btn-primary" name="newMilestone">Create</button>
- </div>
-
- </div><!--modal-content-->
- </div><!--modal-dialog-->
- </div><!--modal-->
- </form>
-
-
-
-
- <!-- STORE START DATE FOR CALENDAR RERENDERING LATER -->
- <input id="experience_start_date" type="hidden" value="<?php echo $row1['start_date']; ?>">
-
-
-
- <!-- FULL CALENDAR IMPORTS -->
- <script src="processes/fullcalendar/packages/core/main.min.js"></script>
- <script src="processes/fullcalendar/packages/daygrid/main.min.js"></script>
- <script src="processes/fullcalendar/packages/timegrid/main.min.js"></script>
- <script src="processes/fullcalendar/packages/interaction/main.min.js"></script>
- <!-- <script src="https://unpkg.com/@fullcalendar/core/main.min.js"></script> -->
- <!-- <script src="https://unpkg.com/@fullcalendar/daygrid/main.min.js"></script> -->
- <!-- <script src="https://unpkg.com/@fullcalendar/timegrid@4.3.0/main.min.js"></script> -->
- <!-- <script src="https://unpkg.com/@fullcalendar/interaction@4.3.0/main.min.js"></script> -->
-
-
-
- <script src="js/viewExperience.js"></script>
- <script src="js/handleSubmit.js"></script>
-
- <script>
-
-
- ["editForm", "newQuestionnaire", "newMoment", "newMilestone"].forEach(function(formName) {
-
- var form = document.getElementById(formName);
-
- if(form) {
- form.addEventListener('submit', function(e) {
- handleSubmit(e, formName);
- });
- }
-
- });
-
-
- //window.onload = function() {
-
- // First load an empty calendar
- var calendarElement = document.getElementById('actualCalendar');
- var calendar = new FullCalendar.Calendar(calendarElement, {
- plugins: [ 'dayGrid', 'timeGrid', 'interaction' ],
- header: {
- left: 'prev,next today',
- center: 'title',
- right: 'dayGridMonth,timeGridWeek,timeGridDay'
- },
- defaultDate: document.getElementById('experience_start_date').value,
- businessHours: true,
- editable: true,
- dragScroll: true,
- eventDrop: function(eventDropInfo) {
- $.post(document.location.protocol + "//tania.uprrp.edu/admin_nuevo/special4.php", {
- id: eventDropInfo.event.id,
- experienceID: document.querySelector('input[name=id_experience]').value,
- newStartDate: Date.parse(eventDropInfo.event.start), // convert to UNIX timestamp
- newEndDate: Date.parse(eventDropInfo.event.end) // convert to UNIX timestamp
- }).fail(function() {
- alert('An error occurred! Resetting calendar...');
- eventDropInfo.revert();
- });
- }
- });
- calendar.render();
-
-
- // After the rest of the page has loaded, fetch events from DB & re-render calendar
- var calendarConfig;
-
- $.post(document.location.protocol + "//tania.uprrp.edu/admin_nuevo/special2.php",
- {
- experienceID: document.querySelector('input[name=id_experience]').value
- },
- function(data, status) {
- if(!isJSON(data)) {
- return;
- }
- calendarConfig = JSON.parse(data);
- }
- ).done(function() {
-
- // console.log(calendarConfig);
-
- if(calendarConfig === undefined) {
- alert("Couldn't fetch your events! Please refresh this page. If this keeps ocurring, contact the page administrator.");
- return;
- }
-
- calendarConfig.events.forEach(calendarEvent => {
- calendar.addEvent(calendarEvent);
- });
-
- calendar.render();
-
- }).fail(function() {
- alert("Couldn't fetch your events! Please refresh this page. If this keeps ocurring, contact the page administrator.");
- });
-
-
- //}//domcontentloaded//onload
-
- </script>
-
-
-
- <?php include_once 'footer.php'; ?>
|