2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 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 /************************************************************************/
16 define('AT_INCLUDE_PATH', '../../include/');
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 authenticate(AT_PRIV_TESTS);
20 if (isset($_GET['edit'], $_GET['id'])) {
21 header('Location: edit_test.php?tid='.$_GET['id']);
23 } else if (isset($_GET['preview'], $_GET['id'])) {
24 header('Location: preview.php?tid='.$_GET['id']);
26 } else if (isset($_GET['questions'], $_GET['id'])) {
27 header('Location: questions.php?tid='.$_GET['id']);
29 } else if (isset($_GET['submissions'], $_GET['id'])) {
30 header('Location: results.php?tid='.$_GET['id']);
32 } else if (isset($_GET['statistics'], $_GET['id'])) {
33 header('Location: results_all_quest.php?tid='.$_GET['id']);
35 } else if (isset($_GET['delete'], $_GET['id'])) {
36 header('Location: delete_test.php?tid='.$_GET['id']);
38 } else if (isset($_GET['export'], $_GET['id'])){
39 header('Location: export_test.php?tid='.$_GET['id']);
40 } else if (isset($_GET['edit'])
41 || isset($_GET['preview'])
42 || isset($_GET['questions'])
43 || isset($_GET['submissions'])
44 || isset($_GET['statistics'])
45 || isset($_GET['delete'])
46 || isset($_GET['export'])) {
48 $msg->addError('NO_ITEM_SELECTED');
51 require(AT_INCLUDE_PATH.'header.inc.php');
54 /* get a list of all the tests we have, and links to create, edit, delete, preview */
56 $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";
57 $result = mysql_query($sql, $db);
58 $num_tests = mysql_num_rows($result);
62 <form method="post" action="<?php echo 'tools/tests/import_test.php'; ?>" enctype="multipart/form-data" >
63 <div class="input-form" style="width: 40%">
64 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('import_test'); ?></legend>
66 <label for="to_file"><?php echo _AT('upload_test'); ?></label><br />
67 <input type="file" name="file" id="to_file" />
70 <div class="row buttons">
71 <input type="submit" name="submit_import" value="<?php echo _AT('import'); ?>" />
77 <form name="form" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
78 <table class="data" summary="" style="width: 90%" rules="cols">
81 <th scope="col"> </th>
82 <th scope="col"><?php echo _AT('title'); ?></th>
83 <th scope="col"><?php echo _AT('status'); ?></th>
84 <th scope="col"><?php echo _AT('availability'); ?></th>
85 <th scope="col"><?php echo _AT('result_release'); ?></th>
86 <th scope="col"><?php echo _AT('submissions'); ?></th>
87 <th scope="col"><?php echo _AT('assigned_to'); ?></th>
91 <?php if ($num_tests): ?>
95 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />
96 <input type="submit" name="preview" value="<?php echo _AT('preview'); ?>" />
97 <input type="submit" name="questions" value="<?php echo _AT('questions'); ?>" />
101 <td colspan="7" style="padding-left:38px;">
102 <input type="submit" name="submissions" value="<?php echo _AT('submissions'); ?>" />
103 <input type="submit" name="statistics" value="<?php echo _AT('statistics'); ?>" />
104 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />
105 <input type="submit" name="export" value="<?php echo _AT('export'); ?>" />
111 <?php while ($row = mysql_fetch_assoc($result)) : ?>
112 <tr onmousedown="document.form['t<?php echo $row['test_id']; ?>'].checked = true;rowselect(this);" id="r_<?php echo $row['test_id']; ?>">
113 <td><input type="radio" name="id" value="<?php echo $row['test_id']; ?>" id="t<?php echo $row['test_id']; ?>" /></td>
114 <td><label for="t<?php echo $row['test_id']; ?>"><?php echo $row['title']; ?></label></td>
116 if ( ($row['us'] <= time()) && ($row['ue'] >= time() ) ) {
117 echo '<em>'._AT('ongoing').'</em>';
118 } else if ($row['ue'] < time() ) {
119 echo '<em>'._AT('expired').'</em>';
120 } else if ($row['us'] > time() ) {
121 echo '<em>'._AT('pending').'</em>';
123 <td><?php $startend_date_format=_AT('startend_date_format');
125 echo AT_date($startend_date_format, $row['start_date'], AT_DATE_MYSQL_DATETIME). ' ' ._AT('to_2').' ';
126 echo AT_date($startend_date_format, $row['end_date'], AT_DATE_MYSQL_DATETIME); ?></td>
129 if ($row['result_release'] == AT_RELEASE_IMMEDIATE) {
130 echo _AT('release_immediate');
131 } else if ($row['result_release'] == AT_RELEASE_MARKED) {
132 echo _AT('release_marked');
133 } else if ($row['result_release'] == AT_RELEASE_NEVER) {
134 echo _AT('release_never');
138 //get # marked submissions
139 $sql_sub = "SELECT COUNT(*) AS sub_cnt FROM ".TABLE_PREFIX."tests_results WHERE status=1 AND test_id=".$row['test_id'];
140 $result_sub = mysql_query($sql_sub, $db);
141 $row_sub = mysql_fetch_assoc($result_sub);
142 echo $row_sub['sub_cnt'].' '._AT('submissions').', ';
145 $sql_sub = "SELECT COUNT(*) AS marked_cnt FROM ".TABLE_PREFIX."tests_results WHERE status=1 AND test_id=".$row['test_id']." AND final_score=''";
146 $result_sub = mysql_query($sql_sub, $db);
147 $row_sub = mysql_fetch_assoc($result_sub);
148 echo $row_sub['marked_cnt'].' '._AT('unmarked');
152 //get assigned groups
153 $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'];
154 $result_sub = mysql_query($sql_sub, $db);
155 if (mysql_num_rows($result_sub) == 0) {
156 echo _AT('everyone');
158 $assigned_groups = '';
159 while ($row_sub = mysql_fetch_assoc($result_sub)) {
160 $assigned_groups .= $row_sub['title'].', ';
162 echo substr($assigned_groups, 0, -2);
171 <td colspan="7"><?php echo _AT('none_found'); ?></td>
178 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>