@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * Automatic fix online time procedure. If a COURSEMANAGER has been idle for $timeLimit |
|
5 | - * or more then the procedure adds $extraTime to his logout_course_date. |
|
6 | - * @package chamilo.cron |
|
7 | - * @author Imanol Losada <[email protected]> |
|
8 | - */ |
|
4 | + * Automatic fix online time procedure. If a COURSEMANAGER has been idle for $timeLimit |
|
5 | + * or more then the procedure adds $extraTime to his logout_course_date. |
|
6 | + * @package chamilo.cron |
|
7 | + * @author Imanol Losada <[email protected]> |
|
8 | + */ |
|
9 | 9 | require_once __DIR__ . '/../inc/global.inc.php'; |
10 | 10 | |
11 | 11 | /** |
@@ -1,20 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This script should be called by a properly set cron process on your server. |
|
4 | - * For more information, check the installation guide in the documentation |
|
5 | - * folder. |
|
6 | - * Add your own executable scripts below the inclusion of notification.php |
|
7 | - * @package chamilo.cron |
|
8 | - */ |
|
3 | + * This script should be called by a properly set cron process on your server. |
|
4 | + * For more information, check the installation guide in the documentation |
|
5 | + * folder. |
|
6 | + * Add your own executable scripts below the inclusion of notification.php |
|
7 | + * @package chamilo.cron |
|
8 | + */ |
|
9 | 9 | /** |
10 | - * Settings that will influence the execution of the cron tasks |
|
11 | - */ |
|
10 | + * Settings that will influence the execution of the cron tasks |
|
11 | + */ |
|
12 | 12 | //ini_set('max_execution_time',300); //authorize execution for up to 5 minutes |
13 | 13 | //ini_set('memory_limit','100M'); //authorize script to use up to 100M RAM |
14 | 14 | /** |
15 | - * Included cron-ed tasks. You might want to turn error-logging off by |
|
16 | - * commenting the first and last line of this section. |
|
17 | - */ |
|
15 | + * Included cron-ed tasks. You might want to turn error-logging off by |
|
16 | + * commenting the first and last line of this section. |
|
17 | + */ |
|
18 | 18 | error_log('[chamilo][cronjob] Starting cron jobs as process '.getmypid()); |
19 | 19 | require_once 'notification.php'; |
20 | 20 | error_log('[chamilo][cronjob] Ending cron jobs of process '.getmypid()); |
@@ -14,23 +14,23 @@ discard block |
||
14 | 14 | $views = array('blocks', 'list'); |
15 | 15 | |
16 | 16 | if(isset($_GET['view']) && in_array($_GET['view'], $views)){ |
17 | - $dashboard_view = $_GET['view']; |
|
17 | + $dashboard_view = $_GET['view']; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | $link_blocks_view = $link_list_view = null; |
21 | 21 | |
22 | 22 | if (isset($dashboard_view) && $dashboard_view == 'list') { |
23 | - $link_blocks_view = '<a href="'.api_get_self().'?view=blocks">'. |
|
24 | - Display::return_icon('blocks.png',get_lang('DashboardBlocks'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
23 | + $link_blocks_view = '<a href="'.api_get_self().'?view=blocks">'. |
|
24 | + Display::return_icon('blocks.png',get_lang('DashboardBlocks'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
25 | 25 | } else { |
26 | - $link_list_view = '<a href="'.api_get_self().'?view=list">'. |
|
27 | - Display::return_icon('edit.png',get_lang('EditBlocks'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
26 | + $link_list_view = '<a href="'.api_get_self().'?view=list">'. |
|
27 | + Display::return_icon('edit.png',get_lang('EditBlocks'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $configuration_link = null; |
31 | 31 | if (api_is_platform_admin()) { |
32 | - $configuration_link = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">' |
|
33 | - .Display::return_icon('settings.png',get_lang('ConfigureDashboardPlugin'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
32 | + $configuration_link = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">' |
|
33 | + .Display::return_icon('settings.png',get_lang('ConfigureDashboardPlugin'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | echo '<div class="actions">'; |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | } else { |
90 | - // block dashboard list |
|
91 | - if (isset($success)) { |
|
92 | - Display::display_confirmation_message(get_lang('BlocksHaveBeenUpdatedSuccessfully')); |
|
93 | - } |
|
94 | - $user_id = api_get_user_id(); |
|
95 | - DashboardManager::display_user_dashboard_list($user_id); |
|
90 | + // block dashboard list |
|
91 | + if (isset($success)) { |
|
92 | + Display::display_confirmation_message(get_lang('BlocksHaveBeenUpdatedSuccessfully')); |
|
93 | + } |
|
94 | + $user_id = api_get_user_id(); |
|
95 | + DashboardManager::display_user_dashboard_list($user_id); |
|
96 | 96 | } |
@@ -85,40 +85,40 @@ |
||
85 | 85 | $this->view->render(); |
86 | 86 | } |
87 | 87 | |
88 | - /** |
|
89 | - * This method allow store user blocks from dashboard manager |
|
90 | - * render to dashboard.php view |
|
91 | - */ |
|
92 | - public function store_user_block() |
|
88 | + /** |
|
89 | + * This method allow store user blocks from dashboard manager |
|
90 | + * render to dashboard.php view |
|
91 | + */ |
|
92 | + public function store_user_block() |
|
93 | 93 | { |
94 | - $data = array(); |
|
95 | - $user_id = $this->user_id; |
|
96 | - if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { |
|
97 | - $enabled_blocks = $_POST['enabled_blocks']; |
|
98 | - $columns = $_POST['columns']; |
|
99 | - $affected_rows = DashboardManager::store_user_blocks($user_id, $enabled_blocks, $columns); |
|
100 | - if ($affected_rows) { |
|
101 | - $data['success'] = true; |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - $data['dashboard_view'] = 'list'; |
|
106 | - |
|
107 | - // render to the view |
|
108 | - $this->view->set_data($data); |
|
109 | - $this->view->set_layout('layout'); |
|
110 | - $this->view->set_template('dashboard'); |
|
111 | - $this->view->render(); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * This method is used when you close a block from dashboard block interface |
|
116 | - * render to dashboard.php view |
|
117 | - */ |
|
118 | - public function close_user_block($path) |
|
94 | + $data = array(); |
|
95 | + $user_id = $this->user_id; |
|
96 | + if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { |
|
97 | + $enabled_blocks = $_POST['enabled_blocks']; |
|
98 | + $columns = $_POST['columns']; |
|
99 | + $affected_rows = DashboardManager::store_user_blocks($user_id, $enabled_blocks, $columns); |
|
100 | + if ($affected_rows) { |
|
101 | + $data['success'] = true; |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + $data['dashboard_view'] = 'list'; |
|
106 | + |
|
107 | + // render to the view |
|
108 | + $this->view->set_data($data); |
|
109 | + $this->view->set_layout('layout'); |
|
110 | + $this->view->set_template('dashboard'); |
|
111 | + $this->view->render(); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * This method is used when you close a block from dashboard block interface |
|
116 | + * render to dashboard.php view |
|
117 | + */ |
|
118 | + public function close_user_block($path) |
|
119 | 119 | { |
120 | - $user_id = $this->user_id; |
|
121 | - $result = DashboardManager::close_user_block($user_id, $path); |
|
122 | - $this->display($result); |
|
123 | - } |
|
120 | + $user_id = $this->user_id; |
|
121 | + $result = DashboardManager::close_user_block($user_id, $path); |
|
122 | + $this->display($result); |
|
123 | + } |
|
124 | 124 | } |
@@ -33,18 +33,18 @@ |
||
33 | 33 | $doc_url = str_replace('/..', '', $doc_url); //echo $doc_url; |
34 | 34 | |
35 | 35 | if (! isset($_course)) { |
36 | - api_not_allowed(true); |
|
36 | + api_not_allowed(true); |
|
37 | 37 | } |
38 | 38 | $full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/blog/'.$doc_url; |
39 | 39 | |
40 | 40 | //if the rewrite rule asks for a directory, we redirect to the course view |
41 | 41 | if (is_dir($full_file_name)) { |
42 | - //remove last slash if present |
|
43 | - while ($doc_url{$dul = strlen($doc_url)-1}=='/') $doc_url = substr($doc_url,0,$dul); |
|
44 | - //create the path |
|
45 | - $document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path |
|
46 | - //redirect |
|
47 | - header('Location: '.$document_explorer); |
|
42 | + //remove last slash if present |
|
43 | + while ($doc_url{$dul = strlen($doc_url)-1}=='/') $doc_url = substr($doc_url,0,$dul); |
|
44 | + //create the path |
|
45 | + $document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path |
|
46 | + //redirect |
|
47 | + header('Location: '.$document_explorer); |
|
48 | 48 | exit; |
49 | 49 | } |
50 | 50 |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | $label = get_lang('NextQuestion'); |
1967 | 1967 | $class = 'btn btn-primary'; |
1968 | 1968 | } |
1969 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1969 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1970 | 1970 | if ($this->type == ONE_PER_PAGE) { |
1971 | 1971 | if ($questionNum != 1) { |
1972 | 1972 | $prev_question = $questionNum - 2; |
@@ -1991,7 +1991,7 @@ discard block |
||
1991 | 1991 | $all_label = get_lang('EndTest'); |
1992 | 1992 | $class = 'btn btn-warning'; |
1993 | 1993 | } |
1994 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1994 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1995 | 1995 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
1996 | 1996 | $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
1997 | 1997 | $html .= $all_button; |
@@ -3774,7 +3774,7 @@ discard block |
||
3774 | 3774 | |
3775 | 3775 | //Fixes multiple answer question in order to be exact |
3776 | 3776 | //if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { |
3777 | - /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3777 | + /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3778 | 3778 | $diff = @array_diff($answer_correct_array, $real_answers); |
3779 | 3779 | |
3780 | 3780 | // All good answers or nothing works like exact |
@@ -5073,8 +5073,8 @@ discard block |
||
5073 | 5073 | } |
5074 | 5074 | |
5075 | 5075 | /** |
5076 | - * @return string |
|
5077 | - */ |
|
5076 | + * @return string |
|
5077 | + */ |
|
5078 | 5078 | public function get_formated_title() |
5079 | 5079 | { |
5080 | 5080 | return api_html_entity_decode($this->selectTitle()); |
@@ -249,7 +249,7 @@ |
||
249 | 249 | break; |
250 | 250 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
251 | 251 | if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) { |
252 | - $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); |
|
252 | + $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); |
|
253 | 253 | } |
254 | 254 | else { |
255 | 255 | $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details')); |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | public $name; |
14 | 14 | public $description; |
15 | 15 | |
16 | - /** |
|
17 | - * Constructor of the class Category |
|
18 | - * If you give an in_id and no in_name, you get info concerning the category of id=in_id |
|
19 | - * otherwise, you've got an category objet avec your in_id, in_name, in_descr |
|
20 | - * |
|
16 | + /** |
|
17 | + * Constructor of the class Category |
|
18 | + * If you give an in_id and no in_name, you get info concerning the category of id=in_id |
|
19 | + * otherwise, you've got an category objet avec your in_id, in_name, in_descr |
|
20 | + * |
|
21 | 21 | * @param int $id |
22 | 22 | * @param string $name |
23 | 23 | * @param string $description |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - /** |
|
64 | + /** |
|
65 | 65 | * add TestCategory in the database if name doesn't already exists |
66 | - */ |
|
66 | + */ |
|
67 | 67 | public function addCategoryInBDD() |
68 | 68 | { |
69 | 69 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | |
109 | 109 | return false; |
110 | 110 | } |
111 | - } |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
113 | + /** |
|
114 | 114 | * Removes the category from the database |
115 | 115 | * if there were question in this category, the link between question and category is removed |
116 | - */ |
|
116 | + */ |
|
117 | 117 | public function removeCategory() |
118 | 118 | { |
119 | 119 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | |
144 | 144 | return true; |
145 | 145 | } |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
148 | + /** |
|
149 | 149 | * Modify category name or description of category with id=in_id |
150 | - */ |
|
150 | + */ |
|
151 | 151 | public function modifyCategory() |
152 | 152 | { |
153 | 153 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -175,40 +175,40 @@ discard block |
||
175 | 175 | |
176 | 176 | return true; |
177 | 177 | } |
178 | - } |
|
178 | + } |
|
179 | 179 | |
180 | - /** |
|
180 | + /** |
|
181 | 181 | * Gets the number of question of category id=in_id |
182 | - */ |
|
182 | + */ |
|
183 | 183 | public function getCategoryQuestionsNumber() |
184 | 184 | { |
185 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
186 | - $in_id = intval($this->id); |
|
187 | - $sql = "SELECT count(*) AS nb |
|
185 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
186 | + $in_id = intval($this->id); |
|
187 | + $sql = "SELECT count(*) AS nb |
|
188 | 188 | FROM $table |
189 | 189 | WHERE category_id=$in_id AND c_id=".api_get_course_int_id(); |
190 | - $res = Database::query($sql); |
|
191 | - $row = Database::fetch_array($res); |
|
190 | + $res = Database::query($sql); |
|
191 | + $row = Database::fetch_array($res); |
|
192 | 192 | |
193 | - return $row['nb']; |
|
194 | - } |
|
193 | + return $row['nb']; |
|
194 | + } |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @param string $in_color |
198 | 198 | */ |
199 | 199 | public function display($in_color="#E0EBF5") |
200 | 200 | { |
201 | - echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>"; |
|
202 | - print_r($this); |
|
203 | - echo "</textarea>"; |
|
204 | - } |
|
201 | + echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>"; |
|
202 | + print_r($this); |
|
203 | + echo "</textarea>"; |
|
204 | + } |
|
205 | 205 | |
206 | - /** |
|
206 | + /** |
|
207 | 207 | * Return an array of all Category objects in the database |
208 | - * If in_field=="" Return an array of all category objects in the database |
|
209 | - * Otherwise, return an array of all in_field value |
|
210 | - * in the database (in_field = id or name or description) |
|
211 | - */ |
|
208 | + * If in_field=="" Return an array of all category objects in the database |
|
209 | + * Otherwise, return an array of all in_field value |
|
210 | + * in the database (in_field = id or name or description) |
|
211 | + */ |
|
212 | 212 | public static function getCategoryListInfo($in_field = "", $courseId = "") |
213 | 213 | { |
214 | 214 | if (empty($courseId) || $courseId=="") { |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | - return $tabres; |
|
243 | - } |
|
242 | + return $tabres; |
|
243 | + } |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Return the TestCategory id for question with question_id = $questionId |
@@ -251,196 +251,196 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return int |
253 | 253 | */ |
254 | - public static function getCategoryForQuestion($questionId, $courseId ="") |
|
254 | + public static function getCategoryForQuestion($questionId, $courseId ="") |
|
255 | 255 | { |
256 | - $result = 0; |
|
256 | + $result = 0; |
|
257 | 257 | if (empty($courseId) || $courseId == "") { |
258 | 258 | $courseId = api_get_course_int_id(); |
259 | 259 | } |
260 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
260 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
261 | 261 | $questionId = intval($questionId); |
262 | - $sql = "SELECT category_id |
|
262 | + $sql = "SELECT category_id |
|
263 | 263 | FROM $table |
264 | 264 | WHERE question_id = $questionId AND c_id = $courseId"; |
265 | - $res = Database::query($sql); |
|
266 | - if (Database::num_rows($res) > 0) { |
|
265 | + $res = Database::query($sql); |
|
266 | + if (Database::num_rows($res) > 0) { |
|
267 | 267 | $data = Database::fetch_array($res); |
268 | - $result = $data['category_id']; |
|
269 | - } |
|
268 | + $result = $data['category_id']; |
|
269 | + } |
|
270 | 270 | |
271 | - return $result; |
|
272 | - } |
|
271 | + return $result; |
|
272 | + } |
|
273 | 273 | |
274 | - /** |
|
275 | - * true if question id has a category |
|
276 | - */ |
|
277 | - public static function isQuestionHasCategory($questionId) |
|
274 | + /** |
|
275 | + * true if question id has a category |
|
276 | + */ |
|
277 | + public static function isQuestionHasCategory($questionId) |
|
278 | 278 | { |
279 | - if (TestCategory::getCategoryForQuestion($questionId) > 0) { |
|
280 | - return true; |
|
281 | - } |
|
282 | - return false; |
|
283 | - } |
|
279 | + if (TestCategory::getCategoryForQuestion($questionId) > 0) { |
|
280 | + return true; |
|
281 | + } |
|
282 | + return false; |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
285 | + /** |
|
286 | 286 | Return the category name for question with question_id = $questionId |
287 | 287 | In this version, a question has only 1 category. |
288 | 288 | Return the category id, "" if none |
289 | - */ |
|
289 | + */ |
|
290 | 290 | public static function getCategoryNameForQuestion( |
291 | 291 | $questionId, |
292 | 292 | $courseId = "" |
293 | 293 | ) { |
294 | - if (empty($courseId) || $courseId=="") { |
|
295 | - $courseId = api_get_course_int_id(); |
|
296 | - } |
|
297 | - $catid = TestCategory::getCategoryForQuestion($questionId, $courseId); |
|
298 | - $result = ""; // result |
|
299 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
300 | - $catid = intval($catid); |
|
301 | - $sql = "SELECT title FROM $table |
|
294 | + if (empty($courseId) || $courseId=="") { |
|
295 | + $courseId = api_get_course_int_id(); |
|
296 | + } |
|
297 | + $catid = TestCategory::getCategoryForQuestion($questionId, $courseId); |
|
298 | + $result = ""; // result |
|
299 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
300 | + $catid = intval($catid); |
|
301 | + $sql = "SELECT title FROM $table |
|
302 | 302 | WHERE id = $catid AND c_id = $courseId"; |
303 | - $res = Database::query($sql); |
|
304 | - $data = Database::fetch_array($res); |
|
305 | - if (Database::num_rows($res) > 0) { |
|
306 | - $result = $data['title']; |
|
307 | - } |
|
308 | - |
|
309 | - return $result; |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * Return the list of differents categories ID for a test in the current course |
|
314 | - * input : test_id |
|
315 | - * return : array of category id (integer) |
|
316 | - * hubert.borderiou 07-04-2011 |
|
317 | - */ |
|
318 | - public static function getListOfCategoriesIDForTest($in_testid) |
|
303 | + $res = Database::query($sql); |
|
304 | + $data = Database::fetch_array($res); |
|
305 | + if (Database::num_rows($res) > 0) { |
|
306 | + $result = $data['title']; |
|
307 | + } |
|
308 | + |
|
309 | + return $result; |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * Return the list of differents categories ID for a test in the current course |
|
314 | + * input : test_id |
|
315 | + * return : array of category id (integer) |
|
316 | + * hubert.borderiou 07-04-2011 |
|
317 | + */ |
|
318 | + public static function getListOfCategoriesIDForTest($in_testid) |
|
319 | 319 | { |
320 | - // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
321 | - $result = array(); |
|
322 | - $quiz = new Exercise(); |
|
323 | - $quiz->read($in_testid); |
|
324 | - $tabQuestionList = $quiz->selectQuestionList(); |
|
325 | - // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
326 | - for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
327 | - if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) { |
|
328 | - $result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]); |
|
329 | - } |
|
330 | - } |
|
331 | - |
|
332 | - return $result; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * return the list of different categories NAME for a test |
|
337 | - * input : test_id |
|
338 | - * return : array of string |
|
339 | - * hubert.borderiou 07-04-2011 |
|
320 | + // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
321 | + $result = array(); |
|
322 | + $quiz = new Exercise(); |
|
323 | + $quiz->read($in_testid); |
|
324 | + $tabQuestionList = $quiz->selectQuestionList(); |
|
325 | + // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
326 | + for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
327 | + if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) { |
|
328 | + $result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]); |
|
329 | + } |
|
330 | + } |
|
331 | + |
|
332 | + return $result; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * return the list of different categories NAME for a test |
|
337 | + * input : test_id |
|
338 | + * return : array of string |
|
339 | + * hubert.borderiou 07-04-2011 |
|
340 | 340 | * @author function rewrote by jmontoya |
341 | - */ |
|
342 | - public static function getListOfCategoriesNameForTest($in_testid) |
|
341 | + */ |
|
342 | + public static function getListOfCategoriesNameForTest($in_testid) |
|
343 | 343 | { |
344 | - $tabcatName = array(); |
|
345 | - $tabcatID = self::getListOfCategoriesIDForTest($in_testid); |
|
346 | - for ($i=0; $i < count($tabcatID); $i++) { |
|
347 | - $cat = new TestCategory($tabcatID[$i]); |
|
348 | - $tabcatName[$cat->id] = $cat->name; |
|
349 | - } |
|
350 | - return $tabcatName; |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * return the number of differents categories for a test |
|
355 | - * input : test_id |
|
356 | - * return : integer |
|
357 | - * hubert.borderiou 07-04-2011 |
|
358 | - */ |
|
359 | - public static function getNumberOfCategoriesForTest($in_testid) |
|
344 | + $tabcatName = array(); |
|
345 | + $tabcatID = self::getListOfCategoriesIDForTest($in_testid); |
|
346 | + for ($i=0; $i < count($tabcatID); $i++) { |
|
347 | + $cat = new TestCategory($tabcatID[$i]); |
|
348 | + $tabcatName[$cat->id] = $cat->name; |
|
349 | + } |
|
350 | + return $tabcatName; |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * return the number of differents categories for a test |
|
355 | + * input : test_id |
|
356 | + * return : integer |
|
357 | + * hubert.borderiou 07-04-2011 |
|
358 | + */ |
|
359 | + public static function getNumberOfCategoriesForTest($in_testid) |
|
360 | 360 | { |
361 | - return count(TestCategory::getListOfCategoriesIDForTest($in_testid)); |
|
362 | - } |
|
361 | + return count(TestCategory::getListOfCategoriesIDForTest($in_testid)); |
|
362 | + } |
|
363 | 363 | |
364 | - /** |
|
365 | - * return the number of question of a category id in a test |
|
366 | - * @param int $exerciseId |
|
364 | + /** |
|
365 | + * return the number of question of a category id in a test |
|
366 | + * @param int $exerciseId |
|
367 | 367 | * @param int $categoryId |
368 | 368 | * |
369 | - * @return integer |
|
369 | + * @return integer |
|
370 | 370 | * |
371 | - * @author hubert.borderiou 07-04-2011 |
|
372 | - */ |
|
373 | - public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId) |
|
371 | + * @author hubert.borderiou 07-04-2011 |
|
372 | + */ |
|
373 | + public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId) |
|
374 | 374 | { |
375 | - $nbCatResult = 0; |
|
376 | - $quiz = new Exercise(); |
|
377 | - $quiz->read($exerciseId); |
|
378 | - $tabQuestionList = $quiz->selectQuestionList(); |
|
379 | - // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ? |
|
380 | - for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
381 | - if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) { |
|
382 | - $nbCatResult++; |
|
383 | - } |
|
384 | - } |
|
385 | - |
|
386 | - return $nbCatResult; |
|
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * return the number of question for a test using random by category |
|
391 | - * input : test_id, number of random question (min 1) |
|
392 | - * hubert.borderiou 07-04-2011 |
|
393 | - * question without categories are not counted |
|
394 | - */ |
|
395 | - public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom) |
|
375 | + $nbCatResult = 0; |
|
376 | + $quiz = new Exercise(); |
|
377 | + $quiz->read($exerciseId); |
|
378 | + $tabQuestionList = $quiz->selectQuestionList(); |
|
379 | + // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ? |
|
380 | + for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
381 | + if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) { |
|
382 | + $nbCatResult++; |
|
383 | + } |
|
384 | + } |
|
385 | + |
|
386 | + return $nbCatResult; |
|
387 | + } |
|
388 | + |
|
389 | + /** |
|
390 | + * return the number of question for a test using random by category |
|
391 | + * input : test_id, number of random question (min 1) |
|
392 | + * hubert.borderiou 07-04-2011 |
|
393 | + * question without categories are not counted |
|
394 | + */ |
|
395 | + public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom) |
|
396 | 396 | { |
397 | - $nbquestionresult = 0; |
|
398 | - $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
399 | - for ($i=0; $i < count($tabcatid); $i++) { |
|
400 | - if ($tabcatid[$i] > 0) { // 0 = no category for this questio |
|
401 | - $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
402 | - if ($nbQuestionInThisCat > $in_nbrandom) { |
|
403 | - $nbquestionresult += $in_nbrandom; |
|
404 | - } |
|
405 | - else { |
|
406 | - $nbquestionresult += $nbQuestionInThisCat; |
|
407 | - } |
|
408 | - } |
|
409 | - } |
|
410 | - return $nbquestionresult; |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * Return an array (id=>name) |
|
415 | - * tabresult[0] = get_lang('NoCategory'); |
|
397 | + $nbquestionresult = 0; |
|
398 | + $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
399 | + for ($i=0; $i < count($tabcatid); $i++) { |
|
400 | + if ($tabcatid[$i] > 0) { // 0 = no category for this questio |
|
401 | + $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
402 | + if ($nbQuestionInThisCat > $in_nbrandom) { |
|
403 | + $nbquestionresult += $in_nbrandom; |
|
404 | + } |
|
405 | + else { |
|
406 | + $nbquestionresult += $nbQuestionInThisCat; |
|
407 | + } |
|
408 | + } |
|
409 | + } |
|
410 | + return $nbquestionresult; |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Return an array (id=>name) |
|
415 | + * tabresult[0] = get_lang('NoCategory'); |
|
416 | 416 | * |
417 | 417 | * @param int $courseId |
418 | 418 | * |
419 | 419 | * @return array |
420 | - * |
|
421 | - */ |
|
420 | + * |
|
421 | + */ |
|
422 | 422 | public static function getCategoriesIdAndName($courseId = "") |
423 | 423 | { |
424 | - if (empty($courseId)) { |
|
425 | - $courseId = api_get_course_int_id(); |
|
426 | - } |
|
427 | - $tabcatobject = TestCategory::getCategoryListInfo("", $courseId); |
|
428 | - $tabresult = array("0"=>get_lang('NoCategorySelected')); |
|
429 | - for ($i=0; $i < count($tabcatobject); $i++) { |
|
430 | - $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name; |
|
431 | - } |
|
432 | - return $tabresult; |
|
433 | - } |
|
424 | + if (empty($courseId)) { |
|
425 | + $courseId = api_get_course_int_id(); |
|
426 | + } |
|
427 | + $tabcatobject = TestCategory::getCategoryListInfo("", $courseId); |
|
428 | + $tabresult = array("0"=>get_lang('NoCategorySelected')); |
|
429 | + for ($i=0; $i < count($tabcatobject); $i++) { |
|
430 | + $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name; |
|
431 | + } |
|
432 | + return $tabresult; |
|
433 | + } |
|
434 | 434 | |
435 | 435 | /** |
436 | - * return an array of question_id for each category |
|
437 | - * tabres[0] = array of question id with category id = 0 (i.e. no category) |
|
438 | - * tabres[24] = array of question id with category id = 24 |
|
439 | - * In this version, a question has 0 or 1 category |
|
440 | - * |
|
441 | - * @param int $exerciseId |
|
442 | - * @return array |
|
443 | - */ |
|
436 | + * return an array of question_id for each category |
|
437 | + * tabres[0] = array of question id with category id = 0 (i.e. no category) |
|
438 | + * tabres[24] = array of question id with category id = 24 |
|
439 | + * In this version, a question has 0 or 1 category |
|
440 | + * |
|
441 | + * @param int $exerciseId |
|
442 | + * @return array |
|
443 | + */ |
|
444 | 444 | public static function getQuestionsByCat($exerciseId) |
445 | 445 | { |
446 | 446 | $em = Database::getManager(); |
@@ -469,29 +469,29 @@ discard block |
||
469 | 469 | } |
470 | 470 | $list[$data['categoryId']][] = $data['questionId']; |
471 | 471 | } |
472 | - return $list; |
|
473 | - } |
|
472 | + return $list; |
|
473 | + } |
|
474 | 474 | |
475 | - /** |
|
476 | - * return a tab of $in_number random elements of $in_tab |
|
477 | - */ |
|
475 | + /** |
|
476 | + * return a tab of $in_number random elements of $in_tab |
|
477 | + */ |
|
478 | 478 | public static function getNElementsFromArray($in_tab, $in_number) |
479 | 479 | { |
480 | - $tabres = $in_tab; |
|
481 | - shuffle($tabres); |
|
482 | - if ($in_number < count($tabres)) { |
|
483 | - $tabres = array_slice($tabres, 0, $in_number); |
|
484 | - } |
|
485 | - return $tabres; |
|
486 | - } |
|
487 | - |
|
488 | - /** |
|
489 | - * display the category |
|
490 | - */ |
|
491 | - public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1) |
|
480 | + $tabres = $in_tab; |
|
481 | + shuffle($tabres); |
|
482 | + if ($in_number < count($tabres)) { |
|
483 | + $tabres = array_slice($tabres, 0, $in_number); |
|
484 | + } |
|
485 | + return $tabres; |
|
486 | + } |
|
487 | + |
|
488 | + /** |
|
489 | + * display the category |
|
490 | + */ |
|
491 | + public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1) |
|
492 | 492 | { |
493 | 493 | echo self::returnCategoryAndTitle($questionId, $in_display_category_name); |
494 | - } |
|
494 | + } |
|
495 | 495 | |
496 | 496 | /** |
497 | 497 | * @param int $questionId |
@@ -507,71 +507,71 @@ discard block |
||
507 | 507 | $in_display_category_name = $objExercise->display_category_name; |
508 | 508 | } |
509 | 509 | $content = null; |
510 | - if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) { |
|
510 | + if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) { |
|
511 | 511 | $content .= '<div class="page-header">'; |
512 | 512 | $content .= '<h4>'.get_lang('Category').": ".TestCategory::getCategoryNameForQuestion($questionId).'</h4>'; |
513 | 513 | $content .= "</div>"; |
514 | - } |
|
514 | + } |
|
515 | 515 | return $content; |
516 | - } |
|
516 | + } |
|
517 | 517 | |
518 | 518 | /** |
519 | - * Display signs [+] and/or (>0) after question title if question has options |
|
520 | - * scoreAlwaysPositive and/or uncheckedMayScore |
|
521 | - */ |
|
519 | + * Display signs [+] and/or (>0) after question title if question has options |
|
520 | + * scoreAlwaysPositive and/or uncheckedMayScore |
|
521 | + */ |
|
522 | 522 | public function displayQuestionOption($in_objQuestion) |
523 | 523 | { |
524 | - if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
|
525 | - echo "<span style='font-size:75%'> (>0)</span>"; |
|
526 | - } |
|
527 | - if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) { |
|
528 | - echo "<span style='font-size:75%'> [+]</span>"; |
|
529 | - } |
|
530 | - } |
|
531 | - |
|
532 | - /** |
|
533 | - * sortTabByBracketLabel ($tabCategoryQuestions) |
|
534 | - * key of $tabCategoryQuestions are the category id (0 for not in a category) |
|
535 | - * value is the array of question id of this category |
|
536 | - * Sort question by Category |
|
537 | - */ |
|
524 | + if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
|
525 | + echo "<span style='font-size:75%'> (>0)</span>"; |
|
526 | + } |
|
527 | + if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) { |
|
528 | + echo "<span style='font-size:75%'> [+]</span>"; |
|
529 | + } |
|
530 | + } |
|
531 | + |
|
532 | + /** |
|
533 | + * sortTabByBracketLabel ($tabCategoryQuestions) |
|
534 | + * key of $tabCategoryQuestions are the category id (0 for not in a category) |
|
535 | + * value is the array of question id of this category |
|
536 | + * Sort question by Category |
|
537 | + */ |
|
538 | 538 | public static function sortTabByBracketLabel($in_tab) |
539 | 539 | { |
540 | - $tabResult = array(); |
|
541 | - $tabCatName = array(); // tab of category name |
|
542 | - while (list($cat_id, $tabquestion) = each($in_tab)) { |
|
543 | - $catTitle = new TestCategory($cat_id); |
|
544 | - $tabCatName[$cat_id] = $catTitle->name; |
|
545 | - } |
|
546 | - reset($in_tab); |
|
547 | - // sort table by value, keeping keys as they are |
|
548 | - asort($tabCatName); |
|
549 | - // keys of $tabCatName are keys order for $in_tab |
|
550 | - while (list($key, $val) = each($tabCatName)) { |
|
551 | - $tabResult[$key] = $in_tab[$key]; |
|
552 | - } |
|
553 | - return $tabResult; |
|
554 | - } |
|
540 | + $tabResult = array(); |
|
541 | + $tabCatName = array(); // tab of category name |
|
542 | + while (list($cat_id, $tabquestion) = each($in_tab)) { |
|
543 | + $catTitle = new TestCategory($cat_id); |
|
544 | + $tabCatName[$cat_id] = $catTitle->name; |
|
545 | + } |
|
546 | + reset($in_tab); |
|
547 | + // sort table by value, keeping keys as they are |
|
548 | + asort($tabCatName); |
|
549 | + // keys of $tabCatName are keys order for $in_tab |
|
550 | + while (list($key, $val) = each($tabCatName)) { |
|
551 | + $tabResult[$key] = $in_tab[$key]; |
|
552 | + } |
|
553 | + return $tabResult; |
|
554 | + } |
|
555 | 555 | |
556 | 556 | /** |
557 | 557 | * return the number max of question in a category |
558 | 558 | * count the number of questions in all categories, and return the max |
559 | 559 | * @param int $exerciseId |
560 | 560 | * @author - hubert borderiou |
561 | - */ |
|
561 | + */ |
|
562 | 562 | public static function getNumberMaxQuestionByCat($exerciseId) |
563 | 563 | { |
564 | 564 | $res_num_max = 0; |
565 | 565 | // foreach question |
566 | - $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
567 | - for ($i=0; $i < count($tabcatid); $i++) { |
|
568 | - if ($tabcatid[$i] > 0) { // 0 = no category for this question |
|
569 | - $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
566 | + $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
567 | + for ($i=0; $i < count($tabcatid); $i++) { |
|
568 | + if ($tabcatid[$i] > 0) { // 0 = no category for this question |
|
569 | + $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
570 | 570 | if ($nbQuestionInThisCat > $res_num_max) { |
571 | 571 | $res_num_max = $nbQuestionInThisCat; |
572 | 572 | } |
573 | - } |
|
574 | - } |
|
573 | + } |
|
574 | + } |
|
575 | 575 | return $res_num_max; |
576 | 576 | } |
577 | 577 | |
@@ -677,8 +677,8 @@ discard block |
||
677 | 677 | * @param int $categoryId |
678 | 678 | * @param int $questionId |
679 | 679 | * @param int $courseId |
680 | - * |
|
681 | - * @return int |
|
680 | + * |
|
681 | + * @return int |
|
682 | 682 | */ |
683 | 683 | public static function add_category_for_question_id($categoryId, $questionId, $courseId) |
684 | 684 | { |
@@ -686,18 +686,18 @@ discard block |
||
686 | 686 | // if question doesn't have a category |
687 | 687 | // @todo change for 1.10 when a question can have several categories |
688 | 688 | if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 && |
689 | - $questionId > 0 && |
|
690 | - $courseId > 0 |
|
689 | + $questionId > 0 && |
|
690 | + $courseId > 0 |
|
691 | 691 | ) { |
692 | 692 | $sql = "INSERT INTO $table (c_id, question_id, category_id) |
693 | 693 | VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")"; |
694 | 694 | Database::query($sql); |
695 | - $id = Database::insert_id(); |
|
695 | + $id = Database::insert_id(); |
|
696 | 696 | |
697 | - return $id; |
|
697 | + return $id; |
|
698 | 698 | } |
699 | 699 | |
700 | - return false; |
|
700 | + return false; |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | - * abstract function which creates the form to create/edit the answers of the question |
|
182 | - * @param FormValidator $form |
|
183 | - */ |
|
181 | + * abstract function which creates the form to create/edit the answers of the question |
|
182 | + * @param FormValidator $form |
|
183 | + */ |
|
184 | 184 | public function processAnswersCreation($form) |
185 | 185 | { |
186 | 186 | $questionWeighting = $nbrGoodAnswers = 0; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | // sets the total weighting of the question |
222 | 222 | $this->updateWeighting($questionWeighting); |
223 | 223 | $this->save(); |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | 226 | function return_header($feedback_type = null, $counter = null, $score = null) |
227 | 227 | { |