<?php // Description: DISPLAY THE USER'S QUESTIONNAIRES echo "This page is no longer in use."; exit(); exit(); exit(); exit(); exit(); require_once 'processes/config.php'; require_once 'processes/dbh.inc.php'; require_once 'processes/checkLogin.php'; include_once 'header.php'; // WARNING: CHANGE QUERY TO INCLUDE "`id_researcher`='".$dbUserData['id_researcher']."';" if($_SESSION['dbUserData']['admin'] === '1') { $query1 = "SELECT * FROM `questionnair`;"; } else { $query1 = "SELECT * FROM `questionnair` WHERE id IN (SELECT id_questionnair FROM experience_questionnair WHERE id_experience IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "'));"; } $result1 = mysqli_query($connection, $query1); ?> <!-- START OF questionnaires.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' style="margin-top: 8rem; min-height: calc(100vh - 8rem - 10vh);"> <div class='row'> <div class='col-sm-8'> <h2>Questionnaires</h2> <p>View, add, and delete any questionnaire you like so that, later on, you can associate them to an experience.</p> </div> <br><br> <div class='col-sm-4 btn-group'> <button type='button' class='btn btn-default' data-toggle='modal' data-target='#Import'>Import</button> <button type='button' class='btn btn-default' data-toggle='modal' data-target='#Duplicate'>Duplicate</button> <button type='button' class='btn btn-default' data-toggle='modal' data-target='#New' disabled>Create</button> </div> </div><!--row--> <div class='row'><div class='col'><br><hr><br></div></div> <?php if($result1->num_rows > 0): ?> <div class='row'> <div class='col-sm-12'> <table class='table table-hover table-striped'> <thead> <tr> <th><h4>Title</h4></th> <th><h4>Description</h4></th> <th><h4>Corresp. Experience</h4></th> </tr> </thead> <tbody> <?php while($row1 = mysqli_fetch_array($result1)): ?> <tr style="cursor: pointer;" onclick="location='viewQuestionnaire.php?view=<?php echo $row1['id']; ?>'"> <td><?php echo $row1['q_title']; ?></td> <td><?php echo $row1['description']; ?></td> <?php $queryExperience = "SELECT title FROM experience WHERE id = (SELECT id_experience FROM experience_questionnair WHERE id_questionnair = '" . $row1['id'] . "')"; $resultExperience = mysqli_query($connection, $queryExperience) or die("Error: Couldn't fetch experience info<br>".mysqli_error($connection)); $rowExperience = mysqli_fetch_assoc($resultExperience); ?> <td style="width: 14em;"><?php echo $rowExperience['title']; ?></td> </tr> <?php endwhile; ?> </tbody> </table> </div><!--col--> </div><!--row--> <?php else: ?> <div class='row'> <div class='col text-center'> <h3><small>It seems you still don't have questionnaires...</small></h3> </div><!--col--> </div><!--row--> <?php endif; ?> <br><br><br> </div><!--container--> <!-- 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"> <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 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-12 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><!--col--> </div> </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> <select class="form-control text-center" id="fromQuestionnaireID" name="fromQuestionnaireID" style="text-align-last:center;" required> <?php $result1 = mysqli_query($connection, $query1); while($row1 = mysqli_fetch_assoc($result1)): $queryExtra = "SELECT title FROM `experience` WHERE id = (SELECT id_experience FROM experience_questionnair WHERE id_questionnair = '" . $row1['id'] . "');"; $resultExtra = mysqli_query($connection, $queryExtra); $rowExtra = mysqli_fetch_assoc($resultExtra); ?> <option value="<?php echo $row1['id']; ?>"><?php echo $row1['q_title']; ?> – from <?php echo $rowExtra['title']; ?></option> <?php endwhile; ?> </select> <br> <!-- TO EXPERIENCE --> <label for="toExperienceID">To What Experience:</label> <select class="form-control text-center" id="toExperienceID" name="toExperienceID" style="text-align-last:center;" required> <?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); while($rowExperience2 = mysqli_fetch_assoc($resultExperience2)): ?> <option value="<?php echo $rowExperience2['id']; ?>"><?php echo $rowExperience2['title']; ?></option> <?php endwhile; ?> </select> </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'>Confirm</button> </div> </div><!--modal-content--> </div><!--modal-dialog--> </div><!--modal--> </form> <!-- END OF questionnaires.php --> <?php include_once 'footer.php'; ?>