2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-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('AT_INCLUDE_PATH', '../../../include/');
14 require(AT_INCLUDE_PATH.'vitals.inc.php');
15 require(AT_INCLUDE_PATH.'../mods/_standard/tests/classes/testQuestions.class.php');
16 authenticate(AT_PRIV_TESTS);
18 // converts array entries to ints
19 function intval_array ( & $value, $key) { $value = (int) $value; }
21 if ( (isset($_GET['edit']) || isset($_GET['delete']) || isset($_GET['export']) || isset($_GET['preview']) || isset($_GET['add'])) && !isset($_GET['questions'])){
22 $msg->addError('NO_ITEM_SELECTED');
23 } else if (isset($_GET['submit_create'], $_GET['question_type'])) {
24 header('Location: '.AT_BASE_HREF.'mods/_standard/tests/create_question_'.$addslashes($_GET['question_type']).'.php');
26 } else if (isset($_GET['edit'])) {
27 $id = current($_GET['questions']);
28 $num_selected = count($id);
30 if ($num_selected == 1) {
31 $ids = explode('|', $id[0], 2);
32 $o = TestQuestions::getQuestion($ids[1]);
33 if ($name = $o->getPrefix()) {
34 header('Location: '.AT_BASE_HREF.'mods/_standard/tests/edit_question_'.$name.'.php?qid='.intval($ids[0]));
37 header('Location: '.AT_BASE_HREF.'mods/_standard/tests/index.php');
41 $msg->addError('SELECT_ONE_ITEM');
44 } else if (isset($_GET['delete'])) {
45 $id = current($_GET['questions']);
47 foreach ($_GET['questions'] as $category_questions) {
48 $ids = array_merge($ids, $category_questions);
51 array_walk($ids, 'intval_array');
52 $ids = implode(',',$ids);
54 header('Location: '.AT_BASE_HREF.'mods/_standard/tests/delete_question.php?qid='.$ids);
56 } else if (isset($_GET['preview'])) {
58 foreach ($_GET['questions'] as $category_questions) {
59 $ids = array_merge($ids, $category_questions);
62 array_walk($ids, 'intval_array');
63 $ids = implode(',',$ids);
65 header('Location: '.AT_BASE_HREF.'mods/_standard/tests/preview_question.php?qid='.$ids);
67 } else if (isset($_GET['add'])) {
68 $id = current($_GET['questions']);
69 $ids = explode('|', $id[0], 2);
70 } else if (isset($_GET['export'])) {
72 foreach ($_GET['questions'] as $category_questions) {
73 $ids = array_merge($ids, $category_questions);
76 array_walk($ids, 'intval_array');
78 if ($_GET['qti_export_version']=='2.1'){
79 test_question_qti_export_v2p1($ids);
81 test_question_qti_export($ids);
87 require(AT_INCLUDE_PATH.'header.inc.php');
91 <div class="input-form">
92 <fieldset class="group_form" style="width:45%;float:left;height:18em;min-width:15em;"><legend class="group_form"><?php echo _AT('create_new_question'); ?></legend>
93 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
94 <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
95 <label for="question"><?php echo _AT('create_new_question'); ?></label><br />
96 <?php $questions = TestQuestions::getQuestionPrefixNames(); ?>
97 <select name="question_type" class="dropdown" id="question" size="8">
98 <?php foreach ($questions as $type => $name): ?>
99 <option value="<?php echo $type; ?>"><?php echo $name; ?></option>
102 <div class="row buttons">
103 <input type="submit" name="submit_create" value="<?php echo _AT('create'); ?>" />
108 <fieldset class="group_form" style="width:45%;float:left;clear:right;height:18em;min-width:18em;"><legend class="group_form"><?php echo _AT('import_question'); ?></legend>
109 <form method="post" action="<?php echo 'mods/_standard/tests/question_import.php'; ?>" enctype="multipart/form-data" > <label for="to_file"><?php echo _AT('upload_question'); ?></label><br />
110 <input type="file" name="file" id="to_file" />
111 <div class="row buttons">
112 <input type="submit" name="submit_import" value="<?php echo _AT('import'); ?>" />
120 <?php require(AT_INCLUDE_PATH.'../mods/_standard/tests/html/tests_questions.inc.php'); ?>
121 <br style="clear:both;" />
123 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>