2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2010 */
\r
6 /* Inclusive Design Institute */
\r
8 /* This program is free software. You can redistribute it and/or */
\r
9 /* modify it under the terms of the GNU General Public License */
\r
10 /* as published by the Free Software Foundation. */
\r
11 /************************************************************************/
\r
13 if (!defined('TR_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_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsDAO.class.php');
\r
25 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsCategoriesDAO.class.php');
\r
26 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
\r
27 //require_once(TR_INCLUDE_PATH.'../tests/classes/TestsUtility.class.php');
\r
29 $testsQuestionsDAO = new TestsQuestionsDAO();
\r
30 $testsQuestionsCategoriesDAO = new TestsQuestionsCategoriesDAO();
\r
33 if ($_GET['category_id'] >= 0) {
\r
34 $category_row = $testsQuestionsCategoriesDAO->get($_GET[category_id]);
\r
36 $category_rows = $testsQuestionsCategoriesDAO->getByCourseID($_course_id);
\r
39 //$result = mysql_query($sql, $db);
\r
40 if ($_GET['category_id'] <= 0) {
\r
41 $cats[] = array('title' => _AT('cats_uncategorized'), 'category_id' => 0);
\r
44 if (is_array($category_rows)) {
\r
45 foreach ($category_rows as $row) $cats[] = $row;
\r
47 else if (isset($category_row) && $category_row <> '') {
\r
48 $cats[] = $category_row;
\r
55 <form method="post" action="tests/add_test_questions_confirm.php?_course_id=<?php echo $_course_id; ?>" name="form">
\r
57 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
\r
59 <input type="hidden" name="_course_id" value="<?php echo $_course_id; ?>" />
\r
60 <table class="data" summary="" rules="cols">
\r
63 <th scope="col"> </th>
\r
64 <th scope="col"><?php echo _AT('question'); ?></th>
\r
65 <th scope="col"><?php echo _AT('type'); ?></th>
\r
72 <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
\r
73 <input type="submit" name="submit" value="<?php echo _AT('add_to_test_survey'); ?>" accesskey="s" />
\r
74 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
\r
80 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />
\r
81 <input type="submit" name="preview" value="<?php echo _AT('preview'); ?>" />
\r
82 <input type="submit" name="export" value="<?php echo _AT('export'); ?>" />
\r
83 <select name='qti_export_version' >
\r
84 <option selected='selected' value='1.2.1'>QTI 1.2.1</option>
\r
85 <option value='2.1'>QTI 2.1</option>
\r
87 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />
\r
95 $question_flag = FALSE;
\r
98 foreach ($cats as $cat) {
\r
100 $rows = $testsQuestionsDAO->getByCourseIDAndCategoryID($_course_id, $cat['category_id']);
\r
101 if (is_array($rows)) {
\r
102 $question_flag = TRUE;
\r
104 echo '<th colspan="'.$cols.'">';
\r
106 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
110 foreach ($rows as $row) {
\r
111 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
113 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
115 echo '<a title="'.htmlentities($row[question], ENT_QUOTES, 'UTF-8').'">';
\r
116 echo AT_print(htmlentities(Utility::validateLength($row['question'], 100, 1), ENT_QUOTES, 'UTF-8'), 'tests_questions.question');
\r
120 $o = TestQuestions::getQuestion($row['type']);
\r
129 if (!$question_flag) {
\r
130 echo '<tr><td colspan="'.$cols.'">'._AT('none_found').'</td></tr>';
\r
137 <script language="javascript" type="text/javascript">
\r
139 function selectCat(catID, cat) {
\r
140 for (var i=0;i<document.form.elements.length;i++) {
\r
141 var e = document.form.elements[i];
\r
142 if ((e.name == 'questions[' + catID + '][]') && (e.type=='checkbox')) {
\r
143 e.checked = cat.checked;
\r
144 togglerowhighlight(document.getElementById("r" + e.id), e.id);
\r
149 function togglerowhighlight(obj, boxid) {
\r
150 if (document.getElementById(boxid).checked) {
\r
151 obj.className = 'selected';
\r
153 obj.className = '';
\r