2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg & Boon-Hau Teh */
\r
6 /* Adaptive Technology Resource Centre / University of Toronto */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
\r
17 if (isset($_GET['reset_filter'])) {
\r
18 unset($_GET['category_id']);
\r
20 if (!isset($_GET['category_id'])) {
\r
21 // Suppress warnings
\r
22 $_GET['category_id'] = -1;
\r
24 require(AT_INCLUDE_PATH.'lib/test_result_functions.inc.php');
\r
27 <div class="input-form" style="width:42em;">
\r
28 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('category'); ?></legend>
\r
29 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
\r
30 <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
\r
32 <label for="cats"><?php echo _AT('category'); ?></label><br />
\r
33 <select name="category_id" id="cats">
\r
34 <option value="-1"><?php echo _AT('cats_all'); ?></option>
\r
35 <?php print_question_cats($_GET['category_id']); ?>
\r
38 <div class="row buttons">
\r
39 <input type="submit" name="filter" value="<?php echo _AT('filter'); ?>" />
\r
40 <input type="submit" name="reset_filter" value="<?php echo _AT('reset_filter'); ?>" />
\r
50 if ($_GET['category_id'] >= 0) {
\r
51 $sql = "SELECT * FROM ".TABLE_PREFIX."tests_questions_categories WHERE course_id=$_SESSION[course_id] AND category_id=$_GET[category_id] ORDER BY title";
\r
53 $sql = "SELECT * FROM ".TABLE_PREFIX."tests_questions_categories WHERE course_id=$_SESSION[course_id] ORDER BY title";
\r
56 $result = mysql_query($sql, $db);
\r
57 if ($_GET['category_id'] <= 0) {
\r
58 $cats[] = array('title' => _AT('cats_uncategorized'), 'category_id' => 0);
\r
61 while ($row = mysql_fetch_assoc($result)) {
\r
68 <form method="post" action="tools/tests/add_test_questions_confirm.php" name="form">
\r
70 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
\r
72 <table class="data" summary="" rules="cols">
\r
75 <th scope="col"> </th>
\r
76 <th scope="col"><?php echo _AT('question'); ?></th>
\r
77 <th scope="col"><?php echo _AT('type'); ?></th>
\r
84 <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
\r
85 <input type="submit" name="submit" value="<?php echo _AT('add_to_test_survey'); ?>" accesskey="s" />
\r
86 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
\r
92 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />
\r
93 <input type="submit" name="preview" value="<?php echo _AT('preview'); ?>" />
\r
94 <input type="submit" name="export" value="<?php echo _AT('export'); ?>" />
\r
95 <select name='qti_export_version' >
\r
96 <option selected='selected' value='1.2.1'>QTI 1.2.1</option>
\r
97 <option value='2.1'>QTI 2.1</option>
\r
99 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />
\r
107 $question_flag = FALSE;
\r
109 //output categories
\r
110 foreach ($cats as $cat) {
\r
112 $sql = "SELECT * FROM ".TABLE_PREFIX."tests_questions WHERE course_id=$_SESSION[course_id] AND category_id=".$cat['category_id']." ORDER BY question";
\r
113 $result = mysql_query($sql, $db);
\r
114 if ($row = mysql_fetch_assoc($result)) {
\r
115 $question_flag = TRUE;
\r
117 echo '<th colspan="'.$cols.'">';
\r
119 echo '<input type="checkbox" name="cat'.$cat['category_id'].'" id="cat'.$cat['category_id'].'" onclick="javascript:selectCat('.$cat['category_id'].', this);" /><label for="cat'.$cat['category_id'].'">'.$cat['title'].'</label>';
\r
124 echo '<tr onmousedown="document.form[\'q' . $row['question_id'] . '\'].checked = !document.form[\'q' . $row['question_id'] . '\'].checked; togglerowhighlight(this, \'q'.$row['question_id'].'\');" id="rq'.$row['question_id'].'">';
\r
126 echo '<input type="checkbox" value="'.$row['question_id'].'|'.$row['type'].'" name="questions['.$cat['category_id'].'][]" id="q'.$row['question_id'].'" onmouseup="this.checked=!this.checked" /></td>';
\r
128 echo '<a title="'.htmlentities($row[question], ENT_QUOTES, 'UTF-8').'">';
\r
129 echo AT_PRINT(htmlentities(validate_length($row['question'], 100, VALIDATE_LENGTH_FOR_DISPLAY), ENT_QUOTES, 'UTF-8'), 'tests_questions.question');
\r
133 $o = TestQuestions::getQuestion($row['type']);
\r
140 } while ($row = mysql_fetch_assoc($result));
\r
143 if (!$question_flag) {
\r
144 echo '<tr><td colspan="'.$cols.'">'._AT('none_found').'</td></tr>';
\r
151 <script language="javascript" type="text/javascript">
\r
153 function selectCat(catID, cat) {
\r
154 for (var i=0;i<document.form.elements.length;i++) {
\r
155 var e = document.form.elements[i];
\r
156 if ((e.name == 'questions[' + catID + '][]') && (e.type=='checkbox')) {
\r
157 e.checked = cat.checked;
\r
158 togglerowhighlight(document.getElementById("r" + e.id), e.id);
\r
163 function togglerowhighlight(obj, boxid) {
\r
164 if (document.getElementById(boxid).checked) {
\r
165 obj.className = 'selected';
\r
167 obj.className = '';
\r