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 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 authenticate(AT_PRIV_TESTS);
21 if (isset($_POST['submit_no'])) {
22 $msg->addFeedback('CANCELLED');
23 header('Location: index.php');
25 } else if (isset($_POST['submit_yes'])) {
27 $tid = intval($_POST['tid']);
29 $sql = "DELETE FROM ".TABLE_PREFIX."tests WHERE test_id=$tid AND course_id=$_SESSION[course_id]";
30 $result = mysql_query($sql, $db);
32 if (mysql_affected_rows($db) == 1) {
33 $sql = "DELETE FROM ".TABLE_PREFIX."tests_questions_assoc WHERE test_id=$tid";
34 $result = mysql_query($sql, $db);
36 //delete test content association as well
37 $sql = "DELETE FROM ".TABLE_PREFIX."content_tests_assoc WHERE test_id=$tid";
38 $result = mysql_query($sql, $db);
40 /* it has to delete the results as well... */
41 $sql = "SELECT result_id FROM ".TABLE_PREFIX."tests_results WHERE test_id=$tid";
42 $result = mysql_query($sql, $db);
43 if ($row = mysql_fetch_array($result)) {
44 $result_list = '('.$row['result_id'];
46 while ($row = mysql_fetch_array($result)) {
47 $result_list .= ','.$row['result_id'];
52 if ($result_list != '') {
53 $sql = "DELETE FROM ".TABLE_PREFIX."tests_answers WHERE result_id IN $result_list";
54 $result = mysql_query($sql, $db);
57 $sql = "DELETE FROM ".TABLE_PREFIX."tests_results WHERE test_id=$tid";
58 $result = mysql_query($sql, $db);
62 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
63 header('Location: '.AT_BASE_HREF.'mods/_standard/tests/index.php');
68 require(AT_INCLUDE_PATH.'header.inc.php');
70 $_GET['tid'] = intval($_GET['tid']);
72 $sql = "SELECT title FROM ".TABLE_PREFIX."tests WHERE test_id=$_GET[tid] AND course_id=$_SESSION[course_id]";
73 $result = mysql_query($sql, $db);
74 $row = mysql_fetch_array($result);
77 $hidden_vars['tid'] = $_GET['tid'];
79 $msg->addConfirm(array('DELETE_TEST', $row['title']), $hidden_vars);
82 require(AT_INCLUDE_PATH.'footer.inc.php');