http://atutor.ca/atutor/mantis/view.php?id=3084
authorjoel kronenberg <joel.kronenberg@utoronto.ca>
Mon, 9 Jul 2007 16:50:52 +0000 (16:50 -0000)
committerjoel kronenberg <joel.kronenberg@utoronto.ca>
Mon, 9 Jul 2007 16:50:52 +0000 (16:50 -0000)
docs/install/db/atutor_schema.sql
docs/install/db/atutor_upgrade_1.5.4_to_1.5.5.sql
docs/tools/my_tests.php
docs/tools/take_test.php
docs/tools/tests/results.php
docs/tools/tests/view_results.php

index f118873..97e76b2 100644 (file)
@@ -883,6 +883,7 @@ CREATE TABLE `tests_results` (
   `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;
index cfc9908..ed16f3e 100644 (file)
@@ -9,4 +9,8 @@ ALTER TABLE `forums_threads` DROP `login`;
 ## 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;
index fd78eaa..8f51ee8 100644 (file)
@@ -107,13 +107,16 @@ if (!$count) {
 <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);
@@ -124,7 +127,8 @@ if ($row = mysql_fetch_assoc($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) {
index 6865b40..bd1f611 100644 (file)
@@ -59,7 +59,7 @@ if (isset($_POST['submit'])) {
                $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);
        }
@@ -87,7 +87,7 @@ if (isset($_POST['submit'])) {
 
        // 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');
@@ -108,7 +108,7 @@ if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
 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'];
@@ -178,7 +178,7 @@ if ($test_row['random']) {
 
 // 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);
 }
index abdfbb0..933c764 100644 (file)
@@ -35,7 +35,7 @@ if ($_GET['reset_filter']) {
 }
 
 $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';
@@ -82,9 +82,9 @@ $num_sub = $row['cnt'];
 
 //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);
@@ -147,17 +147,21 @@ if (isset($_GET['status']) && ($_GET['status'] != '') && ($_GET['status'] == 0))
        <?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>
@@ -167,6 +171,7 @@ if (isset($_GET['status']) && ($_GET['status'] != '') && ($_GET['status'] == 0))
        <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>
@@ -183,6 +188,8 @@ if (isset($_GET['status']) && ($_GET['status'] != '') && ($_GET['status'] == 0))
                        <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) {
index 8952bef..e7c49a0 100644 (file)
@@ -53,7 +53,7 @@ if ($_POST['cancel']) {
                }
        }
 
-       $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');