public function testing() { if (!isset($_SESSION["autorised"])) { header('Location: ' . $_SESSION['base_url'] . '/home'); } $test_id = $_POST['theme']; $_SESSION['test_id'] = $test_id; include_once "/../models/model_test.php"; $tests = get_question($test_id); $_SESSION['test_time'] = time(); include_once "/../pages/testing.php"; }
function write_question_details() { $question = ""; $correct = ""; $distractor1 = ""; $distractor2 = ""; $distractor3 = ""; $type = "Add"; $url = "managequestion.php"; if (isset($_GET['question_id'])) { connect(); $id = $_GET['question_id']; $question_record = get_question($id); $question = $question_record['Question']; $correct = $question_record['CorrectAnswer']; $distractor1 = $question_record['Distractor1']; $distractor2 = $question_record['Distractor2']; $distractor3 = $question_record['Distractor3']; $type = "Edit"; $url .= "?question_id=" . $id; } echo "<form name = 'add_question_form' method = 'post' action = '" . $url . "'>\r\n\t\t\tQuestion <br/>\r\n\t\t\t<textarea rows = '4' cols = '50' name = 'question'>" . $question . "</textarea>\r\n\t\t\t<br/>\r\n\t\t\tCorrect Answer <br/>\r\n\t\t\t<textarea cols = '50' name = 'correct'>" . $correct . "</textarea>\r\n\t\t\t<br/>\r\n\t\t\tDistractor 1 <br/>\r\n\t\t\t<textarea cols = '50' name = 'distractor1'>" . $distractor1 . "</textarea>\r\n\t\t\t<br/>\r\n\t\t\tDistractor 2 <br/>\r\n\t\t\t<textarea cols = '50' name = 'distractor2'>" . $distractor2 . "</textarea>\r\n\t\t\t<br/>\r\n\t\t\tDistractor 3 <br/>\r\n\t\t\t<textarea cols = '50' name = 'distractor3'>" . $distractor3 . "</textarea>\r\n\t\t\t<br/>\r\n\t\t\t<input type = 'submit' name = 'submit_question' value = '" . $type . "'>\r\n\t\t</form>\r\n\t\t"; }
<?php session_start(); $nb_steps = get_steps(); /* Token generation and initialization of the current step */ if (empty($_SESSION['step'])) { $_SESSION['step'] = 1; $_SESSION["token"] = generate_random_string(); } else { if ($_SESSION['step'] > $nb_steps) { $_SESSION['step'] = 1; $_SESSION["token"] = generate_random_string(); } } /* If some datas have been submited, we go to the next step */ if (!empty($_POST) && $_SESSION['step'] <= $nb_steps) { $id_answer = trim($_POST["id_answer"]); $token = $_SESSION["token"]; $step = $_SESSION["step"]; if (check_answer($id_answer, $step)) { $_SESSION["step"]++; add_user_answer($token, $id_answer); if ($_SESSION['step'] > $nb_steps) { header("Location:result.php"); } } } $progress = $_SESSION['step'] / $nb_steps * 100; $question = get_question($_SESSION['step']); $answers = get_answers($_SESSION['step']);
<?php require_once 'Slim/Slim.php'; require_once 'library.php'; \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(); $app->response->headers->set('Content-Type', 'application/json'); $app->post('/alerts', function () use($app, $db) { $post = json_decode($app->request->getBody(), true); echo json_encode(post_alerts($post, $db)); })->name('post_alert'); $app->get('/questions/:id', function ($id) use($app, $db) { echo json_encode(get_question($id, $db)); })->name('get.question'); $app->post('/assoc_alert_question/:id_alert/:id_question', function ($id_alert, $id_question) use($app, $db) { $post = json_decode($app->request->getBody(), true); echo json_encode(post_assoc_alert_question($id_alert, $id_question, $post, $db)); })->name('post.assoc_alert_question'); $app->run();
Xin chào <a href="#"><?php echo $username; ?> </a>(<span id="marks" class="marks"></span>) | <a href="index.php">Trang chủ</a> | <a href="logout.php">Đăng xuất</a> </span> </header> <div id="content"> <?php echo '<div id="exercise-pane"></div>'; if ($exerid == 0) { echo '<h2>Tập viết chương trình</h2>'; } else { $question = get_question($exerid); echo '<h2>Bài số ' . $exerid . '</h2>'; echo '<p class="question">' . $question . '</p>'; } ?> <div id="left"> <table class="large"> <tr> <td> <textarea name="code" id="code"> <?php echo get_code($exerid, $username); ?> </textarea> </td> </tr>
<?php // in this we will include the files of functions and check if the user is instructor // we will assume the user is logged in //include('includes/functions.php'); //dbconnect("localhost", "quizuser", "quiz", "quiz"); include "layout/adminheader.php"; $question_id = $_GET['quid']; $row = get_question($question_id); $choices = get_choices($question_id); $array_of_choices = array(); $choices_id = array(); while ($rows = mysqli_fetch_assoc($choices)) { array_push($array_of_choices, $rows['content']); array_push($choices_id, $rows['id']); } //print_r($array_of_choices[]); // in add press the data will be saved and send to database if (isset($_POST['update'])) { // save it to database with the current quiz id // unset($_SESSION['question_error']); $content = $_POST['content']; $correct = $_POST['correct_answer']; $choice_1 = $_POST['choice_1']; $choice_2 = $_POST['choice_2']; $choice_3 = $_POST['choice_3']; $choice_4 = $_POST['choice_4']; //$choices=array(); //print_r($_POST); if ($correct == 1) { $correct = $choice_1;
<?php require 'includes/connect.php'; require 'includes/utils.php'; $question = $_REQUEST['question']; $data = get_question($question); do_output(true, $data);
<?php session_start(); $_GET['pagename'] = 'list'; include "setting.php"; if (!isset($_GET['id']) || !isset($_SESSION['id']) || !isset($_SESSION['ipaddress'])) { gotoindex(); } check_login(); if (!is_numeric($_GET['id'])) { exit(0); } include "header.php"; $id = $_GET['id']; $q_result = get_question($id); $c_result = get_choices($id); if ($q_result == false || $c_result == false) { print "診断が存在しません。"; exit(0); } else { $question = pg_fetch_assoc($q_result, 0); $dt = date("Y-m-d H:i:s", strtotime($question['date'])); print "診断:{$question['content']}<br>"; print "作成日時:{$dt}<br><br>"; print "質問:{$question['question']}<br><br>"; $num = pg_num_rows($c_result); for ($i = 0; $i < $num; $i++) { $choice = pg_fetch_assoc($c_result, $i); print "<button onclick=\"location.href='answer.php?id={$id}&ans={$choice['id']}'\">" . $choice['choice'] . "</button><br><br>"; } }