2 /****************************************************************************/
4 /****************************************************************************/
5 /* Copyright (c) 2002-2007 by Greg Gay, Joel Kronenberg & Heidi Hazelton */
6 /* Adaptive Technology Resource Centre / University of Toronto */
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 /****************************************************************************/
14 define('AT_INCLUDE_PATH', '../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 authenticate(AT_PRIV_TESTS);
18 $tid = intval($_REQUEST['tid']);
21 if (isset($_GET['delete'], $_GET['id'])) {
22 header('Location:delete_result.php?tid='.$tid.SEP.'rid='.$_GET['id']);
24 } else if (isset($_GET['edit'], $_GET['id'])) {
25 header('Location:view_results.php?tid='.$tid.SEP.'rid='.$_GET['id']);
27 } else if (isset($_GET['edit']) && !$_GET['id'] && !$_GET['asc'] && !$_GET['desc'] && !$_GET['filter'] && !$_GET['reset_filter']) {
28 $msg->addError('NO_ITEM_SELECTED');
31 require(AT_INCLUDE_PATH.'lib/test_result_functions.inc.php');
33 if ($_GET['reset_filter']) {
37 $orders = array('asc' => 'desc', 'desc' => 'asc');
38 $cols = array('login' => 1, 'full_name' => 1, 'date_taken' => 1, 'fs' => 1);
40 if (isset($_GET['asc'])) {
42 $col = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'login';
43 } else if (isset($_GET['desc'])) {
45 $col = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'login';
52 require(AT_INCLUDE_PATH.'header.inc.php');
54 if (isset($_GET['status']) && ($_GET['status'] != '') && ($_GET['status'] != 2)) {
55 if ($_GET['status'] == 0) {
56 $status = " AND R.final_score=''";
58 $status = " AND R.final_score<>''";
60 $page_string .= SEP.'status='.$_GET['status'];
66 $sql = "SELECT out_of, anonymous, random, title FROM ".TABLE_PREFIX."tests WHERE test_id=$tid AND course_id=$_SESSION[course_id]";
67 $result = mysql_query($sql, $db);
68 if (!($row = mysql_fetch_array($result))){
69 $msg->printErrors('ITEM_NOT_FOUND');
70 require (AT_INCLUDE_PATH.'footer.inc.php');
73 $out_of = $row['out_of'];
74 $anonymous = $row['anonymous'];
75 $random = $row['random'];
78 $sql = "SELECT count(*) as cnt FROM ".TABLE_PREFIX."tests_results R LEFT JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE R.test_id=$tid";
79 $result = mysql_query($sql, $db);
80 $row = mysql_fetch_array($result);
81 $num_sub = $row['cnt'];
83 //get results based on filtre and sorting
84 if ($anonymous == 1) {
85 $sql = "SELECT R.*, '<em>"._AT('anonymous')."</em>' AS login FROM ".TABLE_PREFIX."tests_results R WHERE R.test_id=$tid $status ORDER BY $col $order";
87 $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 $status ORDER BY $col $order, R.final_score $order";
90 $result = mysql_query($sql, $db);
91 if ($anonymous == 1) {
92 $guest_text = '<em>'._AT('anonymous').'</em>';
94 $guest_text = '- '._AT('guest').' -';
96 while ($row = mysql_fetch_assoc($result)) {
97 $row['full_name'] = $row['full_name'] ? $row['full_name'] : $guest_text;
98 $row['login'] = $row['login'] ? $row['login'] : $guest_text;
99 $rows[$row['result_id']] = $row;
102 $num_results = mysql_num_rows($result);
104 //count unmarked: no need to do this query if filtre is already getting unmarked
105 if (isset($_GET['status']) && ($_GET['status'] != '') && ($_GET['status'] == 0)) {
106 $num_unmarked = $num_results;
108 $sql = "SELECT count(*) as cnt FROM ".TABLE_PREFIX."tests_results R, ".TABLE_PREFIX."members M WHERE R.test_id=$tid AND R.member_id=M.member_id AND R.final_score=''";
109 $result = mysql_query($sql, $db);
110 $row = mysql_fetch_array($result);
111 $num_unmarked = $row['cnt'];
115 <h3><?php echo AT_print($row['title'], 'tests.title'); ?></h3><br />
117 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
118 <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
120 <div class="input-form">
122 <h3><?php echo _AT('results_found', $num_results); ?></h3>
126 <?php echo _AT('status'); ?><br />
127 <input type="radio" name="status" value="1" id="s0" <?php if ($_GET['status'] == 1) { echo 'checked="checked"'; } ?> /><label for="s0"><?php echo _AT('marked_label', $num_sub - $num_unmarked); ?></label>
129 <input type="radio" name="status" value="0" id="s1" <?php if ($_GET['status'] == 0) { echo 'checked="checked"'; } ?> /><label for="s1"><?php echo _AT('unmarked_label', $num_unmarked); ?></label>
131 <input type="radio" name="status" value="2" id="s2" <?php if (!isset($_GET['status']) || ($_GET['status'] != 0 && $_GET['status'] != 1)) { echo 'checked="checked"'; } ?> /><label for="s2"><?php echo _AT('all_label', $num_sub); ?></label>
135 <div class="row buttons">
136 <input type="submit" name="filter" value="<?php echo _AT('filter'); ?>" />
137 <input type="submit" name="reset_filter" value="<?php echo _AT('reset_filter'); ?>" />
142 <form name="form" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
143 <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
145 <table class="data" summary="" rules="cols">
147 <?php if ($col == 'login'): ?>
151 <?php elseif ($col == 'full_name'): ?>
155 <?php elseif($col == 'date_taken'): ?>
159 <?php elseif($col == 'fs'): ?>
166 <th scope="col" width="1%"> </th>
167 <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>
168 <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>
169 <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>
170 <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>
175 <td colspan="6"><input type="submit" name="edit" value="<?php echo _AT('view_mark_test'); ?>" /> <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /></td>
180 <?php foreach ($rows as $row): ?>
181 <tr onmousedown="document.form['r<?php echo $row['result_id']; ?>'].checked = true;rowselect(this);" id="r_<?php echo $row['result_id']; ?>">
182 <td><input type="radio" name="id" value="<?php echo $row['result_id']; ?>" id="r<?php echo $row['result_id']; ?>" /></td>
183 <td><label for="r<?php echo $row['result_id']; ?>"><?php echo $row['login']; ?></label></td>
184 <td><?php echo $row['full_name']; ?></td>
185 <td><?php echo AT_date('%j/%n/%y %G:%i', $row['date_taken'], AT_DATE_MYSQL_DATETIME); ?></td>
189 $out_of = get_random_outof($tid, $row['result_id']);
192 if ($row['final_score'] != '') {
193 echo $row['final_score'].'/'.$out_of;
195 echo _AT('unmarked');
206 <td colspan="4"><?php echo _AT('none_found'); ?></td>
212 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>