/** * @return Survey[] */ public static function getSurveys() { $db = DB::getConn(); $stm = $db->prepare('select * from Survey'); $stm->execute(); $rss = $stm->fetchAll(); $arr = []; foreach ($rss as $rs) { if ($rs['show'] == 1) { $q = new Survey($rs['title'], 1); $q->setId($rs['id']); $q->setPercent(SurveyCtrl::getPercent($rs['id'])); $q->setCount(SurveyCtrl::getVotedNumber($rs['id'])); $arr[] = $q; } } return $arr; }
<?php /** * Created by PhpStorm. * User: JayDz * Date: 15/07/15 * Time: 2:54 PM */ require_once './controller/SurveyCtrl.php'; require_once './model/Survey.php'; //echo '<br><br><br><br>'; foreach ($_POST as $key => $value) { // echo $key.': '.$value.'<br>'; if ($key == 'id') { $title = $_POST['title']; $show = $_POST['show'] == 'on' ? 1 : 0; $s = new Survey($title); $s->setShow($show); $s->setId($value); SurveyCtrl::update($s); echo 'okkkk'; } }
<?php /** * Created by PhpStorm. * User: JayDz * Date: 10/07/15 * Time: 12:31 AM */ require_once './controller/SurveyCtrl.php'; $arr = SurveyCtrl::getSurveys(); ?> <div class="clear-top hidden-xs"></div> <div class="container"> <ol class="breadcrumb" style="margin-bottom: 40px;"> <li><a href="index.php">Home</a></li> <li class="active">Survey</li> </ol> <form action="index.php?p=15" method="post"> <input type="hidden" name="p" value="15"> <?php foreach ($arr as $index => $s) { ?> <h4><span class="label label-warning pull-left">Question <?php echo $index + 1; ?> of <?php echo count($arr); ?> </span></h4><br/> <div class="panel panel-default"> <div class="panel-body">
<?php /** * Created by PhpStorm. * User: JayDz * Date: 15/07/15 * Time: 2:54 PM */ require_once './controller/SurveyCtrl.php'; require_once './model/Survey.php'; //echo '<br><br><br><br>'; foreach ($_POST as $key => $value) { if ($key == 'title') { SurveyCtrl::add($value); echo 'okkkk'; } }
<?php /** * Created by PhpStorm. * User: JayDz * Date: 15/07/15 * Time: 2:54 PM */ require_once './controller/SurveyCtrl.php'; require_once './model/Survey.php'; //echo '<br><br><br><br>'; foreach ($_GET as $key => $value) { // echo $key .': '.$value.'<br>'; if ($key == 'id') { SurveyCtrl::remove($value); // echo 'okkkk'; } } ?> <script> window.location.href = 'admin.php?p=2'; </script>
*/ require_once './controller/QuestionCtrl.php'; require_once './controller/SurveyCtrl.php'; require_once './controller/UserCtrl.php'; $uid = $_COOKIE['uid']; foreach ($_POST as $key => $value) { $param_name = 'r::'; if (substr($key, 0, strlen($param_name)) == $param_name) { $sid = explode('::', $key)[1]; if (isset($_POST['c::' . $sid]) && $_POST['c::' . $sid] != '') { $comment = $_POST['c::' . $sid]; } else { $comment = ''; } $vote = new Vote($sid, $uid, $value, $comment); SurveyCtrl::vote($vote); } } if (!UserCtrl::isDone(4)) { QuestionCtrl::submitTest(new Answers($uid, 4)); } ?> <div class="clear-top hidden-xs"></div> <div class="container"> <div class="jumbotron"> <h2>Thanks a lot xD</h2> <p>You can finally check your results now.</p> <p><a class="btn btn-primary btn-lg" href="index.php?p=5" role="button"> <span class="glyphicon glyphicon-chevron-right"></span> View Results</a> </p>
<?php require_once './controller/SurveyCtrl.php'; $arr = SurveyCtrl::getSurveyList(); ?> <ol class="breadcrumb"> <li><a href="admin.php">Admin CP</a></li> <li class="active">Survey</li> </ol> <h1 class="page-header">Survey Questions <!-- Button trigger modal --> <button type="button" class="btn btn-primary btn" data-toggle="modal" data-target="#new-question"> <span class="glyphicon glyphicon-plus"></span> New Question</a> </button> </h1> <!-- Modal --> <form id="new-survey-form" action="admin.php" method="post"> <input type="hidden" name="p" value="13"> <div class="modal fade" id="new-question" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-body"> <label>Title</label> <input id="new-question" name="title" type="text" class="form-control" placeholder="required"> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button id="submit-form" type="button" class="btn btn-primary">Add</button> </div> </div>