remove old readme
[atutor.git] / mods / _standard / gradebook / gradebook_tests.php
1 <?php\r
2 /************************************************************************/\r
3 /* ATutor                                                                                                                               */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2002-2010                                              */\r
6 /* Inclusive Design Institute                                           */\r
7 /* http://atutor.ca                                                                                                             */\r
8 /*                                                                                                                                              */\r
9 /* This program is free software. You can redistribute it and/or        */\r
10 /* modify it under the terms of the GNU General Public License          */\r
11 /* as published by the Free Software Foundation.                        */\r
12 /************************************************************************/\r
13 // $Id$\r
14 \r
15 $page = 'gradebook';\r
16 \r
17 define('AT_INCLUDE_PATH', '../../../include/');\r
18 require (AT_INCLUDE_PATH.'vitals.inc.php');\r
19 authenticate(AT_PRIV_GRADEBOOK);\r
20 \r
21 if (isset($_POST['remove'], $_POST['gradebook_test_id'])) \r
22 {\r
23         header('Location: gradebook_delete_tests.php?gradebook_test_id='.$_POST['gradebook_test_id']);\r
24         exit;\r
25\r
26 else if (isset($_POST['edit'], $_POST['gradebook_test_id'])) \r
27 {\r
28         header('Location: gradebook_edit_tests.php?gradebook_test_id='.$_POST['gradebook_test_id']);\r
29         exit;\r
30\r
31 else if (!empty($_POST) && !isset($_POST['gradebook_test_id'])) {\r
32         $msg->addError('NO_ITEM_SELECTED');\r
33 }\r
34 \r
35 require(AT_INCLUDE_PATH.'header.inc.php'); \r
36 \r
37 ?>\r
38 \r
39 <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">\r
40 \r
41 <table summary="" class="data" rules="cols" align="center" style="width: 90%;">\r
42 \r
43 <thead>\r
44 <tr>\r
45         <th scope="col">&nbsp;</th>\r
46         <th scope="col"><?php echo _AT('name'); ?></th>\r
47         <th scope="col"><?php echo _AT('grade_scale'); ?></th>\r
48         <th scope="col"><?php echo _AT('type'); ?></th>\r
49 </tr>\r
50 </thead>\r
51 <tfoot>\r
52 <tr>\r
53         <td colspan="5">\r
54                 <div class="row buttons">\r
55                 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /> \r
56                 <input type="submit" name="remove" value="<?php echo _AT('remove'); ?>" /> \r
57                 </div>\r
58         </td>\r
59 </tr>\r
60 </tfoot>\r
61 <tbody>\r
62 <?php\r
63 \r
64 $sql = "(SELECT g.gradebook_test_id, type, t.title, grade_scale_id".\r
65                                 " FROM ".TABLE_PREFIX."gradebook_tests g, ".TABLE_PREFIX."tests t".\r
66                                 " WHERE g.type='ATutor Test'".\r
67                                 " AND g.id = t.test_id".\r
68                                 " AND t.course_id=".$_SESSION["course_id"].")".\r
69                                 " UNION (SELECT g.gradebook_test_id, g.type, a.title, grade_scale_id".\r
70                                 " FROM ".TABLE_PREFIX."gradebook_tests g, ".TABLE_PREFIX."assignments a".\r
71                                 " WHERE g.type='ATutor Assignment'".\r
72                                 " AND g.id = a.assignment_id".\r
73                                 " AND a.course_id=".$_SESSION["course_id"].")".\r
74                                 " UNION (SELECT gradebook_test_id, type, title, grade_scale_id".\r
75                                 " FROM ".TABLE_PREFIX."gradebook_tests".\r
76                                 " WHERE course_id=".$_SESSION["course_id"].")".\r
77                                 " ORDER BY type, title";\r
78 $result = mysql_query($sql, $db) or die(mysql_error());\r
79 \r
80 if (mysql_num_rows($result) == 0)\r
81 {\r
82 ?>\r
83         <tr>\r
84                 <td colspan="5"><?php echo _AT('none_found'); ?></td>\r
85         </tr>\r
86 <?php \r
87 }\r
88 else\r
89 {\r
90         // Initialize scale content array\r
91         $scale_content[0] = _AT("raw_final_score");\r
92         $sql_scale_ids = "SELECT grade_scale_id from ".TABLE_PREFIX."grade_scales g";\r
93         $result_scale_ids = mysql_query($sql_scale_ids, $db) or die(mysql_error());\r
94 \r
95         while ($row_scale_ids = mysql_fetch_assoc($result_scale_ids))\r
96         {\r
97                 $sql_detail = "SELECT * from ".TABLE_PREFIX."grade_scales_detail d WHERE d.grade_scale_id = ".$row_scale_ids["grade_scale_id"]." ORDER BY d.percentage_to desc";\r
98                 $result_detail = mysql_query($sql_detail, $db) or die(mysql_error());\r
99                 \r
100                 $whole_scale_value = "";\r
101                 \r
102                 while ($row_detail = mysql_fetch_assoc($result_detail))\r
103                 {\r
104                         $whole_scale_value .= $row_detail['scale_value'] . ' = ' . $row_detail['percentage_from'] . ' to ' . $row_detail['percentage_to'] . '%<br>';\r
105                 }\r
106                 \r
107                 if ($whole_scale_value <> '') $scale_content[$row_scale_ids["grade_scale_id"]] = $whole_scale_value;\r
108         }\r
109         // End of initialize scale content array\r
110 \r
111         while ($row = mysql_fetch_assoc($result))\r
112         {\r
113 ?>\r
114                 <tr onmousedown="document.form['m<?php echo $row["gradebook_test_id"]; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row["gradebook_test_id"]; ?>">\r
115                         <td width="10"><input type="radio" name="gradebook_test_id" value="<?php echo $row["gradebook_test_id"]; ?>" id="m<?php echo $row["gradebook_test_id"]; ?>" <?php if ($row["gradebook_test_id"]==$_POST['gradebook_test_id']) echo 'checked'; ?> /></td>\r
116                         <td><label for="m<?php echo $row["gradebook_test_id"]; ?>"><?php echo $row["title"]; ?></label></td>\r
117                         <td><?php echo $scale_content[$row["grade_scale_id"]]; ?></td>\r
118                         <?php if ($row["type"] == "External"){?>\r
119                                 <td><?php echo _AT("external"); ?></td>\r
120                         <?php } elseif($row["type"] == "ATutor Test"){ ?>\r
121                                 <td><?php echo _AT("atutor_test"); ?></td>\r
122                         <?php } else if($row["type"] == "ATutor Assignment") { ?>\r
123                                 <td><?php echo _AT("atutor_assignment"); ?></td>\r
124                         <?php } ?>\r
125                         \r
126                 </tr>\r
127 <?php \r
128         }\r
129 }\r
130 ?>\r
131 \r
132 </tbody>\r
133 </table>\r
134 </form>\r
135 \r
136 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>\r