2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
6 /* Adaptive Technology Resource Centre / University of Toronto */
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 /************************************************************************/
14 define('AT_INCLUDE_PATH', '../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 require(AT_INCLUDE_PATH.'classes/testQuestions.class.php');
17 authenticate(AT_PRIV_TESTS);
19 // converts array entries to ints
20 function intval_array ( & $value, $key) { $value = (int) $value; }
22 if ( (isset($_GET['edit']) || isset($_GET['delete']) || isset($_GET['export']) || isset($_GET['preview']) || isset($_GET['add'])) && !isset($_GET['questions'])){
23 $msg->addError('NO_ITEM_SELECTED');
24 } else if (isset($_GET['submit_create'], $_GET['question_type'])) {
25 header('Location: '.AT_BASE_HREF.'tools/tests/create_question_'.$addslashes($_GET['question_type']).'.php');
27 } else if (isset($_GET['edit'])) {
28 $id = current($_GET['questions']);
29 $num_selected = count($id);
31 if ($num_selected == 1) {
32 $ids = explode('|', $id[0], 2);
33 $o = TestQuestions::getQuestion($ids[1]);
34 if ($name = $o->getPrefix()) {
35 header('Location: '.AT_BASE_HREF.'tools/tests/edit_question_'.$name.'.php?qid='.intval($ids[0]));
38 header('Location: '.AT_BASE_HREF.'tools/tests/index.php');
42 $msg->addError('SELECT_ONE_ITEM');
45 } else if (isset($_GET['delete'])) {
46 $id = current($_GET['questions']);
48 foreach ($_GET['questions'] as $category_questions) {
49 $ids = array_merge($ids, $category_questions);
52 array_walk($ids, 'intval_array');
53 $ids = implode(',',$ids);
55 header('Location: '.AT_BASE_HREF.'tools/tests/delete_question.php?qid='.$ids);
57 } else if (isset($_GET['preview'])) {
59 foreach ($_GET['questions'] as $category_questions) {
60 $ids = array_merge($ids, $category_questions);
63 array_walk($ids, 'intval_array');
64 $ids = implode(',',$ids);
66 header('Location: '.AT_BASE_HREF.'tools/tests/preview_question.php?qid='.$ids);
68 } else if (isset($_GET['add'])) {
69 $id = current($_GET['questions']);
70 $ids = explode('|', $id[0], 2);
71 } else if (isset($_GET['export'])) {
73 foreach ($_GET['questions'] as $category_questions) {
74 $ids = array_merge($ids, $category_questions);
77 array_walk($ids, 'intval_array');
79 if ($_GET['qti_export_version']=='2.1'){
80 test_question_qti_export_v2p1($ids);
82 test_question_qti_export($ids);
88 require(AT_INCLUDE_PATH.'header.inc.php');
92 <div class="input-form" style="width:42em;">
93 <fieldset class="group_form" style="width:16em;float:right;height:18em;"><legend class="group_form"><?php echo _AT('import_question'); ?></legend>
94 <form method="post" action="<?php echo 'tools/tests/question_import.php'; ?>" enctype="multipart/form-data" > <label for="to_file"><?php echo _AT('upload_question'); ?></label><br />
95 <input type="file" name="file" id="to_file" />
96 <div class="row buttons">
97 <input type="submit" name="submit_import" value="<?php echo _AT('import'); ?>" />
101 <fieldset class="group_form" style="width:15em;"><legend class="group_form"><?php echo _AT('create_new_question'); ?></legend>
102 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
103 <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
104 <label for="question"><?php echo _AT('create_new_question'); ?></label><br />
105 <?php $questions = TestQuestions::getQuestionPrefixNames(); ?>
106 <select name="question_type" class="dropdown" id="question" size="8">
107 <?php foreach ($questions as $type => $name): ?>
108 <option value="<?php echo $type; ?>"><?php echo $name; ?></option>
111 <div class="row buttons">
112 <input type="submit" name="submit_create" value="<?php echo _AT('create'); ?>" />
120 <?php require(AT_INCLUDE_PATH.'html/tests_questions.inc.php'); ?>
122 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>