2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 require(AT_INCLUDE_PATH.'../mods/_standard/tests/lib/test_result_functions.inc.php');
19 require(AT_INCLUDE_PATH.'header.inc.php');
21 $sql = "SELECT T.*, UNIX_TIMESTAMP(T.start_date) AS us, UNIX_TIMESTAMP(T.end_date) AS ue, COUNT(Q.weight) AS numquestions FROM ".TABLE_PREFIX."tests T, ".TABLE_PREFIX."tests_questions_assoc Q WHERE Q.test_id=T.test_id AND T.course_id=$_SESSION[course_id] GROUP BY T.test_id ORDER BY T.start_date, T.title";
22 $result = mysql_query($sql, $db);
25 <table class="data static" summary="" rules="cols">
28 <th scope="col"><?php echo _AT('title'); ?></th>
29 <th scope="col"><?php echo _AT('status'); ?></th>
30 <th scope="col"><?php echo _AT('start_date'); ?></th>
31 <th scope="col"><?php echo _AT('end_date'); ?></th>
32 <th scope="col"><?php echo _AT('attempts'); ?></th>
39 while ($row = mysql_fetch_assoc($result)) {
40 // this code hides tests from the user if they are not enrolled.
41 if (!$row['guests'] && !authenticate_test($row['test_id'])) {
48 $sql = "SELECT COUNT(test_id) AS cnt FROM ".TABLE_PREFIX."tests_results WHERE status=1 AND test_id=".$row['test_id']." AND member_id='".$_SESSION['member_id']."'";
50 $takes_result= mysql_query($sql, $db);
51 $takes = mysql_fetch_assoc($takes_result);
52 if ( ($row['us'] <= time() && $row['ue'] >= time()) &&
53 ( ($row['num_takes'] == AT_TESTS_TAKE_UNLIMITED) || ($takes['cnt'] < $row['num_takes']) ) ) {
54 echo '<strong><a href="'.url_rewrite('mods/_standard/tests/test_intro.php?tid='.$row['test_id']).'">'.AT_print($row['title'], 'tests.title').'</a></strong>';
56 echo '<small class="bigspacer">'.AT_print($row['title'], 'tests.title').'';
59 if ( ($row['us'] <= time()) && ($row['ue'] >= time() ) ) {
60 echo '<strong>'._AT('ongoing').'</strong>';
61 } else if ($row['ue'] < time() ) {
62 echo '<strong>'._AT('expired').'</strong>';
63 } else if ($row['us'] > time() ) {
64 echo '<strong>'._AT('pending').'</strong>';
67 $startend_date_long_format=_AT('startend_date_long_format');
70 echo '<td>'.AT_date($startend_date_long_format, $row['start_date']).'</td>';
71 echo '<td>'.AT_date($startend_date_long_format, $row['end_date']).'</td>';
73 if ($row['num_takes'] == AT_TESTS_TAKE_UNLIMITED) {
74 echo '<td>'.$takes['cnt'].'/'._AT('unlimited').'</td>';
76 echo '<td>'.$takes['cnt'].'/'.$row['num_takes'].'</td>';
81 echo '<td>'.$row['num_questions'].'</td>';
82 echo '<td>'.$row['out_of'].'</td>';
84 echo '<td>'.$row['numquestions'].'</td>';
85 if ($row['out_of'] > 0) {
86 echo '<td>'.$row['out_of'].'</td>';
88 echo '<td><em>'._AT('na').'</em></td>';
96 echo '<tr><td colspan="7">'._AT('none_found').'</td></tr>';
103 <?php if (!$_SESSION['enroll']): ?>
104 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>
107 <h4><?php echo _AT('completed_tests'); ?></h4><br />
108 <table class="data static" summary="" rules="cols">
111 <th scope="col"><?php echo _AT('title'); ?></th>
112 <th scope="col"><?php echo _AT('date_taken'); ?></th>
113 <th scope="col"><?php echo _AT('time_spent'); ?></th>
114 <th scope="col"><?php echo _AT('mark'); ?></th>
115 <th scope="col"><?php echo _AT('submission'); ?></th>
122 $sql = "SELECT T.*, R.*, (UNIX_TIMESTAMP(R.end_time) - UNIX_TIMESTAMP(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";
124 $result = mysql_query($sql, $db);
125 $num_results = mysql_num_rows($result);
127 if ($row = mysql_fetch_assoc($result)) {
132 echo '<td><strong>'.AT_print($row['title'], 'tests.title').'</strong></td>';
133 echo '<td>'.AT_date($startend_date_long_format, $row['date_taken']).'</td>';
134 echo '<td>'.get_human_time($row['diff']).'</td>';
137 if ($row['out_of'] == 0) {
139 } elseif ($row['final_score'] == '') {
140 echo _AT('unmarked');
141 } elseif (($row['final_score'] != '') && ($row['result_release']==AT_RELEASE_NEVER)) {
142 echo _AT('unreleased');
144 if ($row['random']) {
145 $out_of = get_random_outof($row['test_id'], $row['result_id']);
147 $out_of = $row['out_of'];
150 echo '<strong>'.$row['final_score'].'</strong>/'.$out_of;
156 if ( ($row['result_release']==AT_RELEASE_IMMEDIATE) || (($row['final_score'] != '') && ($row['result_release']==AT_RELEASE_MARKED)) ) {
157 echo '<a href="mods/_standard/tests/view_results.php?tid='.$row['test_id'].SEP.'rid='.$row['result_id'].'">'._AT('view_results').'</a>';
159 echo '<strong>'._AT('no_results_yet').'</strong>';
164 } while ($row = mysql_fetch_assoc($result));
166 echo '<tr><td colspan="4">'._AT('none_found').'</td></tr>';
173 $_SESSION['last_visited_page'] = $server_protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
174 require(AT_INCLUDE_PATH.'footer.inc.php');