moved code up one level to eliminate the docs subdirectory
[acontent.git] / tests / delete_question.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
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 /************************************************************************/
12
13 define('TR_INCLUDE_PATH', '../include/');
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsDAO.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsAssocDAO.class.php');
17 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
18
19 global $_course_id;
20 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
21 $testsQuestionsDAO = new TestsQuestionsDAO();
22 $testsQuestionsAssocDAO = new TestsQuestionsAssocDAO();
23
24 $tid = intval($_REQUEST['tid']);
25
26 if (isset($_POST['submit_no'])) {
27         $msg->addFeedback('CANCELLED');
28         header('Location: question_db.php?_course_id='.$_course_id);
29         exit;
30 } else if (isset($_POST['submit_yes'])) {
31         $_POST['qid'] = explode(',', $_POST['qid']);
32
33         foreach ($_POST['qid'] as $id) {
34                 $id = intval($id);
35
36                 if ($testsQuestionsDAO->Delete($id)) $testsQuestionsAssocDAO->DeleteByQuestionID($id);
37         }
38
39         $msg->addFeedback('QUESTION_DELETED');
40         header('Location: question_db.php?_course_id='.$_course_id);
41         exit;
42 } /* else: */
43
44 require_once(TR_INCLUDE_PATH.'header.inc.php');
45
46 $these_questions= explode(",", $_REQUEST['qid']);
47
48 foreach($these_questions as $this_question){
49         $this_question = intval($this_question);
50         $row = $testsQuestionsDAO->get($this_question);
51         $confirm .= "<li>".$row['question']."</li>";
52 }
53
54 $confirm = array('DELETE', $confirm);
55 $hidden_vars['qid'] = $_REQUEST['qid'];
56 $hidden_vars['_course_id'] = $_course_id;
57
58 $msg->addConfirm($confirm, $hidden_vars);
59 $msg->printConfirm();
60
61 require_once(TR_INCLUDE_PATH.'footer.inc.php');
62 ?>