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 /****************************************************************/
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 */
28 $sql = "SELECT *, UNIX_TIMESTAMP(start_date) AS us, UNIX_TIMESTAMP(end_date) AS ue
29 FROM ".TABLE_PREFIX."tests
30 WHERE course_id=$_SESSION[course_id]
31 ORDER BY start_date DESC";
32 $result = mysql_query($sql, $db);
33 $num_tests = mysql_num_rows($result);
35 //If there are no tests, don't display anything except a message
37 $msg->addInfo('NO_TESTS');
43 while($row = mysql_fetch_assoc($result))
45 $results[$i]['test_id'] = $row['test_id'];
46 $results[$i]['title'] = $row['title'];
48 if ( ($row['us'] <= time()) && ($row['ue'] >= time() ) ) {
49 $results[$i]['status'] = '<strong>'._AT('ongoing').'</strong>';
50 } else if ($row['ue'] < time() ) {
51 $results[$i]['status'] = '<strong>'._AT('expired').'</strong>';
52 } else if ($row['us'] > time() ) {
53 $results[$i]['status'] = '<strong>'._AT('pending').'</strong>';
56 $startend_date_format=_AT('startend_date_format');
58 $results[$i]['availability'] = AT_date($startend_date_format, $row['start_date'], AT_DATE_MYSQL_DATETIME). ' ' ._AT('to_2').' ';
59 $results[$i]['availability'] .= AT_date($startend_date_format, $row['end_date'], AT_DATE_MYSQL_DATETIME);
62 if ($row['result_release'] == AT_RELEASE_IMMEDIATE)
63 $results[$i]['result_release'] = _AT('release_immediate');
64 else if ($row['result_release'] == AT_RELEASE_MARKED)
65 $results[$i]['result_release'] = _AT('release_marked');
66 else if ($row['result_release'] == AT_RELEASE_NEVER)
67 $results[$i]['result_release'] = _AT('release_never');
69 //get # marked submissions
70 $sql_sub = "SELECT COUNT(*) AS sub_cnt FROM ".TABLE_PREFIX."tests_results WHERE status=1 AND test_id=".$row['test_id'];
71 $result_sub = mysql_query($sql_sub, $db);
72 $row_sub = mysql_fetch_assoc($result_sub);
73 $results[$i]['submissions'] = $row_sub['sub_cnt'].' '._AT('submissions').', ';
76 $sql_sub = "SELECT COUNT(*) AS marked_cnt FROM ".TABLE_PREFIX."tests_results WHERE status=1 AND test_id=".$row['test_id']." AND final_score=''";
77 $result_sub = mysql_query($sql_sub, $db);
78 $row_sub = mysql_fetch_assoc($result_sub);
79 $results[$i]['submissions'] .= $row_sub['marked_cnt'].' '._AT('unmarked');
82 $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'];
83 $result_sub = mysql_query($sql_sub, $db);
84 if (mysql_num_rows($result_sub) == 0) {
85 $results[$i]['assign_to'] = _AT('everyone');
87 $row_sub = mysql_fetch_assoc($result_sub);
88 $results[$i]['assign_to'] = $row_sub['title'];
90 $results[$i]['assign_to'] .= ', '.$row_sub['title'];
91 } while ($row_sub = mysql_fetch_assoc($result_sub));
94 if ($row['passscore'] == 0 && $row['passpercent'] == 0)
95 $results[$i]['pass_score'] = _AT('no_pass_score');
96 else if ($row['passscore'] <> 0)
97 $results[$i]['pass_score'] = $row['passscore'];
98 else if ($row['passpercent'] <> 0)
99 $results[$i]['pass_score'] = $row['passpercent'].'%';
107 <span style="font-weight:bold"><?php echo _AT('about_content_tests'); ?></span>
110 <input type="hidden" name="allow_test_export" id="disallow_test_export" value="0"/>
112 <!-- <div class="row">
113 This option has been commented out for the timebeing until the ability to export and view
114 tests a part of a CP or CP is actually possible
117 //Need radio button 'cause one checkbox makes the states indeterministic
120 $test_export_y_checked = '';
121 $test_export_n_checked = '';
122 if ($_POST['allow_test_export'] == 1){
123 $test_export_y_checked = ' checked="checked"';
125 $test_export_n_checked = ' checked="checked"';
128 echo _AT('allow_test_export');
132 <input type="radio" name="allow_test_export" id="allow_test_export" value="1" <?php //echo $test_export_y_checked; ?>/>
133 <label for="allow_test_export"><?php //echo _AT('yes'); ?></label>
134 <input type="radio" name="allow_test_export" id="disallow_test_export" value="0" <?php //echo $test_export_n_checked; ?>/>
135 <label for="disallow_test_export"><?php //echo _AT('no'); ?></label>
140 <p><?php echo _AT('custom_test_message'); ?></p>
141 <textarea name="test_message"><?php echo $_POST['test_message']; ?></textarea>
144 <?php print_test_table($results, $_POST['tid']);?>
148 $sql = 'SELECT * FROM '.TABLE_PREFIX."content_prerequisites WHERE content_id=$_REQUEST[cid] AND type='".CONTENT_PRE_TEST."'";
149 $result = mysql_query($sql, $db);
150 while ($row = mysql_fetch_assoc($result)) {
151 $_POST['pre_tid'][] = $row['item_id'];
156 <span style="font-weight:bold"><?php echo _AT('define_pretest'); ?></span><br />
157 <small>· <?php echo _AT('about_pretest'); ?></small><br />
158 <?php echo _AT('applies_to_all_sub_pages');?>
161 <?php print_test_table($results, $_POST['pre_tid'], 'pre_');?>
163 <?php function print_test_table($results, $post_tids, $id_prefix='') {?>
165 <table class="data" summary="" style="width: 90%" rules="cols">
168 <th scope="col"> </th>
169 <th scope="col"><?php echo _AT('title'); ?></th>
170 <th scope="col"><?php echo _AT('status'); ?></th>
171 <th scope="col"><?php echo _AT('availability'); ?></th>
172 <th scope="col"><?php echo _AT('result_release'); ?></th>
173 <th scope="col"><?php echo _AT('submissions'); ?></th>
174 <th scope="col"><?php echo _AT('pass_score'); ?></th>
175 <th scope="col"><?php echo _AT('assigned_to'); ?></th>
179 <?php foreach ($results as $row) { ?>
182 if (is_array($post_tids) && in_array($row['test_id'], $post_tids)){
183 $checkMe = ' checked="checked"';
186 <tr onmousedown="toggleTestSelect('<?php echo $id_prefix; ?>r_<?php echo $row['test_id']; ?>');rowselect(this);" id="<?php echo $id_prefix; ?>r_<?php echo $row['test_id']; ?>">
187 <td><input type="checkbox" name="<?php echo $id_prefix; ?>tid[]" value="<?php echo $row['test_id']; ?>" id="<?php echo $id_prefix; ?>t<?php echo $row['test_id']; ?>" <?php echo $checkMe; ?> onmouseup="this.checked=!this.checked" /></td>
188 <td><?php echo $row['title']; ?></td>
189 <td><?php echo $row['status']; ?></td>
190 <td><?php echo $row['availability']; ?></td>
191 <td><?php echo $row['result_release']; ?></td>
192 <td><?php echo $row['submissions']; ?></td>
193 <td><?php echo $row['pass_score']; ?></td>
194 <td><?php echo $row['assign_to']; ?></td>
203 <script language="javascript" type="text/javascript">
204 function toggleTestSelect(r_id){
205 var row = document.getElementById(r_id);
206 var checkBox = row.cells[0].firstChild;
208 if (checkBox.checked == true){
209 checkBox.checked = false;
211 checkBox.checked = true;