2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay & Harris Wong */
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 /****************************************************************/
13 // $Id: tests.inc.php 7208 2008-01-09 16:07:24Z harris $
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
18 /* Get the list of associated tests with this content on page load */
20 $_REQUEST['cid'] = intval($_REQUEST['cid']); //uses request 'cause after 'saved', the cid will become $_GET.
21 $sql = 'SELECT * FROM '.TABLE_PREFIX."content_tests_assoc WHERE content_id=$_REQUEST[cid]";
22 $result = mysql_query($sql, $db);
23 while ($row = mysql_fetch_assoc($result)) {
24 $_POST['tid'][] = $row['test_id'];
27 /* get a list of all the tests we have, and links to create, edit, delete, preview */
29 $sql = "SELECT *, UNIX_TIMESTAMP(start_date) AS us, UNIX_TIMESTAMP(end_date) AS ue FROM ".TABLE_PREFIX."tests WHERE course_id=$_SESSION[course_id] ORDER BY start_date DESC";
30 $result = mysql_query($sql, $db);
31 $num_tests = mysql_num_rows($result);
33 //If there are no tests, don't display anything except a message
35 $msg->addInfo('NO_TESTS');
43 <p><?php echo _AT('about_content_tests'); ?></p>
49 //Need radio button 'cause one checkbox makes the states indeterministic
51 $test_export_y_checked = '';
52 $test_export_n_checked = '';
53 if ($_POST['allow_test_export'] == 1){
54 $test_export_y_checked = ' checked="checked"';
56 $test_export_n_checked = ' checked="checked"';
59 echo _AT('allow_test_export');
62 <input type="radio" name="allow_test_export" id="allow_test_export" value="1" <?php echo $test_export_y_checked; ?>/>
63 <label for="allow_test_export"><?php echo _AT('yes'); ?></label>
64 <input type="radio" name="allow_test_export" id="disallow_test_export" value="0" <?php echo $test_export_n_checked; ?>/>
65 <label for="disallow_test_export"><?php echo _AT('no'); ?></label>
70 <p><?php echo _AT('custom_test_message'); ?></p>
71 <textarea name="test_message"><?php echo $_POST['test_message']; ?></textarea>
74 <table class="data" summary="" style="width: 90%" rules="cols">
77 <th scope="col"> </th>
78 <th scope="col"><?php echo _AT('title'); ?></th>
79 <th scope="col"><?php echo _AT('status'); ?></th>
80 <th scope="col"><?php echo _AT('availability'); ?></th>
81 <th scope="col"><?php echo _AT('result_release'); ?></th>
82 <th scope="col"><?php echo _AT('submissions'); ?></th>
83 <th scope="col"><?php echo _AT('assigned_to'); ?></th>
87 <?php while ($row = mysql_fetch_assoc($result)) : ?>
90 if (is_array($_POST['tid']) && in_array($row['test_id'], $_POST['tid'])){
91 $checkMe = ' checked="checked"';
94 <script language="javascript" type="text/javascript">
95 function toggleTestSelect(r_id){
96 var row = document.getElementById(r_id);
97 var checkBox = row.cells[0].firstChild;
99 if (checkBox.checked == true){
100 checkBox.checked = false;
102 checkBox.checked = true;
106 <tr onmousedown="toggleTestSelect('r_<?php echo $row['test_id']; ?>');rowselect(this);" id="r_<?php echo $row['test_id']; ?>">
107 <td><input type="checkbox" name="tid[]" value="<?php echo $row['test_id']; ?>" id="t<?php echo $row['test_id']; ?>" <?php echo $checkMe; ?>/></td>
108 <td><?php echo $row['title']; ?></td>
110 if ( ($row['us'] <= time()) && ($row['ue'] >= time() ) ) {
111 echo '<em>'._AT('ongoing').'</em>';
112 } else if ($row['ue'] < time() ) {
113 echo '<em>'._AT('expired').'</em>';
114 } else if ($row['us'] > time() ) {
115 echo '<em>'._AT('pending').'</em>';
117 <td><?php $startend_date_format=_AT('startend_date_format');
119 echo AT_date($startend_date_format, $row['start_date'], AT_DATE_MYSQL_DATETIME). ' ' ._AT('to_2').' ';
120 echo AT_date($startend_date_format, $row['end_date'], AT_DATE_MYSQL_DATETIME); ?></td>
123 if ($row['result_release'] == AT_RELEASE_IMMEDIATE) {
124 echo _AT('release_immediate');
125 } else if ($row['result_release'] == AT_RELEASE_MARKED) {
126 echo _AT('release_marked');
127 } else if ($row['result_release'] == AT_RELEASE_NEVER) {
128 echo _AT('release_never');
132 //get # marked submissions
133 $sql_sub = "SELECT COUNT(*) AS sub_cnt FROM ".TABLE_PREFIX."tests_results WHERE status=1 AND test_id=".$row['test_id'];
134 $result_sub = mysql_query($sql_sub, $db);
135 $row_sub = mysql_fetch_assoc($result_sub);
136 echo $row_sub['sub_cnt'].' '._AT('submissions').', ';
139 $sql_sub = "SELECT COUNT(*) AS marked_cnt FROM ".TABLE_PREFIX."tests_results WHERE status=1 AND test_id=".$row['test_id']." AND final_score=''";
140 $result_sub = mysql_query($sql_sub, $db);
141 $row_sub = mysql_fetch_assoc($result_sub);
142 echo $row_sub['marked_cnt'].' '._AT('unmarked');
146 //get assigned groups
147 $sql_sub = "SELECT G.title FROM ".TABLE_PREFIX."groups G INNER JOIN ".TABLE_PREFIX."tests_groups T USING (group_id) WHERE T.test_id=".$row['test_id'];
148 $result_sub = mysql_query($sql_sub, $db);
149 if (mysql_num_rows($result_sub) == 0) {
150 echo _AT('everyone');
152 $row_sub = mysql_fetch_assoc($result_sub);
153 echo $row_sub['title'];
155 echo ', '.$row_sub['title'];
156 } while ($row_sub = mysql_fetch_assoc($result_sub));