Esempio n. 1
0
function start()
{
    $tno = $_GET['tno'];
    $questions = array();
    include '../dao/QuestionDaoImpl.php';
    $questionDao = new QuestionDaoImpl();
    include '../dao/TestDaoImpl.php';
    $testDao = new testDaoImpl();
    include '../dao/TtoqDaoImpl.php';
    $ttoqDao = new TtoqDaoImpl();
    $test = $testDao->get($tno);
    $ttoqs = $ttoqDao->queryByCondition($tno);
    foreach ($ttoqs as $ttoq) {
        $questions = array_merge($questions, array($questionDao->get($ttoq['qno'])));
    }
    session_start();
    $_SESSION['test'] = $test;
    $_SESSION['questions'] = $questions;
    header('Location: /student/testinfo.php');
}
Esempio n. 2
0
function insert()
{
    $tno = $_POST['tno'];
    $subject = $_POST['subject'];
    $tid = $_POST['tid'];
    $quantity = $_POST['quantity'];
    $difficulty = $_POST['difficulty'];
    $total = $_POST['total'];
    $qnos = $_POST['qnos'];
    $qnos = explode('@', $qnos);
    include '../dao/TestDaoImpl.php';
    $testDao = new TestDaoImpl();
    include '../dao/TtoqDaoImpl.php';
    $ttoqDao = new TtoqDaoImpl();
    $result = $testDao->insert($tno, $subject, $tid, $quantity, $difficulty, $total);
    $tests = $testDao->queryAll();
    for ($i = 0; $i < count($qnos); $i++) {
        $result = $ttoqDao->insert($tno, $i + 1, $qnos[$i]);
    }
    session_start();
    $_SESSION['tests'] = $tests;
    $_SESSION['tno'] = $tno;
    header('Location: /teacher/test.php');
}