`date_taken` TIMESTAMP NOT NULL,
`final_score` char(5) NOT NULL default '',
`status` TINYINT NOT NULL DEFAULT '0',
+ `end_time` TIMESTAMP NOT NULL ,
PRIMARY KEY (`result_id`),
KEY `test_id` (`test_id`)
) TYPE=MyISAM;
## refresh test issue - #2362
ALTER TABLE `tests_questions_assoc` DROP INDEX `test_id`;
ALTER TABLE `tests_results` ADD `status` TINYINT NOT NULL DEFAULT '0';
-UPDATE TABLE `tests_results` SET status=1;
+UPDATE TABLE `tests_results` SET status=1, date_taken=date_taken;
+
+## times tests - #3084
+ALTER TABLE `tests_results` ADD `end_time` TIMESTAMP NOT NULL ;
+UPDATE TABLE `tests_results` SET date_taken=date_taken, end_time=date_taken;
<tr>
<th scope="col"><?php echo _AT('title'); ?></th>
<th scope="col"><?php echo _AT('date_taken'); ?></th>
+ <th scope="col"><?php echo _AT('time_spent'); ?></th>
<th scope="col"><?php echo _AT('mark'); ?></th>
<th scope="col"><?php echo _AT('submission'); ?></th>
</tr>
</thead>
<tbody>
<?php
-$sql = "SELECT T.*, R.* FROM ".TABLE_PREFIX."tests T, ".TABLE_PREFIX."tests_results R, ".TABLE_PREFIX."tests_questions_assoc Q WHERE R.status=1 AND Q.test_id=T.test_id AND R.member_id=$_SESSION[member_id] AND R.test_id=T.test_id AND T.course_id=$_SESSION[course_id] GROUP BY R.result_id ORDER BY R.date_taken DESC";
+
+
+$sql = "SELECT T.*, R.*, (R.end_time - R.date_taken) AS diff FROM ".TABLE_PREFIX."tests T, ".TABLE_PREFIX."tests_results R, ".TABLE_PREFIX."tests_questions_assoc Q WHERE R.status=1 AND Q.test_id=T.test_id AND R.member_id=$_SESSION[member_id] AND R.test_id=T.test_id AND T.course_id=$_SESSION[course_id] GROUP BY R.result_id ORDER BY R.date_taken DESC";
$result = mysql_query($sql, $db);
$num_results = mysql_num_rows($result);
do {
echo '<tr>';
echo '<td><strong>'.AT_print($row['title'], 'tests.title').'</strong></td>';
- echo '<td>'.$row['date_taken'].'</td>';
+ echo '<td>'.substr($row['date_taken'], 0, -3).'</td>';
+ echo '<td>'.get_human_time($row['diff']).'</td>';
echo '<td>';
if ($row['out_of'] == 0) {
$row = mysql_fetch_assoc($result);
$result_id = $row['result_id'];
} else {
- $sql = "INSERT INTO ".TABLE_PREFIX."tests_results VALUES (NULL, $tid, 0, NOW(), '', 0)";
+ $sql = "INSERT INTO ".TABLE_PREFIX."tests_results VALUES (NULL, $tid, 0, NOW(), '', 0, NOW())";
$result = mysql_query($sql, $db);
$result_id = mysql_insert_id($db);
}
// update the final score
// update status to complate to fix refresh test issue.
- $sql = "UPDATE ".TABLE_PREFIX."tests_results SET final_score=$final_score, date_taken=date_taken, status=1 WHERE result_id=$result_id AND member_id=$_SESSION[member_id]";
+ $sql = "UPDATE ".TABLE_PREFIX."tests_results SET final_score=$final_score, date_taken=date_taken, status=1, end_time=NOW() WHERE result_id=$result_id AND member_id=$_SESSION[member_id]";
$result = mysql_query($sql, $db);
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
require(AT_INCLUDE_PATH.'header.inc.php');
/* Retrieve the content_id of this test */
-$num_questions = $test_row['num_questions'];
+$num_questions = $test_row['num_questions'];
$content_id = $test_row['content_id'];
$anonymous = $test_row['anonymous'];
$instructions = $test_row['instructions'];
// save $questions with no response, and set status to 'in progress' in test_results <---
if ($_SESSION['member_id'] && !$in_progress) {
- $sql = "INSERT INTO ".TABLE_PREFIX."tests_results VALUES (NULL, $tid, $_SESSION[member_id], NOW(), '', 0)";
+ $sql = "INSERT INTO ".TABLE_PREFIX."tests_results VALUES (NULL, $tid, $_SESSION[member_id], NOW(), '', 0, NOW())";
$result = mysql_query($sql, $db);
$result_id = mysql_insert_id($db);
}
}
$orders = array('asc' => 'desc', 'desc' => 'asc');
-$cols = array('login' => 1, 'full_name' => 1, 'date_taken' => 1, 'fs' => 1);
+$cols = array('login' => 1, 'full_name' => 1, 'date_taken' => 1, 'fs' => 1, 'time_spent' => 1);
if (isset($_GET['asc'])) {
$order = 'asc';
//get results based on filtre and sorting
if ($anonymous == 1) {
- $sql = "SELECT R.*, '<em>"._AT('anonymous')."</em>' AS login FROM ".TABLE_PREFIX."tests_results R WHERE R.test_id=$tid AND R.status=1 $status ORDER BY $col $order";
+ $sql = "SELECT R.*, (R.end_time - R.date_taken) AS time_spent, '<em>"._AT('anonymous')."</em>' AS login FROM ".TABLE_PREFIX."tests_results R WHERE R.test_id=$tid AND R.status=1 $status ORDER BY $col $order";
} else {
- $sql = "SELECT R.*, login, CONCAT(first_name, ' ', second_name, ' ', last_name) AS full_name, R.final_score+0.0 AS fs FROM ".TABLE_PREFIX."tests_results R LEFT JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE R.test_id=$tid AND R.status=1 $status ORDER BY $col $order, R.final_score $order";
+ $sql = "SELECT R.*, login, (R.end_time - R.date_taken) AS time_spent, CONCAT(first_name, ' ', second_name, ' ', last_name) AS full_name, R.final_score+0.0 AS fs FROM ".TABLE_PREFIX."tests_results R LEFT JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE R.test_id=$tid AND R.status=1 $status ORDER BY $col $order, R.final_score $order";
}
$result = mysql_query($sql, $db);
<?php if ($col == 'login'): ?>
<col />
<col class="sort" />
- <col span="3" />
+ <col span="4" />
<?php elseif ($col == 'full_name'): ?>
<col span="2" />
<col class="sort" />
- <col span="2" />
+ <col span="3" />
<?php elseif($col == 'date_taken'): ?>
<col span="3" />
<col class="sort" />
+ <col span="2" />
+ <?php elseif($col == 'time_spent'): ?>
+ <col span="4" />
+ <col class="sort" />
<col span="1" />
<?php elseif($col == 'fs'): ?>
- <col span="4" />
+ <col span="5" />
<col class="sort" />
<?php endif; ?>
</colgroup>
<th scope="col"><a href="tools/tests/results.php?tid=<?php echo $tid.$page_string.SEP.$orders[$order]; ?>=login"><?php echo _AT('login_name'); ?></a></th>
<th scope="col"><a href="tools/tests/results.php?tid=<?php echo $tid.$page_string.SEP.$orders[$order]; ?>=full_name"><?php echo _AT('full_name'); ?></a></th>
<th scope="col"><a href="tools/tests/results.php?tid=<?php echo $tid.$page_string.SEP.$orders[$order]; ?>=date_taken"><?php echo _AT('date_taken'); ?></a></th>
+ <th scope="col"><a href="tools/tests/results.php?tid=<?php echo $tid.$page_string.SEP.$orders[$order]; ?>=time_spent"><?php echo _AT('time_spent'); ?></a></th>
<th scope="col"><a href="tools/tests/results.php?tid=<?php echo $tid.$page_string.SEP.$orders[$order]; ?>=fs"><?php echo _AT('mark'); ?></a></th>
</tr>
</thead>
<td><label for="r<?php echo $row['result_id']; ?>"><?php echo $row['login']; ?></label></td>
<td><?php echo $row['full_name']; ?></td>
<td><?php echo AT_date('%j/%n/%y %G:%i', $row['date_taken'], AT_DATE_MYSQL_DATETIME); ?></td>
+ <td><?php echo get_human_time($row['time_spent']); ?></td>
+
<td align="center">
<?php if ($out_of) {
if ($random) {
}
}
- $sql = "UPDATE ".TABLE_PREFIX."tests_results SET final_score='$final_score', date_taken=date_taken WHERE result_id=$rid AND status=1";
+ $sql = "UPDATE ".TABLE_PREFIX."tests_results SET final_score='$final_score', date_taken=date_taken, end_time=end_time WHERE result_id=$rid AND status=1";
$result = mysql_query($sql, $db);
$msg->addFeedback('RESULTS_UPDATED');