function createTest($student, $exam, $subject, $noq) { $subject = num_value($subject); $test = $this->insertTest($student, $exam); $result = $this->query("select ID from oes_Question" . " where Subject = {$subject} order by rand() limit {$noq}"); $questions = fetch_column($result); mysql_free_result($result); foreach ($questions as $question) { $this->insertTQ($test, $question); } return $test; }
return -1; } } $_SESSION['test'] = $test; header('Location: question.php'); return; } ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript" src="../ptajax/module.js"></script> <link href="test.css" rel="stylesheet" type="text/css"> </head> <?php $class = $db->getValue("select Class from oes_Student where ID={$student}"); $class = num_value($class); $result = $db->query("select\n\t\t\t\tE.ID as ID,\n\t\t\t\tE.Name as Name,\n\t\t\t\toes_Subject.Name as Subject,\n\t\t\t\tTime,\n\t\t\t\t(select TimeSpent from oes_Test where Exam = E.ID and Student = {$student}) as TimeSpent,\n\t\t\t\tDuration,\n\t\t\t\t(select count(distinct ID) from oes_Answer join oes_TQ on ID = TQ\n\t\t\t\t\t\twhere Test =\n\t\t\t\t\t\t(select ID from oes_Test where Exam = E.ID and Student = {$student}))\n\t\t\t\t\t\tas Done,\n\t\t\t\tNoQ\n\t\t\tfrom (select * from oes_Exam where Class = {$class}\n\t\t\t\t\tand StartTime is not null and EndTime is null) as E\n\t\t\t\tjoin oes_Subject on E.Subject = oes_Subject.ID"); if (mysql_num_rows($result) == 0) { echo '<center>Không có buổi thi nào cho bạn.</center>'; mysql_free_result($result); return; } echo '<h2>Chọn môn thi</h2>'; echo '<table class=examtable cellspacing="0"><tr>'; echo '<th>Tên<th>Môn<th>Lần<th>Đã dùng<th>Đã làm'; $c = 0; while ($row = mysql_fetch_array($result)) { $ex = $row['ID']; $style = $c++ & 1 ? 'class=alt' : null; echo "<tr {$style} onClick='window.location=\"test.php?eid={$ex}\"'>"; echo '<td>' . $row['Name'];