/** * @return bool * @param int $step */ public static function isDone($step) { switch ($step) { case 1: return QuestionCtrl::isDone(1); break; case 2: return QuestionCtrl::isDone(3); break; case 3: return QuestionCtrl::isDone(2); break; case 4: return QuestionCtrl::isDone(4); break; } }
//QuestionCtrl::addOption(new Option(2,'Low coupling and Low Cohesion',false)); //QuestionCtrl::addOption(new Option(2,'High coupling and High Cohesion',false)); //QuestionCtrl::addOption(new Option(2,'High Coupling and Low Cohesion',false)); //QuestionCtrl::addOption(new Option(2,'Low Coupling and High Cohesion',true)); //$arr = QuestionCtrl::getQuestionsByCategory(1); // //foreach ($arr as $q) { // echo $q['id']. ' - '. $q['title'] . '<br>'; // $opts = QuestionCtrl::getOptionsByID($q['id']); // // foreach ($opts as $o) { // echo $o['id'] . ' - ' . $o['title'] . ' - ' . $o['isCorrect'] . '<br>'; // } // echo '<br>'; //} $q = QuestionCtrl::get(7); ?> <h2>POST DATA</h2> <pre> <?php echo htmlspecialchars_decode($q->getOpts()[0]->getText()); echo htmlspecialchars_decode($q->getOpts()[1]->getText()); echo htmlspecialchars_decode($q->getOpts()[2]->getText()); echo htmlspecialchars_decode($q->getOpts()[3]->getText()); ?> </pre> <!--<pre>--> <?php //echo htmlspecialchars($_POST['opt4']); ?>
<?php require_once './controller/QuestionCtrl.php'; $pre_chart = QuestionCtrl::getChart(1); $post_chart = QuestionCtrl::getChart(2); ?> <div class="row"> <div class="col-xs-6"> <div class="panel panel-default"> <div class="panel-heading"> Pre Test Results </div> <div class="panel-body"> <div class="text-center"> <canvas id="chart-area-pre"/> </div>Average Result: <span class="label label-<?php echo $pre_chart->getAverageClass(); ?> "> <?php echo $pre_chart->getAverageType(); ?> </span> (<?php echo $pre_chart->getAverage(); ?> %) <hr> <div> <ul class="legend-list list-unstyled list-inline"> <li><span class="leg leg-hd"> </span> HD: <?php
} if ($explain != '') { $q_tmp->setExplain($explain); } $q_tmp->setId($qid); QuestionCtrl::updateQuestion($q_tmp); } } if ($qid > 0) { foreach ($_POST as $key => $value) { $param_name = 'o::'; if (substr($key, 0, strlen($param_name)) == $param_name) { if (strlen($value) > 0) { echo $key . ': ' . $value . '<br>'; $value = htmlspecialchars($value); $ktext = explode('::', $key)[1]; $correct = $ktext == $_POST['correct'] ? 1 : 0; $o = new Option($qid, $value, $correct); if ($type == 'add') { QuestionCtrl::addOption($o); } else { if ($type == 'update') { $o->setId(explode('::', $key)[2]); QuestionCtrl::updateOption($o); } } } } } } echo '<script>window.location.href="admin.php?p=0"</script>';
/** * @return bool * @param int $id */ public static function check($id, $s) { if (QuestionCtrl::has($id)) { return QuestionCtrl::get($id)->checkRs($s); } else { return false; } }
} $ok = ''; } } $submit = 'Save'; $text = 'added'; $text_css = 'success'; $title = 'New Question'; if (isset($_GET['id']) && $_GET['id'] != '') { $id = $_GET['id']; $link = '&id=' . $id; $text = 'updated'; $text_css = 'info'; $submit = 'Update'; $title = 'Update Question'; $q = QuestionCtrl::get($id); } ?> <form action="admin.php?p=10<?php echo $link; ?> " method="post" enctype="multipart/form-data" onsubmit="return postForm()"> <input type="hidden" name="ques_id" value="<?php echo $id; ?> "/> <h2 class="page-header"><?php echo $title; ?> </h2>
/** * Created by PhpStorm. * User: JayDz * Date: 15/07/15 * Time: 2:54 PM */ require_once './controller/QuestionCtrl.php'; $uid = $_COOKIE['uid']; //echo $uid; $b = false; if (isset($_POST['c']) && $_POST['c'] != '') { $c = $_POST['c']; $answers = new Answers($uid, $c); foreach ($_POST as $key => $value) { $param_name = 'ans::'; if (substr($key, 0, strlen($param_name)) == $param_name) { $ques = explode('ans::', $key)[1]; $ans = explode('_', $value)[1]; $ktext = explode('_', $value)[2]; $answers->addAns(new Answer($ques, $ans . '_' . $ktext)); $b = true; } } } if ($b) { QuestionCtrl::submitTest($answers); echo 'okkkk'; } else { echo '<script>window.location.href="index.php"</script>'; }
<h4><a href="admin.php?p=10&c=2"><span class="glyphicon glyphicon-plus"></span> New Question</a></h4> </div> </h1> <div class="table-responsiv"> <table cellpadding="0" cellspacing="0" border="0" class="datatable-1 table table-bordered table-striped display"> <thead> <tr> <th>#</th> <th>Question</th> <th>Point</th> <th>Action</th> </tr> </thead> <tbody> <?php foreach (QuestionCtrl::getQuestionsByCategory(2) as $key => $q) { ?> <tr> <td style="text-align: center"><?php echo $key + 1; ?> </td> <td><?php echo $q->getShortTitle(); ?> </td> <td><?php echo $q->getPoint(); ?> </td> <td style="text-align: center">
if (<?php echo $q; ?> == <?php echo QuestionCtrl::size(); ?> ) ssubmit = ' view overall results'; $('#submit').click(function () { if ($('.bt-text').html() == ssubmit) { if (<?php echo $q + 1; ?> > <?php echo QuestionCtrl::size(); ?> ) window.location.href = 'index.php?p=0'; // later move to overall page else window.location.href = 'index.php?p=1&q=<?php echo $q + 1; ?> '; } else { if ($('#selected').val() == '') { $('#submit').addClass('btn-warning').removeClass('btn-primary').removeClass('btn-danger').removeClass('btn-success'); $('.bt-icon').addClass('glyphicon-warning-sign').removeClass('glyphicon-send'); $('.bt-text').html(' select something!'); } else {
" name="correct" data-toggle="tooltip" data-placement="top" title="is this the correct answer?" <?php echo $opt->isCorrectText(); ?> > Option <?php echo QuestionCtrl::getKText($index); ?> </label> <div class="col-sm-11"> <div class="question-input"><?php echo html_entity_decode($opt->getText()); ?> </div> <input type="hidden" name="o::<?php echo QuestionCtrl::getKText($index); ?> ::<?php echo $opt->getId(); ?> " /> </div> </div> <?php } ?> <div class="form-group"> <label for="explain" class="col-sm-1 control-label">Explain</label> <div class="col-sm-11"> <div class="question-input"><?php echo html_entity_decode($q->getExplain());
<?php require_once './controller/QuestionCtrl.php'; $c = 1; if (isset($_GET['c']) && $_GET['c'] != '') { $c = $_GET['c']; if ($c != 1 && $c != 2) { $c = 1; } } $question_arr = QuestionCtrl::getQuestionsByCategory($c); function getKText($opt) { switch ($opt) { case 0: return 'A'; break; case 1: return 'B'; break; case 2: return 'C'; break; case 3: return 'D'; break; } } $type = 'Pre-Test'; if ($c == 2) { $type = 'Post-Test';
<?php /** * Created by PhpStorm. * User: JayDz * Date: 10/07/15 * Time: 12:02 AM */ require_once './controller/QuestionCtrl.php'; require_once './controller/UserCtrl.php'; if (!UserCtrl::isDone(2)) { $uid = $_COOKIE['uid']; QuestionCtrl::submitTest(new Answers($uid, 3)); } ?> <div class="clear-top hidden-xs"></div> <div class="container"> <div class="jumbotron"> <h2>Congrats!</h2> <p>Let's do some questions to see how better you are now xD.</p> <p><a class="btn btn-primary btn-lg" href="index.php?p=1&c=2" role="button"> <span class="glyphicon glyphicon-chevron-right"></span> Do post-test</a></p> </div> </div>
</h1> <div class="table-responsiv"> <table cellpadding="0" cellspacing="0" border="0" class="datatable-1 table table-bordered table-striped display"> <thead> <tr> <th>#</th> <th>Question</th> <th>Point</th> <th>Category</th> <th>Action</th> </tr> </thead> <tbody> <?php foreach (QuestionCtrl::getAll() as $key => $q) { ?> <tr> <td style="text-align: center"><?php echo $key + 1; ?> </td> <td><?php echo $q->getShortTitle(); ?> </td> <td><?php echo $q->getPoint(); ?> </td> <td><?php
if ($arr[$ques]->getKtext() == QuestionCtrl::getKText($opt)) { if ($done4) { $type = $arr[$ques]->getRes(); } else { $type = 'info'; } } else { $type = 'default'; } ?> <div class="answer-view alert alert-<?php echo $type; ?> "> <span class="key"><?php echo QuestionCtrl::getKText($opt); ?> .</span><?php echo htmlspecialchars_decode($o->getText()); ?> </div> <?php } ?> <!-- --><?php //if ($done4) : ?> <!-- <hr>--> <!-- <blockquote>--> <!-- --><?php //if (!$selected) :