2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
14 define('TR_INCLUDE_PATH', '../include/');
15 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
16 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
17 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsDAO.class.php');
18 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsAssocDAO.class.php');
19 require_once(TR_INCLUDE_PATH.'classes/DAO/ContentTestsAssocDAO.class.php');
23 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
25 $testsDAO = new TestsDAO();
27 if (isset($_POST['submit_no'])) {
28 $msg->addFeedback('CANCELLED');
29 header('Location: index.php?_course_id='.$_course_id);
31 } else if (isset($_POST['submit_yes'])) {
33 $tid = intval($_POST['tid']);
35 if ($testsDAO->Delete($tid)) {
36 $testsQuestionsAssocDAO = new TestsQuestionsAssocDAO();
37 $testsQuestionsAssocDAO->DeleteByTestID($tid);
39 //delete test content association as well
40 $contentTestsAssocDAO = new ContentTestsAssocDAO();
41 $contentTestsAssocDAO->DeleteByTestID($tid);
44 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
45 header('Location: '.TR_BASE_HREF.'tests/index.php?_course_id='.$_course_id);
50 require_once(TR_INCLUDE_PATH.'header.inc.php');
52 $_GET['tid'] = intval($_GET['tid']);
54 $row = $testsDAO->get($_GET['tid']);
57 $hidden_vars['tid'] = $_GET['tid'];
58 $hidden_vars['_course_id'] = $_course_id;
60 $msg->addConfirm(array('DELETE_TEST', $row['title']), $hidden_vars);
63 require_once(TR_INCLUDE_PATH.'footer.inc.php');