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 /************************************************************************/
13 define('TR_INCLUDE_PATH', '../include/');
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'classes/testQuestions.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
20 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
22 // converts array entries to ints
23 function intval_array ( & $value, $key) { $value = (int) $value; }
25 if ( (isset($_GET['edit']) || isset($_GET['delete']) || isset($_GET['export']) || isset($_GET['preview']) || isset($_GET['add'])) && !isset($_GET['questions'])){
26 $msg->addError('NO_ITEM_SELECTED');
27 } else if (isset($_GET['submit_create'], $_GET['question_type'])) {
28 header('Location: '.TR_BASE_HREF.'tests/create_question_'.$addslashes($_GET['question_type']).'.php?_course_id='.$_course_id);
30 } else if (isset($_GET['edit'])) {
31 $id = current($_GET['questions']);
32 $num_selected = count($id);
34 if ($num_selected == 1) {
35 $ids = explode('|', $id[0], 2);
36 $o = TestQuestions::getQuestion($ids[1]);
37 if ($name = $o->getPrefix()) {
38 header('Location: '.TR_BASE_HREF.'tests/edit_question_'.$name.'.php?qid='.intval($ids[0]).'&_course_id='.$_course_id);
41 header('Location: '.TR_BASE_HREF.'tests/index.php?_course_id='.$_course_id);
45 $msg->addError('SELECT_ONE_ITEM');
48 } else if (isset($_GET['delete'])) {
49 $id = current($_GET['questions']);
51 foreach ($_GET['questions'] as $category_questions) {
52 $ids = array_merge($ids, $category_questions);
55 array_walk($ids, 'intval_array');
56 $ids = implode(',',$ids);
58 header('Location: '.TR_BASE_HREF.'tests/delete_question.php?qid='.$ids.'&_course_id='.$_course_id);
60 } else if (isset($_GET['preview'])) {
62 foreach ($_GET['questions'] as $category_questions) {
63 $ids = array_merge($ids, $category_questions);
66 array_walk($ids, 'intval_array');
67 $ids = implode(',',$ids);
69 header('Location: '.TR_BASE_HREF.'tests/preview_question.php?qid='.$ids.'&_course_id='.$_course_id);
71 } else if (isset($_GET['add'])) {
72 $id = current($_GET['questions']);
73 $ids = explode('|', $id[0], 2);
74 } else if (isset($_GET['export'])) {
76 foreach ($_GET['questions'] as $category_questions) {
77 $ids = array_merge($ids, $category_questions);
80 array_walk($ids, 'intval_array');
82 if ($_GET['qti_export_version']=='2.1'){
83 test_question_qti_export_v2p1($ids);
85 test_question_qti_export($ids);
91 require_once(TR_INCLUDE_PATH.'header.inc.php');
93 $savant->assign('course_id', $_course_id);
94 $savant->assign('tid', $tid);
95 $savant->assign('questions', TestQuestions::getQuestionPrefixNames());
97 $savant->display('tests/question_db_top.tmpl.php');
101 require_once(TR_INCLUDE_PATH.'../tests/html/tests_questions.inc.php');
103 <br style="clear:both;" />
106 <?php require_once(TR_INCLUDE_PATH.'footer.inc.php');?>