Example #1
0
<HEAD>
	<title>OES Admin - Sample Database</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</HEAD>

<?php 
$db = new Database(DB_HOST, DB_USER, DB_PASS);
$db->selectDatabase(DB_NAME);
if (isset($_POST['submit'])) {
    $db->begin();
    try {
        /* Exam */
        $db->insertRandomExam();
        /* Question and Choice */
        $txtGen = new TXTGen();
        $subjects = $db->getColumn('ID', 'oes_Subject');
        foreach ($subjects as $subject) {
            for ($i = 0; $i < 100; ++$i) {
                $question = $txtGen->randParagraph(mt_rand(1, 6));
                $rank = mt_rand() / mt_getrandmax();
                $type = mt_rand(0, 2);
                switch ($type) {
                    case 0:
                        // single choice
                        $questionID = $db->insertQuestion($question, $subject, 'true', $rank);
                        $n = mt_rand(3, 5);
                        $c = mt_rand(0, $n - 1);
                        for ($j = 0; $j < $n; ++$j) {
                            $choice = $txtGen->randSentence();
                            $db->insertChoice($questionID, $choice, $j == $c ? 'true' : 'false', 'true');
                        }