예제 #1
0
require_once '../includes/config.php';
require_once '../includes/session.php';
require_once '../includes/functions.php';
if (isset($_GET["test_name"])) {
    $test_name = $_GET["test_name"];
    $query = "Select * from " . TESTS_TABLE . " where test_name='{$test_name}'";
    $result = $db->query_database($query);
    if ($result != NULL) {
        if ($db->number_of_rows($result) > 0) {
            $row = $db->fetch_array($result);
            //$test_start_unix_timestamp = strtotime($row["start_time"]);
            //$test_end_unix_timestamp = strtotime($row["end_time"]);
            //$current_unix_timestamp = strtotime("now");
            //$current_unix_timestamp = strtotime(date('Y-m-d H:i:s') ) + 4 * 60 * 60 + 30*60 ;
            //if($current_unix_timestamp >= $test_start_unix_timestamp && $current_unix_timestamp <= $test_end_unix_timestamp ){
            set_test_name($test_name);
            set_test_duration($row["duration"]);
            redirect_to("../user/user_registration.php");
            //}else if($current_unix_timestamp < $test_start_unix_timestamp){
            //	set_error_message(TEST_NOT_STARTED);
            //	redirect_to("error.php");
            //}else if($current_unix_timestamp > $test_end_unix_timestamp){
            //	set_error_message(TEST_HAS_ENDED);
            //	redirect_to("error.php");
            //}
        } else {
            set_error_message(TEST_NAME_NOT_FOUND);
            redirect_to("error.php");
        }
    } else {
        set_error_message(TEST_NAME_NOT_FOUND);
예제 #2
0
<?php

require_once '../includes/db_connect.php';
require_once '../includes/functions.php';
require_once '../includes/session.php';
$db = new DB_CONNECT();
confirm_logged_in();
// get username from the session
$username = get_username();
$decode_url = urldecode($_GET['test_name']);
set_test_name($decode_url);
//select all test created by him from test table
$query = "SELECT * FROM " . $decode_url . "_questions";
$users_table = $db->query_database($query);
if ($db->number_of_rows($users_table) > 0) {
    $i = 1;
    while ($row = $db->fetch_array($users_table)) {
        $table_data = array();
        $table_data_array[$i] = array();
        $table_data["question_id"] = $row["id"];
        $table_data["question"] = $row["question"];
        $table_data["option1"] = $row["option1"];
        $table_data["option2"] = $row["option2"];
        $table_data["option3"] = $row["option3"];
        $table_data["option4"] = $row["option4"];
        $table_data["correct_ans"] = $row["correct_ans"];
        $table_data["marks"] = $row["marks"];
        $table_data["negative_marks"] = $row["negative_marks"];
        $table_data_array[$i] = $table_data;
        $i++;
    }