Esempio n. 1
0
    if (array_key_exists('show', $_POST)) {
        DoStartQuestion(false, false);
    } else {
        DoStartQuestion(true, false);
    }
    die;
}
if ($action == 'starttimer') {
    OnStartTimer();
    die;
}
if ($action == 'gradeanswers') {
    OnGradeAnswers();
    die;
}
ShowAnswers();
function ShowAnswers()
{
    global $CFG;
    $selecthitid = "(SELECT MAX(id) FROM {$CFG->prefix}hits h WHERE h.userid=u.id AND kind=0)";
    $query = "SELECT u.id, u.name, (SELECT answer FROM {$CFG->prefix}hits WHERE id={$selecthitid}) as answer" . " FROM {$CFG->prefix}users u" . " ORDER BY username";
    $result = mysql_query($query);
    echo '<table border=1>';
    while ($row = mysql_fetch_assoc($result)) {
        echo '<tr>';
        echo '<td>' . $row['username'] . '</td>';
        echo '<td>' . $row['name'] . '</td>';
        echo '<td>' . $row['answer'] . '</td>';
        echo '</tr>';
    }
    echo '</table>';
Esempio n. 2
0
function LoadATest()
{
    global $mysqli;
    $crntest = $_SESSION['crntest'];
    //$curquest = $_SESSION['curquest'];
    $qids = array();
    $question_array = array();
    $temparray = array();
    $sql = "SELECT * FROM st_tests INNER JOIN ST_questions ON st_tests.test_id = st_questions.question_test  WHERE test_id ='{$crntest}'   LIMIT 1";
    //get query
    if ($result = mysqli_query($mysqli, $sql)) {
        //if result not empty
        echo $crntest;
        $uid = $_SESSION['uid'];
        $curtest = $_SESSION['crntest'];
        $pos = 0;
        $temparray = array();
        $question_array = array();
        while ($row = mysqli_fetch_object($result)) {
            echo $_SESSION['qcount'] = $row->test_question_count;
            echo $question_alt_video = $row->question_alt_video;
            $question = $row->question_question;
            $_SESSION['question'] = $question;
            $answer = $row->question_answer;
            $videourl = $row->question_video;
            $_SESSION['videourl'] = $videourl;
            $_SESSION["altvideourl"] = $row->question_alt_video;
            $_SESSION["question_alt_video"] = $row->question_alt_video;
            $weight = $row->question_weight;
            $occ = $row->question_occ;
            $test = $row->question_test;
            $quest_num = $row->question_test_num;
            $quest_correct = $row->question_correct;
            $_SESSION['question_correct'] = $quest_correct;
            $battingsidenum = $row->question_battingside;
            $quest_correct = $row->question_correct;
            $question_order = $row->test_question_order;
        }
        echo 'Batting Side: ' . $_SESSION['mybattingside'] . '<br/>';
        $question = $_SESSION['question'];
        $videourl = $_SESSION['videourl'];
        ShowAnswers();
        echo ' <h2>' . $question . '</h2> ';
        echo '<div class="responsive">';
        echo '
<video width="600" height="400" id="video" style="max-width:100%; position:absolute; top:0px;left:0px;" autoplay >
<source src="' . $videourl . '" type="video/mp4">
</video></div><div id="answers" style="visibility:visible;"></div>';
        if (isset($_SESSION['curquestarray'])) {
            $question_array = $_SESSION['curquestarray'];
            if (empty($question_array)) {
                TestEnd();
            }
            $_SESSION['questionid'] = $question_array[0];
            $_SESSION['curquest'] = $question_array[0];
            $_SESSION['curquestarray'] = substr($_SESSION['curquestarray'], 1);
        } else {
            if (!isset($_SESSION['curquestarray'])) {
                $question_array = $question_order;
                $_SESSION['questionid'] = $question_array[0];
                $_SESSION['curquest'] = $question_array[0];
                $_SESSION['curquestarray'] = substr($question_array, 1);
            }
        }
        echo "     \n    <script>\n\$(function(){\n\nvar video = \$('video')[0];\nvar answers = \$('answers')[0];\n\nvideo.addEventListener('playing', function(){\n\$('PLAY').fadeOut();\n\n\n})\nvideo.addEventListener('pause', function(){\n\$('STOP').fadeOut();\nvideo.style.visibility='hidden';    \n\n\n})\n\n})\n</script>  ";
    }
}