@@ -3,121 +3,121 @@ discard block |
||
3 | 3 | * Validates imported data. |
4 | 4 | */ |
5 | 5 | function validate_data($users) { |
6 | - global $defined_auth_sources; |
|
7 | - $errors = array (); |
|
8 | - $usernames = array (); |
|
9 | - if(is_array($users)) { |
|
10 | - foreach ($users as $index => $user) { |
|
11 | - // 1. Check whether mandatory fields have been set. |
|
12 | - $mandatory_fields = array ('LastName', 'FirstName'); |
|
13 | - if (api_get_setting('registration', 'email') == 'true') { |
|
14 | - $mandatory_fields[] = 'Email'; |
|
15 | - } |
|
16 | - foreach ($mandatory_fields as $key => $field) { |
|
17 | - if (!isset ($user[$field]) || strlen($user[$field]) == 0) { |
|
18 | - $user['error'] = get_lang($field.'Mandatory'); |
|
19 | - $errors[] = $user; |
|
20 | - } |
|
21 | - } |
|
22 | - // 2. Check username. |
|
23 | - if (!UserManager::is_username_empty($user['UserName'])) { |
|
24 | - // 2.1. Check whether username was used twice in the import file. |
|
25 | - if (isset($usernames[$user['UserName']])) { |
|
26 | - $user['error'] = get_lang('UserNameUsedTwice'); |
|
27 | - $errors[] = $user; |
|
28 | - } |
|
29 | - $usernames[$user['UserName']] = 1; |
|
30 | - // 2.2. Check whether username is allready in use in database. |
|
31 | - if (!UserManager::is_username_available($user['UserName'])) { |
|
32 | - $user['error'] = get_lang('UserNameNotAvailable'); |
|
33 | - $errors[] = $user; |
|
34 | - } |
|
35 | - // 2.3. Check whether username is too long. |
|
36 | - if (UserManager::is_username_too_long($user['UserName'])) { |
|
37 | - $user['error'] = get_lang('UserNameTooLong'); |
|
38 | - $errors[] = $user; |
|
39 | - } |
|
40 | - } |
|
41 | - // 3. Check status. |
|
42 | - if (isset ($user['Status']) && !api_status_exists($user['Status'])) { |
|
43 | - $user['error'] = get_lang('WrongStatus'); |
|
44 | - $errors[] = $user; |
|
45 | - } |
|
46 | - // 5. Check authentication source. |
|
47 | - if (isset ($user['AuthSource']) && strlen($user['AuthSource']) != 0) { |
|
48 | - if (!in_array($user['AuthSource'], $defined_auth_sources)) { |
|
49 | - $user['error'] = get_lang('AuthSourceNotAvailable'); |
|
50 | - $errors[] = $user; |
|
51 | - } |
|
52 | - } |
|
53 | - } |
|
54 | - } |
|
55 | - return $errors; |
|
6 | + global $defined_auth_sources; |
|
7 | + $errors = array (); |
|
8 | + $usernames = array (); |
|
9 | + if(is_array($users)) { |
|
10 | + foreach ($users as $index => $user) { |
|
11 | + // 1. Check whether mandatory fields have been set. |
|
12 | + $mandatory_fields = array ('LastName', 'FirstName'); |
|
13 | + if (api_get_setting('registration', 'email') == 'true') { |
|
14 | + $mandatory_fields[] = 'Email'; |
|
15 | + } |
|
16 | + foreach ($mandatory_fields as $key => $field) { |
|
17 | + if (!isset ($user[$field]) || strlen($user[$field]) == 0) { |
|
18 | + $user['error'] = get_lang($field.'Mandatory'); |
|
19 | + $errors[] = $user; |
|
20 | + } |
|
21 | + } |
|
22 | + // 2. Check username. |
|
23 | + if (!UserManager::is_username_empty($user['UserName'])) { |
|
24 | + // 2.1. Check whether username was used twice in the import file. |
|
25 | + if (isset($usernames[$user['UserName']])) { |
|
26 | + $user['error'] = get_lang('UserNameUsedTwice'); |
|
27 | + $errors[] = $user; |
|
28 | + } |
|
29 | + $usernames[$user['UserName']] = 1; |
|
30 | + // 2.2. Check whether username is allready in use in database. |
|
31 | + if (!UserManager::is_username_available($user['UserName'])) { |
|
32 | + $user['error'] = get_lang('UserNameNotAvailable'); |
|
33 | + $errors[] = $user; |
|
34 | + } |
|
35 | + // 2.3. Check whether username is too long. |
|
36 | + if (UserManager::is_username_too_long($user['UserName'])) { |
|
37 | + $user['error'] = get_lang('UserNameTooLong'); |
|
38 | + $errors[] = $user; |
|
39 | + } |
|
40 | + } |
|
41 | + // 3. Check status. |
|
42 | + if (isset ($user['Status']) && !api_status_exists($user['Status'])) { |
|
43 | + $user['error'] = get_lang('WrongStatus'); |
|
44 | + $errors[] = $user; |
|
45 | + } |
|
46 | + // 5. Check authentication source. |
|
47 | + if (isset ($user['AuthSource']) && strlen($user['AuthSource']) != 0) { |
|
48 | + if (!in_array($user['AuthSource'], $defined_auth_sources)) { |
|
49 | + $user['error'] = get_lang('AuthSourceNotAvailable'); |
|
50 | + $errors[] = $user; |
|
51 | + } |
|
52 | + } |
|
53 | + } |
|
54 | + } |
|
55 | + return $errors; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Adds missing user-information (which isn't required, like password, username, etc). |
60 | 60 | */ |
61 | 61 | function complete_missing_data($user) { |
62 | - // 1. Create a username if necessary. |
|
63 | - if (UserManager::is_username_empty($user['UserName'])) { |
|
64 | - $user['UserName'] = UserManager::create_unique_username($user['FirstName'], $user['LastName']); |
|
65 | - } |
|
66 | - // 2. Generate a password if necessary. |
|
67 | - if (!isset ($user['Password']) || strlen($user['Password']) == 0) { |
|
68 | - $user['Password'] = api_generate_password(); |
|
69 | - } |
|
70 | - // 3. set status if not allready set. |
|
71 | - if (!isset ($user['Status']) || strlen($user['Status']) == 0) { |
|
72 | - $user['Status'] = 'user'; |
|
73 | - } |
|
74 | - // 4. Set authsource if not allready set. |
|
75 | - if (!isset ($user['AuthSource']) || strlen($user['AuthSource']) == 0) { |
|
76 | - $user['AuthSource'] = PLATFORM_AUTH_SOURCE; |
|
77 | - } |
|
78 | - return $user; |
|
62 | + // 1. Create a username if necessary. |
|
63 | + if (UserManager::is_username_empty($user['UserName'])) { |
|
64 | + $user['UserName'] = UserManager::create_unique_username($user['FirstName'], $user['LastName']); |
|
65 | + } |
|
66 | + // 2. Generate a password if necessary. |
|
67 | + if (!isset ($user['Password']) || strlen($user['Password']) == 0) { |
|
68 | + $user['Password'] = api_generate_password(); |
|
69 | + } |
|
70 | + // 3. set status if not allready set. |
|
71 | + if (!isset ($user['Status']) || strlen($user['Status']) == 0) { |
|
72 | + $user['Status'] = 'user'; |
|
73 | + } |
|
74 | + // 4. Set authsource if not allready set. |
|
75 | + if (!isset ($user['AuthSource']) || strlen($user['AuthSource']) == 0) { |
|
76 | + $user['AuthSource'] = PLATFORM_AUTH_SOURCE; |
|
77 | + } |
|
78 | + return $user; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Save the imported data |
83 | 83 | */ |
84 | 84 | function save_data($users) { |
85 | - $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
|
86 | - if(is_array($users)) { |
|
87 | - foreach ($users as $index => $user) { |
|
88 | - $user = complete_missing_data($user); |
|
85 | + $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
|
86 | + if(is_array($users)) { |
|
87 | + foreach ($users as $index => $user) { |
|
88 | + $user = complete_missing_data($user); |
|
89 | 89 | |
90 | - $user['Status'] = api_status_key($user['Status']); |
|
90 | + $user['Status'] = api_status_key($user['Status']); |
|
91 | 91 | |
92 | - $user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']); |
|
93 | - foreach ($user['Courses'] as $index => $course) { |
|
94 | - if(CourseManager :: course_exists($course)) |
|
95 | - CourseManager :: subscribe_user($user_id, $course,$user['Status']); |
|
96 | - } |
|
92 | + $user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']); |
|
93 | + foreach ($user['Courses'] as $index => $course) { |
|
94 | + if(CourseManager :: course_exists($course)) |
|
95 | + CourseManager :: subscribe_user($user_id, $course,$user['Status']); |
|
96 | + } |
|
97 | 97 | |
98 | - // TODO: Hard-coded French texts. |
|
98 | + // TODO: Hard-coded French texts. |
|
99 | 99 | |
100 | - // Qualite |
|
101 | - if (!empty($user['Qualite'])) { |
|
102 | - UserManager::update_extra_field_value($user_id, 'qualite', $user['Qualite']); |
|
103 | - } |
|
100 | + // Qualite |
|
101 | + if (!empty($user['Qualite'])) { |
|
102 | + UserManager::update_extra_field_value($user_id, 'qualite', $user['Qualite']); |
|
103 | + } |
|
104 | 104 | |
105 | - // Categorie |
|
106 | - if (!empty($user['Categorie'])) { |
|
107 | - UserManager::update_extra_field_value($user_id, 'categorie', $user['Categorie']); |
|
108 | - } |
|
105 | + // Categorie |
|
106 | + if (!empty($user['Categorie'])) { |
|
107 | + UserManager::update_extra_field_value($user_id, 'categorie', $user['Categorie']); |
|
108 | + } |
|
109 | 109 | |
110 | - // Etat |
|
111 | - if (!empty($user['Etat'])) { |
|
112 | - UserManager::update_extra_field_value($user_id, 'etat', $user['Etat']); |
|
113 | - } |
|
110 | + // Etat |
|
111 | + if (!empty($user['Etat'])) { |
|
112 | + UserManager::update_extra_field_value($user_id, 'etat', $user['Etat']); |
|
113 | + } |
|
114 | 114 | |
115 | - // Niveau |
|
116 | - if (!empty($user['Niveau'])) { |
|
117 | - UserManager::update_extra_field_value($user_id, 'niveau', $user['Niveau']); |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
115 | + // Niveau |
|
116 | + if (!empty($user['Niveau'])) { |
|
117 | + UserManager::update_extra_field_value($user_id, 'niveau', $user['Niveau']); |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | * @return array All userinformation read from the file |
127 | 127 | */ |
128 | 128 | function parse_csv_data($file) { |
129 | - $users = Import :: csvToArray($file); |
|
130 | - foreach ($users as $index => $user) { |
|
131 | - if (isset ($user['Courses'])) { |
|
132 | - $user['Courses'] = explode('|', trim($user['Courses'])); |
|
133 | - } |
|
134 | - $users[$index] = $user; |
|
135 | - } |
|
136 | - return $users; |
|
129 | + $users = Import :: csvToArray($file); |
|
130 | + foreach ($users as $index => $user) { |
|
131 | + if (isset ($user['Courses'])) { |
|
132 | + $user['Courses'] = explode('|', trim($user['Courses'])); |
|
133 | + } |
|
134 | + $users[$index] = $user; |
|
135 | + } |
|
136 | + return $users; |
|
137 | 137 | } |
@@ -14,20 +14,20 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class UniqueAnswerNoOption extends Question |
16 | 16 | { |
17 | - public static $typePicture = 'mcuao.png'; |
|
18 | - public static $explanationLangVar = 'UniqueAnswerNoOption'; |
|
17 | + public static $typePicture = 'mcuao.png'; |
|
18 | + public static $explanationLangVar = 'UniqueAnswerNoOption'; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Constructor |
|
22 | - */ |
|
23 | - public function __construct() |
|
20 | + /** |
|
21 | + * Constructor |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | 24 | { |
25 | - parent::__construct(); |
|
26 | - $this -> type = UNIQUE_ANSWER_NO_OPTION; |
|
27 | - $this -> isContent = $this-> getIsContent(); |
|
28 | - } |
|
25 | + parent::__construct(); |
|
26 | + $this -> type = UNIQUE_ANSWER_NO_OPTION; |
|
27 | + $this -> isContent = $this-> getIsContent(); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
30 | + /** |
|
31 | 31 | * function which redifines Question::createAnswersForm |
32 | 32 | * @param the formvalidator instance |
33 | 33 | * @param the answers number to display |
@@ -283,37 +283,37 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | - * Function which creates the form to create / edit the answers of the question |
|
287 | - * @param the formvalidator instance |
|
288 | - * @param the answers number to display |
|
289 | - */ |
|
290 | - function processAnswersCreation($form) |
|
286 | + * Function which creates the form to create / edit the answers of the question |
|
287 | + * @param the formvalidator instance |
|
288 | + * @param the answers number to display |
|
289 | + */ |
|
290 | + function processAnswersCreation($form) |
|
291 | 291 | { |
292 | - $questionWeighting = $nbrGoodAnswers = 0; |
|
293 | - $correct = $form -> getSubmitValue('correct'); |
|
294 | - $objAnswer = new Answer($this->id); |
|
295 | - $nb_answers = $form -> getSubmitValue('nb_answers'); |
|
296 | - $minus = 1; |
|
297 | - if ($form -> getSubmitValue('new_question')) { |
|
298 | - $minus = 0; |
|
299 | - } |
|
300 | - |
|
301 | - for ($i=1 ; $i <= $nb_answers - $minus; $i++) { |
|
302 | - $position = trim($form -> getSubmitValue('position['.$i.']')); |
|
303 | - $answer = trim($form -> getSubmitValue('answer['.$i.']')); |
|
292 | + $questionWeighting = $nbrGoodAnswers = 0; |
|
293 | + $correct = $form -> getSubmitValue('correct'); |
|
294 | + $objAnswer = new Answer($this->id); |
|
295 | + $nb_answers = $form -> getSubmitValue('nb_answers'); |
|
296 | + $minus = 1; |
|
297 | + if ($form -> getSubmitValue('new_question')) { |
|
298 | + $minus = 0; |
|
299 | + } |
|
300 | + |
|
301 | + for ($i=1 ; $i <= $nb_answers - $minus; $i++) { |
|
302 | + $position = trim($form -> getSubmitValue('position['.$i.']')); |
|
303 | + $answer = trim($form -> getSubmitValue('answer['.$i.']')); |
|
304 | 304 | $comment = trim($form -> getSubmitValue('comment['.$i.']')); |
305 | 305 | $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); |
306 | 306 | $scenario = $form -> getSubmitValue('scenario'); |
307 | 307 | |
308 | - //$list_destination = $form -> getSubmitValue('destination'.$i); |
|
309 | - //$destination_str = $form -> getSubmitValue('destination'.$i); |
|
308 | + //$list_destination = $form -> getSubmitValue('destination'.$i); |
|
309 | + //$destination_str = $form -> getSubmitValue('destination'.$i); |
|
310 | 310 | |
311 | - $try = $scenario['try'.$i]; |
|
311 | + $try = $scenario['try'.$i]; |
|
312 | 312 | $lp = $scenario['lp'.$i]; |
313 | - $destination = $scenario['destination'.$i]; |
|
314 | - $url = trim($scenario['url'.$i]); |
|
313 | + $destination = $scenario['destination'.$i]; |
|
314 | + $url = trim($scenario['url'.$i]); |
|
315 | 315 | |
316 | - /* |
|
316 | + /* |
|
317 | 317 | How we are going to parse the destination value |
318 | 318 | |
319 | 319 | here we parse the destination value which is a string |
@@ -326,41 +326,41 @@ discard block |
||
326 | 326 | selected_questions= ids of questions |
327 | 327 | url= an url |
328 | 328 | */ |
329 | - /* |
|
329 | + /* |
|
330 | 330 | $destination_str=''; |
331 | 331 | foreach ($list_destination as $destination_id) |
332 | 332 | { |
333 | 333 | $destination_str.=$destination_id.';'; |
334 | 334 | }*/ |
335 | 335 | |
336 | - $goodAnswer= ($correct == $i) ? true : false; |
|
336 | + $goodAnswer= ($correct == $i) ? true : false; |
|
337 | 337 | |
338 | - if ($goodAnswer) { |
|
339 | - $nbrGoodAnswers++; |
|
340 | - $weighting = abs($weighting); |
|
341 | - if($weighting > 0) { |
|
338 | + if ($goodAnswer) { |
|
339 | + $nbrGoodAnswers++; |
|
340 | + $weighting = abs($weighting); |
|
341 | + if($weighting > 0) { |
|
342 | 342 | $questionWeighting += $weighting; |
343 | 343 | } |
344 | - } |
|
344 | + } |
|
345 | 345 | |
346 | - if (empty($try)) |
|
347 | - $try=0; |
|
346 | + if (empty($try)) |
|
347 | + $try=0; |
|
348 | 348 | |
349 | - if (empty($lp)) { |
|
350 | - $lp=0; |
|
351 | - } |
|
349 | + if (empty($lp)) { |
|
350 | + $lp=0; |
|
351 | + } |
|
352 | 352 | |
353 | - if (empty($destination)) { |
|
354 | - $destination=0; |
|
355 | - } |
|
353 | + if (empty($destination)) { |
|
354 | + $destination=0; |
|
355 | + } |
|
356 | 356 | |
357 | - if ($url=='') { |
|
358 | - $url=0; |
|
359 | - } |
|
357 | + if ($url=='') { |
|
358 | + $url=0; |
|
359 | + } |
|
360 | 360 | |
361 | - //1@@1;2;@@2;4;4;@@http://www.chamilo.org |
|
362 | - $dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url; |
|
363 | - $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest); |
|
361 | + //1@@1;2;@@2;4;4;@@http://www.chamilo.org |
|
362 | + $dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url; |
|
363 | + $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | //Create 666 answer |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | |
374 | 374 | $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest); |
375 | 375 | |
376 | - // saves the answers into the data base |
|
376 | + // saves the answers into the data base |
|
377 | 377 | $objAnswer -> save(); |
378 | 378 | |
379 | 379 | // sets the total weighting of the question |
380 | 380 | $this -> updateWeighting($questionWeighting); |
381 | 381 | $this -> save(); |
382 | - } |
|
382 | + } |
|
383 | 383 | |
384 | - function return_header($feedback_type = null, $counter = null, $score = null) |
|
384 | + function return_header($feedback_type = null, $counter = null, $score = null) |
|
385 | 385 | { |
386 | - $header = parent::return_header($feedback_type, $counter, $score); |
|
387 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
386 | + $header = parent::return_header($feedback_type, $counter, $score); |
|
387 | + $header .= '<table class="'.$this->question_table_class .'"> |
|
388 | 388 | <tr> |
389 | 389 | <th>'.get_lang("Choice").'</th> |
390 | 390 | <th>'. get_lang("ExpectedChoice").'</th> |
@@ -392,5 +392,5 @@ discard block |
||
392 | 392 | $header .= '<th>'.get_lang("Comment").'</th>'; |
393 | 393 | $header .= '</tr>'; |
394 | 394 | return $header; |
395 | - } |
|
395 | + } |
|
396 | 396 | } |
@@ -25,8 +25,8 @@ |
||
25 | 25 | // user clicked ON a hotspot |
26 | 26 | $hit = 1; |
27 | 27 | $answerId = api_substr($_GET['answerId'],22,2); |
28 | - // Save into session |
|
29 | - $_SESSION['exerciseResult'][$questionId][$answerId] = $hit; |
|
28 | + // Save into session |
|
29 | + $_SESSION['exerciseResult'][$questionId][$answerId] = $hit; |
|
30 | 30 | } |
31 | 31 | //round-up the coordinates |
32 | 32 | $coords = explode('/',$coordinates); |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | public $name; |
16 | 16 | public $description; |
17 | 17 | |
18 | - /** |
|
19 | - * Constructor of the class Category |
|
20 | - * If you give an in_id and no in_name, you get info concerning the category of id=in_id |
|
21 | - * otherwise, you've got an category objet avec your in_id, in_name, in_descr |
|
22 | - * |
|
18 | + /** |
|
19 | + * Constructor of the class Category |
|
20 | + * If you give an in_id and no in_name, you get info concerning the category of id=in_id |
|
21 | + * otherwise, you've got an category objet avec your in_id, in_name, in_descr |
|
22 | + * |
|
23 | 23 | * @param int $id |
24 | 24 | * @param string $name |
25 | 25 | * @param string $description |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
66 | + /** |
|
67 | 67 | * add TestCategory in the database if name doesn't already exists |
68 | - */ |
|
68 | + */ |
|
69 | 69 | public function addCategoryInBDD() |
70 | 70 | { |
71 | 71 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | |
111 | 111 | return false; |
112 | 112 | } |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
115 | + /** |
|
116 | 116 | * Removes the category from the database |
117 | 117 | * if there were question in this category, the link between question and category is removed |
118 | - */ |
|
118 | + */ |
|
119 | 119 | public function removeCategory() |
120 | 120 | { |
121 | 121 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | |
146 | 146 | return true; |
147 | 147 | } |
148 | - } |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
150 | + /** |
|
151 | 151 | * Modify category name or description of category with id=in_id |
152 | - */ |
|
152 | + */ |
|
153 | 153 | public function modifyCategory() |
154 | 154 | { |
155 | 155 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -177,40 +177,40 @@ discard block |
||
177 | 177 | |
178 | 178 | return true; |
179 | 179 | } |
180 | - } |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
182 | + /** |
|
183 | 183 | * Gets the number of question of category id=in_id |
184 | - */ |
|
184 | + */ |
|
185 | 185 | public function getCategoryQuestionsNumber() |
186 | 186 | { |
187 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
188 | - $in_id = intval($this->id); |
|
189 | - $sql = "SELECT count(*) AS nb |
|
187 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
188 | + $in_id = intval($this->id); |
|
189 | + $sql = "SELECT count(*) AS nb |
|
190 | 190 | FROM $table |
191 | 191 | WHERE category_id=$in_id AND c_id=".api_get_course_int_id(); |
192 | - $res = Database::query($sql); |
|
193 | - $row = Database::fetch_array($res); |
|
192 | + $res = Database::query($sql); |
|
193 | + $row = Database::fetch_array($res); |
|
194 | 194 | |
195 | - return $row['nb']; |
|
196 | - } |
|
195 | + return $row['nb']; |
|
196 | + } |
|
197 | 197 | |
198 | 198 | /** |
199 | 199 | * @param string $in_color |
200 | 200 | */ |
201 | 201 | public function display($in_color="#E0EBF5") |
202 | 202 | { |
203 | - echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>"; |
|
204 | - print_r($this); |
|
205 | - echo "</textarea>"; |
|
206 | - } |
|
203 | + echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>"; |
|
204 | + print_r($this); |
|
205 | + echo "</textarea>"; |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
208 | + /** |
|
209 | 209 | * Return an array of all Category objects in the database |
210 | - * If in_field=="" Return an array of all category objects in the database |
|
211 | - * Otherwise, return an array of all in_field value |
|
212 | - * in the database (in_field = id or name or description) |
|
213 | - */ |
|
210 | + * If in_field=="" Return an array of all category objects in the database |
|
211 | + * Otherwise, return an array of all in_field value |
|
212 | + * in the database (in_field = id or name or description) |
|
213 | + */ |
|
214 | 214 | public static function getCategoryListInfo($in_field = "", $courseId = "") |
215 | 215 | { |
216 | 216 | if (empty($courseId) || $courseId=="") { |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | - return $tabres; |
|
245 | - } |
|
244 | + return $tabres; |
|
245 | + } |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Return the TestCategory id for question with question_id = $questionId |
@@ -253,210 +253,210 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return int |
255 | 255 | */ |
256 | - public static function getCategoryForQuestion($questionId, $courseId ="") |
|
256 | + public static function getCategoryForQuestion($questionId, $courseId ="") |
|
257 | 257 | { |
258 | - $result = 0; |
|
258 | + $result = 0; |
|
259 | 259 | if (empty($courseId) || $courseId == "") { |
260 | 260 | $courseId = api_get_course_int_id(); |
261 | 261 | } |
262 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
262 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
263 | 263 | $questionId = intval($questionId); |
264 | - $sql = "SELECT category_id |
|
264 | + $sql = "SELECT category_id |
|
265 | 265 | FROM $table |
266 | 266 | WHERE question_id = $questionId AND c_id = $courseId"; |
267 | - $res = Database::query($sql); |
|
268 | - if (Database::num_rows($res) > 0) { |
|
267 | + $res = Database::query($sql); |
|
268 | + if (Database::num_rows($res) > 0) { |
|
269 | 269 | $data = Database::fetch_array($res); |
270 | - $result = $data['category_id']; |
|
271 | - } |
|
270 | + $result = $data['category_id']; |
|
271 | + } |
|
272 | 272 | |
273 | - return $result; |
|
274 | - } |
|
273 | + return $result; |
|
274 | + } |
|
275 | 275 | |
276 | - /** |
|
277 | - * true if question id has a category |
|
278 | - */ |
|
279 | - public static function isQuestionHasCategory($questionId) |
|
276 | + /** |
|
277 | + * true if question id has a category |
|
278 | + */ |
|
279 | + public static function isQuestionHasCategory($questionId) |
|
280 | 280 | { |
281 | - if (TestCategory::getCategoryForQuestion($questionId) > 0) { |
|
282 | - return true; |
|
283 | - } |
|
284 | - return false; |
|
285 | - } |
|
281 | + if (TestCategory::getCategoryForQuestion($questionId) > 0) { |
|
282 | + return true; |
|
283 | + } |
|
284 | + return false; |
|
285 | + } |
|
286 | 286 | |
287 | - /** |
|
287 | + /** |
|
288 | 288 | Return the category name for question with question_id = $questionId |
289 | 289 | In this version, a question has only 1 category. |
290 | 290 | Return the category id, "" if none |
291 | - */ |
|
291 | + */ |
|
292 | 292 | public static function getCategoryNameForQuestion( |
293 | 293 | $questionId, |
294 | 294 | $courseId = "" |
295 | 295 | ) { |
296 | - if (empty($courseId) || $courseId=="") { |
|
297 | - $courseId = api_get_course_int_id(); |
|
298 | - } |
|
299 | - $catid = TestCategory::getCategoryForQuestion($questionId, $courseId); |
|
300 | - $result = ""; // result |
|
301 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
302 | - $catid = intval($catid); |
|
303 | - $sql = "SELECT title FROM $table |
|
296 | + if (empty($courseId) || $courseId=="") { |
|
297 | + $courseId = api_get_course_int_id(); |
|
298 | + } |
|
299 | + $catid = TestCategory::getCategoryForQuestion($questionId, $courseId); |
|
300 | + $result = ""; // result |
|
301 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
302 | + $catid = intval($catid); |
|
303 | + $sql = "SELECT title FROM $table |
|
304 | 304 | WHERE id = $catid AND c_id = $courseId"; |
305 | - $res = Database::query($sql); |
|
306 | - $data = Database::fetch_array($res); |
|
307 | - if (Database::num_rows($res) > 0) { |
|
308 | - $result = $data['title']; |
|
309 | - } |
|
310 | - |
|
311 | - return $result; |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Return the list of differents categories ID for a test in the current course |
|
316 | - * input : test_id |
|
317 | - * return : array of category id (integer) |
|
318 | - * hubert.borderiou 07-04-2011 |
|
319 | - * @param int $exerciseId |
|
320 | - */ |
|
321 | - public static function getListOfCategoriesIDForTest($exerciseId) |
|
305 | + $res = Database::query($sql); |
|
306 | + $data = Database::fetch_array($res); |
|
307 | + if (Database::num_rows($res) > 0) { |
|
308 | + $result = $data['title']; |
|
309 | + } |
|
310 | + |
|
311 | + return $result; |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Return the list of differents categories ID for a test in the current course |
|
316 | + * input : test_id |
|
317 | + * return : array of category id (integer) |
|
318 | + * hubert.borderiou 07-04-2011 |
|
319 | + * @param int $exerciseId |
|
320 | + */ |
|
321 | + public static function getListOfCategoriesIDForTest($exerciseId) |
|
322 | 322 | { |
323 | - // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
324 | - $exercise = new Exercise(); |
|
325 | - $exercise->read($exerciseId, false); |
|
326 | - $categoriesInExercise = $exercise->getQuestionWithCategories(); |
|
327 | - // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
328 | - $categories = array(); |
|
323 | + // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
324 | + $exercise = new Exercise(); |
|
325 | + $exercise->read($exerciseId, false); |
|
326 | + $categoriesInExercise = $exercise->getQuestionWithCategories(); |
|
327 | + // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
328 | + $categories = array(); |
|
329 | 329 | if (!empty($categoriesInExercise)) { |
330 | - foreach ($categoriesInExercise as $category) { |
|
331 | - //$category['id'] = $category['iid']; |
|
332 | - $categories[$category['id']] = $category; |
|
333 | - } |
|
334 | - } |
|
335 | - |
|
336 | - return $categories; |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * @param Exercise $exercise_obj |
|
341 | - * @return array |
|
342 | - */ |
|
343 | - public static function getListOfCategoriesIDForTestObject(Exercise $exercise_obj) |
|
344 | - { |
|
345 | - // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
346 | - $categories_in_exercise = array(); |
|
347 | - // $question_list = $exercise_obj->getQuestionList(); |
|
348 | - $question_list = $exercise_obj->getQuestionOrderedListByName(); |
|
349 | - |
|
350 | - // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
351 | - foreach ($question_list as $questionInfo) { |
|
352 | - $question_id = $questionInfo['question_id']; |
|
353 | - $category_list = self::getCategoryForQuestion($question_id); |
|
354 | - if (is_numeric($category_list)) { |
|
355 | - $category_list = array($category_list); |
|
356 | - } |
|
357 | - |
|
358 | - if (!empty($category_list)) { |
|
359 | - $categories_in_exercise = array_merge($categories_in_exercise, $category_list); |
|
360 | - } |
|
361 | - } |
|
362 | - if (!empty($categories_in_exercise)) { |
|
363 | - $categories_in_exercise = array_unique(array_filter($categories_in_exercise)); |
|
364 | - } |
|
365 | - return $categories_in_exercise; |
|
366 | - } |
|
367 | - |
|
368 | - /** |
|
369 | - * Return the list of differents categories NAME for a test |
|
370 | - * @param int exercise id |
|
371 | - * @param bool |
|
372 | - * @return integer of string |
|
373 | - * |
|
330 | + foreach ($categoriesInExercise as $category) { |
|
331 | + //$category['id'] = $category['iid']; |
|
332 | + $categories[$category['id']] = $category; |
|
333 | + } |
|
334 | + } |
|
335 | + |
|
336 | + return $categories; |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * @param Exercise $exercise_obj |
|
341 | + * @return array |
|
342 | + */ |
|
343 | + public static function getListOfCategoriesIDForTestObject(Exercise $exercise_obj) |
|
344 | + { |
|
345 | + // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
346 | + $categories_in_exercise = array(); |
|
347 | + // $question_list = $exercise_obj->getQuestionList(); |
|
348 | + $question_list = $exercise_obj->getQuestionOrderedListByName(); |
|
349 | + |
|
350 | + // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
351 | + foreach ($question_list as $questionInfo) { |
|
352 | + $question_id = $questionInfo['question_id']; |
|
353 | + $category_list = self::getCategoryForQuestion($question_id); |
|
354 | + if (is_numeric($category_list)) { |
|
355 | + $category_list = array($category_list); |
|
356 | + } |
|
357 | + |
|
358 | + if (!empty($category_list)) { |
|
359 | + $categories_in_exercise = array_merge($categories_in_exercise, $category_list); |
|
360 | + } |
|
361 | + } |
|
362 | + if (!empty($categories_in_exercise)) { |
|
363 | + $categories_in_exercise = array_unique(array_filter($categories_in_exercise)); |
|
364 | + } |
|
365 | + return $categories_in_exercise; |
|
366 | + } |
|
367 | + |
|
368 | + /** |
|
369 | + * Return the list of differents categories NAME for a test |
|
370 | + * @param int exercise id |
|
371 | + * @param bool |
|
372 | + * @return integer of string |
|
373 | + * |
|
374 | 374 | * @author function rewrote by jmontoya |
375 | - */ |
|
376 | - public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true) |
|
375 | + */ |
|
376 | + public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true) |
|
377 | 377 | { |
378 | - $result = array(); |
|
379 | - $categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category); |
|
378 | + $result = array(); |
|
379 | + $categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category); |
|
380 | 380 | |
381 | - foreach ($categories as $catInfo) { |
|
382 | - $categoryId = $catInfo['id']; |
|
383 | - if (!empty($categoryId)) { |
|
384 | - $result[$categoryId] = array( |
|
381 | + foreach ($categories as $catInfo) { |
|
382 | + $categoryId = $catInfo['id']; |
|
383 | + if (!empty($categoryId)) { |
|
384 | + $result[$categoryId] = array( |
|
385 | 385 | 'title' => $catInfo['title'], |
386 | 386 | //'parent_id' => $catInfo['parent_id'], |
387 | - 'parent_id' => '', |
|
387 | + 'parent_id' => '', |
|
388 | 388 | 'c_id' => $catInfo['c_id'] |
389 | 389 | ); |
390 | - } |
|
391 | - } |
|
392 | - |
|
393 | - return $result; |
|
394 | - } |
|
395 | - |
|
396 | - /** |
|
397 | - * @param Exercise $exercise_obj |
|
398 | - * @return array |
|
399 | - */ |
|
400 | - public static function getListOfCategoriesForTest(Exercise $exercise_obj) |
|
401 | - { |
|
402 | - $result = array(); |
|
403 | - $categories = self::getListOfCategoriesIDForTestObject($exercise_obj); |
|
404 | - foreach ($categories as $cat_id) { |
|
405 | - $cat = new TestCategory($cat_id); |
|
406 | - $cat = (array)$cat; |
|
407 | - $cat['iid'] = $cat['id']; |
|
408 | - $cat['title'] = $cat['name']; |
|
409 | - $result[$cat['id']] = $cat; |
|
410 | - } |
|
411 | - return $result; |
|
412 | - } |
|
413 | - |
|
414 | - /** |
|
415 | - * return the number of differents categories for a test |
|
416 | - * input : test_id |
|
417 | - * return : integer |
|
418 | - * hubert.borderiou 07-04-2011 |
|
419 | - */ |
|
420 | - public static function getNumberOfCategoriesForTest($id) |
|
390 | + } |
|
391 | + } |
|
392 | + |
|
393 | + return $result; |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * @param Exercise $exercise_obj |
|
398 | + * @return array |
|
399 | + */ |
|
400 | + public static function getListOfCategoriesForTest(Exercise $exercise_obj) |
|
401 | + { |
|
402 | + $result = array(); |
|
403 | + $categories = self::getListOfCategoriesIDForTestObject($exercise_obj); |
|
404 | + foreach ($categories as $cat_id) { |
|
405 | + $cat = new TestCategory($cat_id); |
|
406 | + $cat = (array)$cat; |
|
407 | + $cat['iid'] = $cat['id']; |
|
408 | + $cat['title'] = $cat['name']; |
|
409 | + $result[$cat['id']] = $cat; |
|
410 | + } |
|
411 | + return $result; |
|
412 | + } |
|
413 | + |
|
414 | + /** |
|
415 | + * return the number of differents categories for a test |
|
416 | + * input : test_id |
|
417 | + * return : integer |
|
418 | + * hubert.borderiou 07-04-2011 |
|
419 | + */ |
|
420 | + public static function getNumberOfCategoriesForTest($id) |
|
421 | 421 | { |
422 | - return count(TestCategory::getListOfCategoriesIDForTest($id)); |
|
423 | - } |
|
422 | + return count(TestCategory::getListOfCategoriesIDForTest($id)); |
|
423 | + } |
|
424 | 424 | |
425 | - /** |
|
426 | - * return the number of question of a category id in a test |
|
427 | - * @param int $exerciseId |
|
425 | + /** |
|
426 | + * return the number of question of a category id in a test |
|
427 | + * @param int $exerciseId |
|
428 | 428 | * @param int $categoryId |
429 | 429 | * |
430 | - * @return integer |
|
430 | + * @return integer |
|
431 | 431 | * |
432 | - * @author hubert.borderiou 07-04-2011 |
|
433 | - */ |
|
434 | - public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId) |
|
432 | + * @author hubert.borderiou 07-04-2011 |
|
433 | + */ |
|
434 | + public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId) |
|
435 | 435 | { |
436 | - $nbCatResult = 0; |
|
437 | - $quiz = new Exercise(); |
|
438 | - $quiz->read($exerciseId); |
|
439 | - $tabQuestionList = $quiz->selectQuestionList(); |
|
440 | - // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ? |
|
441 | - for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
442 | - if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) { |
|
443 | - $nbCatResult++; |
|
444 | - } |
|
445 | - } |
|
446 | - |
|
447 | - return $nbCatResult; |
|
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * return the number of question for a test using random by category |
|
452 | - * input : test_id, number of random question (min 1) |
|
453 | - * hubert.borderiou 07-04-2011 |
|
454 | - * question without categories are not counted |
|
455 | - */ |
|
456 | - public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom) |
|
436 | + $nbCatResult = 0; |
|
437 | + $quiz = new Exercise(); |
|
438 | + $quiz->read($exerciseId); |
|
439 | + $tabQuestionList = $quiz->selectQuestionList(); |
|
440 | + // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ? |
|
441 | + for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
442 | + if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) { |
|
443 | + $nbCatResult++; |
|
444 | + } |
|
445 | + } |
|
446 | + |
|
447 | + return $nbCatResult; |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * return the number of question for a test using random by category |
|
452 | + * input : test_id, number of random question (min 1) |
|
453 | + * hubert.borderiou 07-04-2011 |
|
454 | + * question without categories are not counted |
|
455 | + */ |
|
456 | + public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom) |
|
457 | 457 | { |
458 | - $nbquestionresult = 0; |
|
459 | - $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
458 | + $nbquestionresult = 0; |
|
459 | + $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
460 | 460 | |
461 | 461 | foreach ($tabcatid as $category) { |
462 | 462 | if (empty($category['id'])) { |
@@ -472,30 +472,30 @@ discard block |
||
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | - return $nbquestionresult; |
|
476 | - } |
|
475 | + return $nbquestionresult; |
|
476 | + } |
|
477 | 477 | |
478 | - /** |
|
479 | - * Return an array (id=>name) |
|
480 | - * tabresult[0] = get_lang('NoCategory'); |
|
478 | + /** |
|
479 | + * Return an array (id=>name) |
|
480 | + * tabresult[0] = get_lang('NoCategory'); |
|
481 | 481 | * |
482 | 482 | * @param int $courseId |
483 | 483 | * |
484 | 484 | * @return array |
485 | - * |
|
486 | - */ |
|
485 | + * |
|
486 | + */ |
|
487 | 487 | public static function getCategoriesIdAndName($courseId = "") |
488 | 488 | { |
489 | - if (empty($courseId)) { |
|
490 | - $courseId = api_get_course_int_id(); |
|
491 | - } |
|
492 | - $tabcatobject = TestCategory::getCategoryListInfo("", $courseId); |
|
493 | - $tabresult = array("0"=>get_lang('NoCategorySelected')); |
|
494 | - for ($i=0; $i < count($tabcatobject); $i++) { |
|
495 | - $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name; |
|
496 | - } |
|
497 | - return $tabresult; |
|
498 | - } |
|
489 | + if (empty($courseId)) { |
|
490 | + $courseId = api_get_course_int_id(); |
|
491 | + } |
|
492 | + $tabcatobject = TestCategory::getCategoryListInfo("", $courseId); |
|
493 | + $tabresult = array("0"=>get_lang('NoCategorySelected')); |
|
494 | + for ($i=0; $i < count($tabcatobject); $i++) { |
|
495 | + $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name; |
|
496 | + } |
|
497 | + return $tabresult; |
|
498 | + } |
|
499 | 499 | |
500 | 500 | /** |
501 | 501 | * Returns an array of question ids for each category |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | * @param int exercise |
505 | 505 | * @param array $check_in_question_list |
506 | 506 | * @param array $categoriesAddedInExercise |
507 | - * |
|
508 | - * @param int $exerciseId |
|
509 | - * @return array |
|
510 | - */ |
|
507 | + * |
|
508 | + * @param int $exerciseId |
|
509 | + * @return array |
|
510 | + */ |
|
511 | 511 | static function getQuestionsByCat( |
512 | 512 | $exerciseId, |
513 | 513 | $check_in_question_list = array(), |
@@ -585,28 +585,28 @@ discard block |
||
585 | 585 | } |
586 | 586 | |
587 | 587 | return $categories; |
588 | - } |
|
588 | + } |
|
589 | 589 | |
590 | - /** |
|
591 | - * return a tab of $in_number random elements of $in_tab |
|
592 | - */ |
|
590 | + /** |
|
591 | + * return a tab of $in_number random elements of $in_tab |
|
592 | + */ |
|
593 | 593 | public static function getNElementsFromArray($in_tab, $in_number) |
594 | 594 | { |
595 | - $tabres = $in_tab; |
|
596 | - shuffle($tabres); |
|
597 | - if ($in_number < count($tabres)) { |
|
598 | - $tabres = array_slice($tabres, 0, $in_number); |
|
599 | - } |
|
600 | - return $tabres; |
|
601 | - } |
|
602 | - |
|
603 | - /** |
|
604 | - * display the category |
|
605 | - */ |
|
606 | - public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1) |
|
595 | + $tabres = $in_tab; |
|
596 | + shuffle($tabres); |
|
597 | + if ($in_number < count($tabres)) { |
|
598 | + $tabres = array_slice($tabres, 0, $in_number); |
|
599 | + } |
|
600 | + return $tabres; |
|
601 | + } |
|
602 | + |
|
603 | + /** |
|
604 | + * display the category |
|
605 | + */ |
|
606 | + public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1) |
|
607 | 607 | { |
608 | 608 | echo self::returnCategoryAndTitle($questionId, $in_display_category_name); |
609 | - } |
|
609 | + } |
|
610 | 610 | |
611 | 611 | /** |
612 | 612 | * @param int $questionId |
@@ -622,90 +622,90 @@ discard block |
||
622 | 622 | $in_display_category_name = $objExercise->display_category_name; |
623 | 623 | } |
624 | 624 | $content = null; |
625 | - if (TestCategory::getCategoryNameForQuestion($questionId) != '' && ($in_display_category_name == 1 || !$is_student)) { |
|
625 | + if (TestCategory::getCategoryNameForQuestion($questionId) != '' && ($in_display_category_name == 1 || !$is_student)) { |
|
626 | 626 | $content .= '<div class="page-header">'; |
627 | 627 | $content .= '<h4>'.get_lang('Category').": ".TestCategory::getCategoryNameForQuestion($questionId).'</h4>'; |
628 | 628 | $content .= "</div>"; |
629 | - } |
|
629 | + } |
|
630 | 630 | return $content; |
631 | - } |
|
631 | + } |
|
632 | 632 | |
633 | 633 | /** |
634 | - * Display signs [+] and/or (>0) after question title if question has options |
|
635 | - * scoreAlwaysPositive and/or uncheckedMayScore |
|
636 | - */ |
|
634 | + * Display signs [+] and/or (>0) after question title if question has options |
|
635 | + * scoreAlwaysPositive and/or uncheckedMayScore |
|
636 | + */ |
|
637 | 637 | public function displayQuestionOption($in_objQuestion) |
638 | 638 | { |
639 | - if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
|
640 | - echo "<span style='font-size:75%'> (>0)</span>"; |
|
641 | - } |
|
642 | - if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) { |
|
643 | - echo "<span style='font-size:75%'> [+]</span>"; |
|
644 | - } |
|
645 | - } |
|
646 | - |
|
647 | - /** |
|
648 | - * sortTabByBracketLabel ($tabCategoryQuestions) |
|
649 | - * key of $tabCategoryQuestions are the category id (0 for not in a category) |
|
650 | - * value is the array of question id of this category |
|
651 | - * Sort question by Category |
|
652 | - */ |
|
639 | + if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
|
640 | + echo "<span style='font-size:75%'> (>0)</span>"; |
|
641 | + } |
|
642 | + if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) { |
|
643 | + echo "<span style='font-size:75%'> [+]</span>"; |
|
644 | + } |
|
645 | + } |
|
646 | + |
|
647 | + /** |
|
648 | + * sortTabByBracketLabel ($tabCategoryQuestions) |
|
649 | + * key of $tabCategoryQuestions are the category id (0 for not in a category) |
|
650 | + * value is the array of question id of this category |
|
651 | + * Sort question by Category |
|
652 | + */ |
|
653 | 653 | public static function sortTabByBracketLabel($in_tab) |
654 | 654 | { |
655 | - $tabResult = array(); |
|
656 | - $tabCatName = array(); // tab of category name |
|
657 | - while (list($cat_id, $tabquestion) = each($in_tab)) { |
|
658 | - $catTitle = new TestCategory($cat_id); |
|
659 | - $tabCatName[$cat_id] = $catTitle->name; |
|
660 | - } |
|
661 | - reset($in_tab); |
|
662 | - // sort table by value, keeping keys as they are |
|
663 | - asort($tabCatName); |
|
664 | - // keys of $tabCatName are keys order for $in_tab |
|
665 | - while (list($key, $val) = each($tabCatName)) { |
|
666 | - $tabResult[$key] = $in_tab[$key]; |
|
667 | - } |
|
668 | - return $tabResult; |
|
669 | - } |
|
655 | + $tabResult = array(); |
|
656 | + $tabCatName = array(); // tab of category name |
|
657 | + while (list($cat_id, $tabquestion) = each($in_tab)) { |
|
658 | + $catTitle = new TestCategory($cat_id); |
|
659 | + $tabCatName[$cat_id] = $catTitle->name; |
|
660 | + } |
|
661 | + reset($in_tab); |
|
662 | + // sort table by value, keeping keys as they are |
|
663 | + asort($tabCatName); |
|
664 | + // keys of $tabCatName are keys order for $in_tab |
|
665 | + while (list($key, $val) = each($tabCatName)) { |
|
666 | + $tabResult[$key] = $in_tab[$key]; |
|
667 | + } |
|
668 | + return $tabResult; |
|
669 | + } |
|
670 | 670 | |
671 | 671 | /** |
672 | - * return total score for test exe_id for all question in the category $in_cat_id for user |
|
673 | - * If no question for this category, return "" |
|
674 | - */ |
|
675 | - public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id) |
|
676 | - { |
|
677 | - $tbl_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
678 | - $tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
679 | - $in_cat_id = intval($in_cat_id); |
|
680 | - $in_exe_id = intval($in_exe_id); |
|
681 | - $in_user_id = intval($in_user_id); |
|
682 | - |
|
683 | - $query = "SELECT DISTINCT |
|
672 | + * return total score for test exe_id for all question in the category $in_cat_id for user |
|
673 | + * If no question for this category, return "" |
|
674 | + */ |
|
675 | + public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id) |
|
676 | + { |
|
677 | + $tbl_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
678 | + $tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
679 | + $in_cat_id = intval($in_cat_id); |
|
680 | + $in_exe_id = intval($in_exe_id); |
|
681 | + $in_user_id = intval($in_user_id); |
|
682 | + |
|
683 | + $query = "SELECT DISTINCT |
|
684 | 684 | marks, exe_id, user_id, ta.question_id, category_id |
685 | 685 | FROM $tbl_track_attempt ta , $tbl_question_rel_category qrc |
686 | 686 | WHERE |
687 | 687 | ta.question_id=qrc.question_id AND |
688 | 688 | qrc.category_id=$in_cat_id AND |
689 | 689 | exe_id=$in_exe_id AND user_id=$in_user_id"; |
690 | - $res = Database::query($query); |
|
691 | - $totalcatscore = ""; |
|
692 | - while ($data = Database::fetch_array($res)) { |
|
693 | - $totalcatscore += $data['marks']; |
|
694 | - } |
|
695 | - return $totalcatscore; |
|
696 | - } |
|
697 | - |
|
698 | - /** |
|
690 | + $res = Database::query($query); |
|
691 | + $totalcatscore = ""; |
|
692 | + while ($data = Database::fetch_array($res)) { |
|
693 | + $totalcatscore += $data['marks']; |
|
694 | + } |
|
695 | + return $totalcatscore; |
|
696 | + } |
|
697 | + |
|
698 | + /** |
|
699 | 699 | * return the number max of question in a category |
700 | 700 | * count the number of questions in all categories, and return the max |
701 | 701 | * @param int $exerciseId |
702 | 702 | * @author - hubert borderiou |
703 | - */ |
|
703 | + */ |
|
704 | 704 | public static function getNumberMaxQuestionByCat($exerciseId) |
705 | 705 | { |
706 | 706 | $res_num_max = 0; |
707 | 707 | // foreach question |
708 | - $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
708 | + $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
709 | 709 | |
710 | 710 | foreach ($tabcatid as $category) { |
711 | 711 | if (empty($category['id'])) { |
@@ -777,34 +777,34 @@ discard block |
||
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
780 | - * @return array |
|
781 | - */ |
|
782 | - function get_all_categories() |
|
783 | - { |
|
784 | - $table = Database::get_course_table(TABLE_QUIZ_CATEGORY); |
|
785 | - $sql = "SELECT * FROM $table ORDER BY title ASC"; |
|
786 | - $res = Database::query($sql); |
|
787 | - while ($row = Database::fetch_array($res,'ASSOC')) { |
|
788 | - $array[] = $row; |
|
789 | - } |
|
790 | - return $array; |
|
791 | - } |
|
792 | - |
|
793 | - /** |
|
794 | - * @param Exercise $exercise |
|
795 | - * @param int $course_id |
|
796 | - * @param string $order |
|
797 | - * @param bool $shuffle |
|
798 | - * @param bool $excludeCategoryWithNoQuestions |
|
799 | - * @return array|bool |
|
800 | - */ |
|
801 | - public function getCategoryExerciseTree( |
|
802 | - $exercise, |
|
803 | - $course_id, |
|
804 | - $order = null, |
|
805 | - $shuffle = false, |
|
806 | - $excludeCategoryWithNoQuestions = true |
|
807 | - ) { |
|
780 | + * @return array |
|
781 | + */ |
|
782 | + function get_all_categories() |
|
783 | + { |
|
784 | + $table = Database::get_course_table(TABLE_QUIZ_CATEGORY); |
|
785 | + $sql = "SELECT * FROM $table ORDER BY title ASC"; |
|
786 | + $res = Database::query($sql); |
|
787 | + while ($row = Database::fetch_array($res,'ASSOC')) { |
|
788 | + $array[] = $row; |
|
789 | + } |
|
790 | + return $array; |
|
791 | + } |
|
792 | + |
|
793 | + /** |
|
794 | + * @param Exercise $exercise |
|
795 | + * @param int $course_id |
|
796 | + * @param string $order |
|
797 | + * @param bool $shuffle |
|
798 | + * @param bool $excludeCategoryWithNoQuestions |
|
799 | + * @return array|bool |
|
800 | + */ |
|
801 | + public function getCategoryExerciseTree( |
|
802 | + $exercise, |
|
803 | + $course_id, |
|
804 | + $order = null, |
|
805 | + $shuffle = false, |
|
806 | + $excludeCategoryWithNoQuestions = true |
|
807 | + ) { |
|
808 | 808 | if (empty($exercise)) { |
809 | 809 | return array(); |
810 | 810 | } |
@@ -814,165 +814,165 @@ discard block |
||
814 | 814 | } |
815 | 815 | |
816 | 816 | $course_id = intval($course_id); |
817 | - $table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY); |
|
817 | + $table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY); |
|
818 | 818 | $categoryTable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
819 | - $sql = "SELECT * FROM $table qc |
|
819 | + $sql = "SELECT * FROM $table qc |
|
820 | 820 | LEFT JOIN $categoryTable c |
821 | 821 | ON (qc.c_id = c.c_id AND c.id = qc.category_id) |
822 | 822 | WHERE qc.c_id = $course_id AND exercise_id = {$exercise->id} "; |
823 | 823 | |
824 | - if (!empty($order)) { |
|
825 | - $sql .= "ORDER BY $order"; |
|
826 | - } |
|
827 | - |
|
828 | - $categories = array(); |
|
829 | - |
|
830 | - $result = Database::query($sql); |
|
831 | - if (Database::num_rows($result)) { |
|
832 | - while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
833 | - if ($excludeCategoryWithNoQuestions) { |
|
834 | - if ($row['count_questions'] == 0) { |
|
835 | - continue; |
|
836 | - } |
|
837 | - } |
|
838 | - if (empty($row['title']) && empty($row['category_id'])) { |
|
839 | - $row['title'] = get_lang('NoCategory'); |
|
840 | - } |
|
824 | + if (!empty($order)) { |
|
825 | + $sql .= "ORDER BY $order"; |
|
826 | + } |
|
827 | + |
|
828 | + $categories = array(); |
|
829 | + |
|
830 | + $result = Database::query($sql); |
|
831 | + if (Database::num_rows($result)) { |
|
832 | + while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
833 | + if ($excludeCategoryWithNoQuestions) { |
|
834 | + if ($row['count_questions'] == 0) { |
|
835 | + continue; |
|
836 | + } |
|
837 | + } |
|
838 | + if (empty($row['title']) && empty($row['category_id'])) { |
|
839 | + $row['title'] = get_lang('NoCategory'); |
|
840 | + } |
|
841 | 841 | $categories[$row['category_id']] = $row; |
842 | - } |
|
843 | - } |
|
844 | - |
|
845 | - if ($shuffle) { |
|
846 | - shuffle_assoc($categories); |
|
847 | - } |
|
848 | - |
|
849 | - return $categories; |
|
850 | - } |
|
851 | - |
|
852 | - public function getForm(& $form, $action = 'new') |
|
853 | - { |
|
854 | - switch($action) { |
|
855 | - case 'new': |
|
856 | - $header = get_lang('AddACategory'); |
|
857 | - $submit = get_lang('AddTestCategory'); |
|
858 | - break; |
|
859 | - case 'edit': |
|
860 | - $header = get_lang('EditCategory'); |
|
861 | - $submit = get_lang('ModifyCategory'); |
|
862 | - break; |
|
863 | - } |
|
864 | - |
|
865 | - // settting the form elements |
|
866 | - $form->addElement('header', $header); |
|
867 | - $form->addElement('hidden', 'category_id'); |
|
868 | - $form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6')); |
|
869 | - $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200')); |
|
870 | - $category_parent_list = array(); |
|
871 | - |
|
872 | - $options = array( |
|
873 | - '1' => get_lang('Visible'), |
|
874 | - '0' => get_lang('Hidden') |
|
875 | - ); |
|
876 | - $form->addElement('select', 'visibility', get_lang('Visibility'), $options); |
|
877 | - $script = null; |
|
878 | - if (!empty($this->parent_id)) { |
|
879 | - $parent_cat = new TestCategory($this->parent_id); |
|
880 | - $category_parent_list = array($parent_cat->id => $parent_cat->name); |
|
881 | - $script .= '<script>$(function() { $("#parent_id").trigger("addItem",[{"title": "'.$parent_cat->name.'", "value": "'.$parent_cat->id.'"}]); });</script>'; |
|
882 | - } |
|
883 | - $form->addElement('html', $script); |
|
884 | - |
|
885 | - $form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, array('id' => 'parent_id')); |
|
886 | - $form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"'); |
|
887 | - |
|
888 | - // setting the defaults |
|
889 | - $defaults = array(); |
|
890 | - $defaults["category_id"] = $this->id; |
|
891 | - $defaults["category_name"] = $this->name; |
|
892 | - $defaults["category_description"] = $this->description; |
|
893 | - $defaults["parent_id"] = $this->parent_id; |
|
894 | - $defaults["visibility"] = $this->visibility; |
|
895 | - $form->setDefaults($defaults); |
|
896 | - |
|
897 | - // setting the rules |
|
898 | - $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required'); |
|
899 | - } |
|
900 | - |
|
901 | - /** |
|
902 | - * Returns the category form. |
|
903 | - * @param Exercise $exercise_obj |
|
904 | - * @return string |
|
905 | - */ |
|
906 | - public function returnCategoryForm(Exercise $exercise_obj) |
|
907 | - { |
|
908 | - $categories = $this->getListOfCategoriesForTest($exercise_obj); |
|
909 | - |
|
910 | - $saved_categories = $exercise_obj->get_categories_in_exercise(); |
|
911 | - $return = null; |
|
912 | - |
|
913 | - if (!empty($categories)) { |
|
914 | - $nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory(); |
|
915 | - $exercise_obj->setCategoriesGrouping(true); |
|
916 | - $real_question_count = count($exercise_obj->getQuestionList()); |
|
917 | - |
|
918 | - $warning = null; |
|
919 | - if ($nbQuestionsTotal != $real_question_count) { |
|
920 | - $warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning'); |
|
921 | - } |
|
922 | - |
|
923 | - $return .= $warning; |
|
924 | - $return .= '<table class="data_table">'; |
|
925 | - $return .= '<tr>'; |
|
926 | - $return .= '<th height="24">' . get_lang('Categories') . '</th>'; |
|
927 | - $return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>'; |
|
928 | - |
|
929 | - $emptyCategory = array( |
|
930 | - 'id' => '0', |
|
931 | - 'name' => get_lang('NoCategory'), |
|
932 | - 'description' => '', |
|
933 | - 'iid' => '0', |
|
934 | - 'title' => get_lang('NoCategory') |
|
935 | - ); |
|
936 | - |
|
937 | - $categories[] = $emptyCategory; |
|
938 | - |
|
939 | - foreach ($categories as $category) { |
|
940 | - $cat_id = $category['iid']; |
|
941 | - $return .= '<tr>'; |
|
942 | - $return .= '<td>'; |
|
943 | - //$return .= Display::div(isset($category['parent_path']) ? $category['parent_path'] : ''); |
|
944 | - $return .= Display::div($category['name']); |
|
945 | - $return .= '</td>'; |
|
946 | - $return .= '<td>'; |
|
947 | - $value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1; |
|
948 | - $return .= '<input name="category['.$cat_id.']" value="' .$value.'" />'; |
|
949 | - $return .= '</td>'; |
|
950 | - $return .= '</tr>'; |
|
951 | - } |
|
952 | - |
|
953 | - $return .= '</table>'; |
|
954 | - $return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected'); |
|
955 | - return $return; |
|
956 | - } |
|
957 | - } |
|
958 | - |
|
959 | - /** |
|
960 | - * Sorts an array |
|
961 | - * @param $array |
|
962 | - * @return mixed |
|
963 | - */ |
|
964 | - public function sort_tree_array($array) |
|
965 | - { |
|
966 | - foreach ($array as $key => $row) { |
|
967 | - $parent[$key] = $row['parent_id']; |
|
968 | - } |
|
969 | - if (count($array) > 0) { |
|
970 | - array_multisort($parent, SORT_ASC, $array); |
|
971 | - } |
|
972 | - return $array; |
|
973 | - } |
|
974 | - |
|
975 | - /** |
|
842 | + } |
|
843 | + } |
|
844 | + |
|
845 | + if ($shuffle) { |
|
846 | + shuffle_assoc($categories); |
|
847 | + } |
|
848 | + |
|
849 | + return $categories; |
|
850 | + } |
|
851 | + |
|
852 | + public function getForm(& $form, $action = 'new') |
|
853 | + { |
|
854 | + switch($action) { |
|
855 | + case 'new': |
|
856 | + $header = get_lang('AddACategory'); |
|
857 | + $submit = get_lang('AddTestCategory'); |
|
858 | + break; |
|
859 | + case 'edit': |
|
860 | + $header = get_lang('EditCategory'); |
|
861 | + $submit = get_lang('ModifyCategory'); |
|
862 | + break; |
|
863 | + } |
|
864 | + |
|
865 | + // settting the form elements |
|
866 | + $form->addElement('header', $header); |
|
867 | + $form->addElement('hidden', 'category_id'); |
|
868 | + $form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6')); |
|
869 | + $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200')); |
|
870 | + $category_parent_list = array(); |
|
871 | + |
|
872 | + $options = array( |
|
873 | + '1' => get_lang('Visible'), |
|
874 | + '0' => get_lang('Hidden') |
|
875 | + ); |
|
876 | + $form->addElement('select', 'visibility', get_lang('Visibility'), $options); |
|
877 | + $script = null; |
|
878 | + if (!empty($this->parent_id)) { |
|
879 | + $parent_cat = new TestCategory($this->parent_id); |
|
880 | + $category_parent_list = array($parent_cat->id => $parent_cat->name); |
|
881 | + $script .= '<script>$(function() { $("#parent_id").trigger("addItem",[{"title": "'.$parent_cat->name.'", "value": "'.$parent_cat->id.'"}]); });</script>'; |
|
882 | + } |
|
883 | + $form->addElement('html', $script); |
|
884 | + |
|
885 | + $form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, array('id' => 'parent_id')); |
|
886 | + $form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"'); |
|
887 | + |
|
888 | + // setting the defaults |
|
889 | + $defaults = array(); |
|
890 | + $defaults["category_id"] = $this->id; |
|
891 | + $defaults["category_name"] = $this->name; |
|
892 | + $defaults["category_description"] = $this->description; |
|
893 | + $defaults["parent_id"] = $this->parent_id; |
|
894 | + $defaults["visibility"] = $this->visibility; |
|
895 | + $form->setDefaults($defaults); |
|
896 | + |
|
897 | + // setting the rules |
|
898 | + $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required'); |
|
899 | + } |
|
900 | + |
|
901 | + /** |
|
902 | + * Returns the category form. |
|
903 | + * @param Exercise $exercise_obj |
|
904 | + * @return string |
|
905 | + */ |
|
906 | + public function returnCategoryForm(Exercise $exercise_obj) |
|
907 | + { |
|
908 | + $categories = $this->getListOfCategoriesForTest($exercise_obj); |
|
909 | + |
|
910 | + $saved_categories = $exercise_obj->get_categories_in_exercise(); |
|
911 | + $return = null; |
|
912 | + |
|
913 | + if (!empty($categories)) { |
|
914 | + $nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory(); |
|
915 | + $exercise_obj->setCategoriesGrouping(true); |
|
916 | + $real_question_count = count($exercise_obj->getQuestionList()); |
|
917 | + |
|
918 | + $warning = null; |
|
919 | + if ($nbQuestionsTotal != $real_question_count) { |
|
920 | + $warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning'); |
|
921 | + } |
|
922 | + |
|
923 | + $return .= $warning; |
|
924 | + $return .= '<table class="data_table">'; |
|
925 | + $return .= '<tr>'; |
|
926 | + $return .= '<th height="24">' . get_lang('Categories') . '</th>'; |
|
927 | + $return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>'; |
|
928 | + |
|
929 | + $emptyCategory = array( |
|
930 | + 'id' => '0', |
|
931 | + 'name' => get_lang('NoCategory'), |
|
932 | + 'description' => '', |
|
933 | + 'iid' => '0', |
|
934 | + 'title' => get_lang('NoCategory') |
|
935 | + ); |
|
936 | + |
|
937 | + $categories[] = $emptyCategory; |
|
938 | + |
|
939 | + foreach ($categories as $category) { |
|
940 | + $cat_id = $category['iid']; |
|
941 | + $return .= '<tr>'; |
|
942 | + $return .= '<td>'; |
|
943 | + //$return .= Display::div(isset($category['parent_path']) ? $category['parent_path'] : ''); |
|
944 | + $return .= Display::div($category['name']); |
|
945 | + $return .= '</td>'; |
|
946 | + $return .= '<td>'; |
|
947 | + $value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1; |
|
948 | + $return .= '<input name="category['.$cat_id.']" value="' .$value.'" />'; |
|
949 | + $return .= '</td>'; |
|
950 | + $return .= '</tr>'; |
|
951 | + } |
|
952 | + |
|
953 | + $return .= '</table>'; |
|
954 | + $return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected'); |
|
955 | + return $return; |
|
956 | + } |
|
957 | + } |
|
958 | + |
|
959 | + /** |
|
960 | + * Sorts an array |
|
961 | + * @param $array |
|
962 | + * @return mixed |
|
963 | + */ |
|
964 | + public function sort_tree_array($array) |
|
965 | + { |
|
966 | + foreach ($array as $key => $row) { |
|
967 | + $parent[$key] = $row['parent_id']; |
|
968 | + } |
|
969 | + if (count($array) > 0) { |
|
970 | + array_multisort($parent, SORT_ASC, $array); |
|
971 | + } |
|
972 | + return $array; |
|
973 | + } |
|
974 | + |
|
975 | + /** |
|
976 | 976 | * Return true if a category already exists with the same name |
977 | 977 | * @param string $in_name |
978 | 978 | * |
@@ -1018,8 +1018,8 @@ discard block |
||
1018 | 1018 | * @param int $categoryId |
1019 | 1019 | * @param int $questionId |
1020 | 1020 | * @param int $courseId |
1021 | - * |
|
1022 | - * @return string|false |
|
1021 | + * |
|
1022 | + * @return string|false |
|
1023 | 1023 | */ |
1024 | 1024 | public static function add_category_for_question_id($categoryId, $questionId, $courseId) |
1025 | 1025 | { |
@@ -1027,18 +1027,18 @@ discard block |
||
1027 | 1027 | // if question doesn't have a category |
1028 | 1028 | // @todo change for 1.10 when a question can have several categories |
1029 | 1029 | if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 && |
1030 | - $questionId > 0 && |
|
1031 | - $courseId > 0 |
|
1030 | + $questionId > 0 && |
|
1031 | + $courseId > 0 |
|
1032 | 1032 | ) { |
1033 | 1033 | $sql = "INSERT INTO $table (c_id, question_id, category_id) |
1034 | 1034 | VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")"; |
1035 | 1035 | Database::query($sql); |
1036 | - $id = Database::insert_id(); |
|
1036 | + $id = Database::insert_id(); |
|
1037 | 1037 | |
1038 | - return $id; |
|
1038 | + return $id; |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | - return false; |
|
1041 | + return false; |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | /** |
@@ -20,16 +20,16 @@ |
||
20 | 20 | $exerciseId = $objExercise->selectId(); |
21 | 21 | if ($_GET['answerId'] == "0") { // click is NOT on a hotspot |
22 | 22 | $hit = 0; |
23 | - $answerId = $hotspotId; |
|
23 | + $answerId = $hotspotId; |
|
24 | 24 | |
25 | - // remove from session |
|
26 | - unset($_SESSION['exerciseResult'][$questionId][$answerId]); |
|
25 | + // remove from session |
|
26 | + unset($_SESSION['exerciseResult'][$questionId][$answerId]); |
|
27 | 27 | } else { // user clicked ON a hotspot |
28 | - $hit = 1; |
|
29 | - $answerId = $hotspotId; |
|
28 | + $hit = 1; |
|
29 | + $answerId = $hotspotId; |
|
30 | 30 | |
31 | - // Save into session |
|
32 | - $_SESSION['exerciseResult'][$questionId][$answerId] = $hit; |
|
31 | + // Save into session |
|
32 | + $_SESSION['exerciseResult'][$questionId][$answerId] = $hit; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | //round-up the coordinates |
@@ -49,29 +49,29 @@ discard block |
||
49 | 49 | $extra_field_list = UserManager::get_extra_fields(); |
50 | 50 | $new_field_list = array(); |
51 | 51 | if (is_array($extra_field_list)) { |
52 | - foreach ($extra_field_list as $extra_field) { |
|
53 | - //if is enabled to filter and is a "<select>" field type |
|
54 | - if ($extra_field[8]==1 && $extra_field[2]==4 ) { |
|
52 | + foreach ($extra_field_list as $extra_field) { |
|
53 | + //if is enabled to filter and is a "<select>" field type |
|
54 | + if ($extra_field[8]==1 && $extra_field[2]==4 ) { |
|
55 | 55 | $new_field_list[] = array( |
56 | 56 | 'name' => $extra_field[3], |
57 | 57 | 'variable' => $extra_field[1], |
58 | 58 | 'data' => $extra_field[9], |
59 | 59 | ); |
60 | - } |
|
61 | - } |
|
60 | + } |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | function search_users($needle, $type) |
65 | 65 | { |
66 | - global $id_session; |
|
66 | + global $id_session; |
|
67 | 67 | |
68 | 68 | $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
69 | 69 | $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
70 | 70 | |
71 | - $xajax_response = new xajaxResponse(); |
|
72 | - $return = ''; |
|
71 | + $xajax_response = new xajaxResponse(); |
|
72 | + $return = ''; |
|
73 | 73 | |
74 | - if (!empty($needle) && !empty($type)) { |
|
74 | + if (!empty($needle) && !empty($type)) { |
|
75 | 75 | |
76 | 76 | //normal behaviour |
77 | 77 | if ($type == 'any_session' && $needle == 'false') { |
@@ -79,32 +79,32 @@ discard block |
||
79 | 79 | $needle = ''; |
80 | 80 | } |
81 | 81 | |
82 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
83 | - $charset = api_get_system_encoding(); |
|
84 | - $needle = Database::escape_string($needle); |
|
85 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
82 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
83 | + $charset = api_get_system_encoding(); |
|
84 | + $needle = Database::escape_string($needle); |
|
85 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
86 | 86 | |
87 | - $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; |
|
88 | - $cond_user_id = ''; |
|
87 | + $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; |
|
88 | + $cond_user_id = ''; |
|
89 | 89 | |
90 | 90 | //Only for single & multiple |
91 | 91 | if (in_array($type, array('single','multiple'))) { |
92 | - if (!empty($id_session)) { |
|
93 | - $id_session = intval($id_session); |
|
94 | - // check id_user from session_rel_user table |
|
95 | - $sql = 'SELECT user_id FROM '.$tbl_session_rel_user.' |
|
92 | + if (!empty($id_session)) { |
|
93 | + $id_session = intval($id_session); |
|
94 | + // check id_user from session_rel_user table |
|
95 | + $sql = 'SELECT user_id FROM '.$tbl_session_rel_user.' |
|
96 | 96 | WHERE session_id ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' '; |
97 | - $res = Database::query($sql); |
|
98 | - $user_ids = array(); |
|
99 | - if (Database::num_rows($res) > 0) { |
|
100 | - while ($row = Database::fetch_row($res)) { |
|
101 | - $user_ids[] = (int)$row[0]; |
|
102 | - } |
|
103 | - } |
|
104 | - if (count($user_ids) > 0) { |
|
105 | - $cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')'; |
|
106 | - } |
|
107 | - } |
|
97 | + $res = Database::query($sql); |
|
98 | + $user_ids = array(); |
|
99 | + if (Database::num_rows($res) > 0) { |
|
100 | + while ($row = Database::fetch_row($res)) { |
|
101 | + $user_ids[] = (int)$row[0]; |
|
102 | + } |
|
103 | + } |
|
104 | + if (count($user_ids) > 0) { |
|
105 | + $cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')'; |
|
106 | + } |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | switch ($type) { |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | user.status <> 6 '.$cond_user_id. |
137 | 137 | $order_clause; |
138 | 138 | break; |
139 | - } |
|
140 | - if (api_is_multiple_url_enabled()) { |
|
141 | - $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
142 | - $access_url_id = api_get_current_access_url_id(); |
|
143 | - if ($access_url_id != -1) { |
|
139 | + } |
|
140 | + if (api_is_multiple_url_enabled()) { |
|
141 | + $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
142 | + $access_url_id = api_get_current_access_url_id(); |
|
143 | + if ($access_url_id != -1) { |
|
144 | 144 | switch ($type) { |
145 | 145 | case 'single': |
146 | 146 | $sql = 'SELECT user.user_id, username, lastname, firstname |
@@ -178,36 +178,36 @@ discard block |
||
178 | 178 | user.status<>6 '.$cond_user_id. |
179 | 179 | $order_clause; |
180 | 180 | break; |
181 | - } |
|
182 | - } |
|
183 | - } |
|
181 | + } |
|
182 | + } |
|
183 | + } |
|
184 | 184 | |
185 | - $rs = Database::query($sql); |
|
185 | + $rs = Database::query($sql); |
|
186 | 186 | $i=0; |
187 | - if ($type == 'single') { |
|
188 | - while ($user = Database::fetch_array($rs)) { |
|
189 | - $i++; |
|
190 | - if ($i<=10) { |
|
191 | - $person_name = api_get_person_name($user['firstname'], $user['lastname']); |
|
192 | - $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />'; |
|
193 | - } else { |
|
194 | - $return .= '...<br />'; |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - $xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return)); |
|
199 | - } else { |
|
200 | - $return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">'; |
|
201 | - while ($user = Database :: fetch_array($rs)) { |
|
202 | - $person_name = api_get_person_name($user['firstname'], $user['lastname']); |
|
203 | - $return .= '<option value="'.$user['user_id'].'">'.$person_name.' ('.$user['username'].')</option>'; |
|
204 | - } |
|
205 | - $return .= '</select>'; |
|
206 | - $xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return)); |
|
207 | - } |
|
208 | - } |
|
187 | + if ($type == 'single') { |
|
188 | + while ($user = Database::fetch_array($rs)) { |
|
189 | + $i++; |
|
190 | + if ($i<=10) { |
|
191 | + $person_name = api_get_person_name($user['firstname'], $user['lastname']); |
|
192 | + $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />'; |
|
193 | + } else { |
|
194 | + $return .= '...<br />'; |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + $xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return)); |
|
199 | + } else { |
|
200 | + $return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">'; |
|
201 | + while ($user = Database :: fetch_array($rs)) { |
|
202 | + $person_name = api_get_person_name($user['firstname'], $user['lastname']); |
|
203 | + $return .= '<option value="'.$user['user_id'].'">'.$person_name.' ('.$user['username'].')</option>'; |
|
204 | + } |
|
205 | + $return .= '</select>'; |
|
206 | + $xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return)); |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - return $xajax_response; |
|
210 | + return $xajax_response; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | $xajax -> processRequests(); |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | |
348 | 348 | if ($use_extra_fields) { |
349 | 349 | $final_result = array(); |
350 | - if (count($extra_field_result)>1) { |
|
351 | - for($i=0;$i<count($extra_field_result)-1;$i++) { |
|
350 | + if (count($extra_field_result)>1) { |
|
351 | + for($i=0;$i<count($extra_field_result)-1;$i++) { |
|
352 | 352 | if (is_array($extra_field_result[$i+1])) { |
353 | 353 | $final_result = array_intersect( |
354 | 354 | $extra_field_result[$i], |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | 'un' => $user['username'] |
427 | 427 | ); |
428 | 428 | unset($users[$uid]); |
429 | - } |
|
429 | + } |
|
430 | 430 | } |
431 | 431 | unset($users); //clean to free memory |
432 | 432 | |
@@ -471,13 +471,13 @@ discard block |
||
471 | 471 | } |
472 | 472 | |
473 | 473 | if ($add_type === 'multiple') { |
474 | - $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; |
|
475 | - $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); |
|
474 | + $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; |
|
475 | + $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); |
|
476 | 476 | } else { |
477 | - $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'); |
|
478 | - $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; |
|
477 | + $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'); |
|
478 | + $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; |
|
479 | 479 | } |
480 | - $link_add_group = '<a href="usergroups.php">'. |
|
480 | + $link_add_group = '<a href="usergroups.php">'. |
|
481 | 481 | Display::return_icon('multiple.gif', get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups').'</a>'; |
482 | 482 | ?> |
483 | 483 | <div class="actions"> |
@@ -487,30 +487,30 @@ discard block |
||
487 | 487 | <?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?> |
488 | 488 | <?php |
489 | 489 | if ($add_type === 'multiple') { |
490 | - if (is_array($extra_field_list)) { |
|
491 | - if (is_array($new_field_list) && count($new_field_list)>0 ) { |
|
492 | - echo '<h3>'.get_lang('FilterUsers').'</h3>'; |
|
493 | - foreach ($new_field_list as $new_field) { |
|
494 | - echo $new_field['name']; |
|
495 | - $varname = 'field_'.$new_field['variable']; |
|
496 | - echo ' <select name="'.$varname.'">'; |
|
497 | - echo '<option value="0">--'.get_lang('Select').'--</option>'; |
|
498 | - foreach ($new_field['data'] as $option) { |
|
499 | - $checked=''; |
|
500 | - if (isset($_POST[$varname])) { |
|
501 | - if ($_POST[$varname] == $option[1]) { |
|
502 | - $checked = 'selected="true"'; |
|
503 | - } |
|
504 | - } |
|
505 | - echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>'; |
|
506 | - } |
|
507 | - echo '</select>'; |
|
508 | - echo ' '; |
|
509 | - } |
|
510 | - echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />'; |
|
511 | - echo '<br /><br />'; |
|
512 | - } |
|
513 | - } |
|
490 | + if (is_array($extra_field_list)) { |
|
491 | + if (is_array($new_field_list) && count($new_field_list)>0 ) { |
|
492 | + echo '<h3>'.get_lang('FilterUsers').'</h3>'; |
|
493 | + foreach ($new_field_list as $new_field) { |
|
494 | + echo $new_field['name']; |
|
495 | + $varname = 'field_'.$new_field['variable']; |
|
496 | + echo ' <select name="'.$varname.'">'; |
|
497 | + echo '<option value="0">--'.get_lang('Select').'--</option>'; |
|
498 | + foreach ($new_field['data'] as $option) { |
|
499 | + $checked=''; |
|
500 | + if (isset($_POST[$varname])) { |
|
501 | + if ($_POST[$varname] == $option[1]) { |
|
502 | + $checked = 'selected="true"'; |
|
503 | + } |
|
504 | + } |
|
505 | + echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>'; |
|
506 | + } |
|
507 | + echo '</select>'; |
|
508 | + echo ' '; |
|
509 | + } |
|
510 | + echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />'; |
|
511 | + echo '<br /><br />'; |
|
512 | + } |
|
513 | + } |
|
514 | 514 | } |
515 | 515 | ?> |
516 | 516 | <input type="hidden" name="form_sent" value="1" /> |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | <div id="content_source"> |
534 | 534 | <?php |
535 | 535 | if (!($add_type == 'multiple')) { |
536 | - ?> |
|
536 | + ?> |
|
537 | 537 | <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" /> |
538 | 538 | <div id="ajax_list_users_single"></div> |
539 | 539 | <?php |
@@ -542,12 +542,12 @@ discard block |
||
542 | 542 | <div id="ajax_list_users_multiple"> |
543 | 543 | <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" class="span5"> |
544 | 544 | <?php |
545 | - foreach ($nosessionUsersList as $uid => $enreg) { |
|
546 | - ?> |
|
545 | + foreach ($nosessionUsersList as $uid => $enreg) { |
|
546 | + ?> |
|
547 | 547 | <option value="<?php echo $uid; ?>" <?php if(in_array($uid,$UserList)) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')'; ?></option> |
548 | 548 | <?php |
549 | - } |
|
550 | - ?> |
|
549 | + } |
|
550 | + ?> |
|
551 | 551 | </select> |
552 | 552 | </div> |
553 | 553 | <input type="checkbox" onchange="checked_in_no_session(this.checked);" name="user_with_any_session" id="user_with_any_session_id"> |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | <?php |
556 | 556 | } |
557 | 557 | unset($nosessionUsersList); |
558 | - ?> |
|
558 | + ?> |
|
559 | 559 | </div> |
560 | 560 | </div> |
561 | 561 | |
@@ -582,13 +582,13 @@ discard block |
||
582 | 582 | <br /> |
583 | 583 | <br /> |
584 | 584 | <?php |
585 | - if (isset($_GET['add'])) { |
|
586 | - echo '<button class="btn btn-primary" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>'; |
|
585 | + if (isset($_GET['add'])) { |
|
586 | + echo '<button class="btn btn-primary" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>'; |
|
587 | 587 | } else { |
588 | 588 | //@todo see that the call to "valide()" doesn't duplicate the onsubmit of the form (necessary to avoid delete on "enter" key pressed) |
589 | - echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToSession').'</button>'; |
|
589 | + echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToSession').'</button>'; |
|
590 | 590 | } |
591 | - ?> |
|
591 | + ?> |
|
592 | 592 | </div> |
593 | 593 | <div class="span5"> |
594 | 594 | <div class="multiple_select_header"> |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class CourseSelectForm |
19 | 19 | { |
20 | - /** |
|
21 | - * Display the form |
|
20 | + /** |
|
21 | + * Display the form |
|
22 | 22 | * @param array $course |
23 | - * @param array $hidden_fields Hidden fields to add to the form. |
|
24 | - * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file |
|
25 | - */ |
|
26 | - public static function display_form($course, $hidden_fields = null, $avoid_serialize = false) |
|
23 | + * @param array $hidden_fields Hidden fields to add to the form. |
|
24 | + * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file |
|
25 | + */ |
|
26 | + public static function display_form($course, $hidden_fields = null, $avoid_serialize = false) |
|
27 | 27 | { |
28 | 28 | global $charset; |
29 | 29 | $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook'); |
@@ -138,48 +138,48 @@ discard block |
||
138 | 138 | } |
139 | 139 | </script> |
140 | 140 | <?php |
141 | - // get destination course title |
|
142 | - if (!empty($hidden_fields['destination_course'])) { |
|
141 | + // get destination course title |
|
142 | + if (!empty($hidden_fields['destination_course'])) { |
|
143 | 143 | $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name($hidden_fields['destination_session']) . ')' : null; |
144 | 144 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
145 | - echo '<h3>'; |
|
146 | - echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle; |
|
147 | - echo '</h3>'; |
|
148 | - } |
|
145 | + echo '<h3>'; |
|
146 | + echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle; |
|
147 | + echo '</h3>'; |
|
148 | + } |
|
149 | 149 | echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>'; |
150 | - echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
150 | + echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
151 | 151 | $icon = Display::returnIconPath('myprogress_bar.gif'); |
152 | 152 | echo '<div class="tool-backups-options">'; |
153 | - echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">'; |
|
154 | - echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
153 | + echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">'; |
|
154 | + echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
155 | 155 | |
156 | - if (!empty($hidden_fields['destination_course']) && |
|
156 | + if (!empty($hidden_fields['destination_course']) && |
|
157 | 157 | !empty($hidden_fields['origin_course']) && |
158 | 158 | !empty($hidden_fields['destination_session']) && |
159 | 159 | !empty($hidden_fields['origin_session']) |
160 | 160 | ) { |
161 | - echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>'; |
|
162 | - echo '<input type="hidden" name="origin_course" value="'.$hidden_fields['origin_course'].'"/>'; |
|
163 | - echo '<input type="hidden" name="destination_session" value="'.$hidden_fields['destination_session'].'"/>'; |
|
164 | - echo '<input type="hidden" name="origin_session" value="'.$hidden_fields['origin_session'].'"/>'; |
|
165 | - } |
|
161 | + echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>'; |
|
162 | + echo '<input type="hidden" name="origin_course" value="'.$hidden_fields['origin_course'].'"/>'; |
|
163 | + echo '<input type="hidden" name="destination_session" value="'.$hidden_fields['destination_session'].'"/>'; |
|
164 | + echo '<input type="hidden" name="origin_session" value="'.$hidden_fields['origin_session'].'"/>'; |
|
165 | + } |
|
166 | 166 | |
167 | - $element_count = 0; |
|
167 | + $element_count = 0; |
|
168 | 168 | $forum_categories = array(); |
169 | 169 | $forums = array(); |
170 | 170 | $forum_topics = array(); |
171 | 171 | |
172 | 172 | echo '<p>'; |
173 | - echo get_lang('SelectResources'); |
|
174 | - echo '</p>'; |
|
173 | + echo get_lang('SelectResources'); |
|
174 | + echo '</p>'; |
|
175 | 175 | |
176 | 176 | Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt')); |
177 | 177 | |
178 | 178 | foreach ($course->resources as $type => $resources) { |
179 | 179 | if (count($resources) > 0) { |
180 | - switch ($type) { |
|
181 | - //Resources to avoid |
|
182 | - case RESOURCE_FORUMCATEGORY: |
|
180 | + switch ($type) { |
|
181 | + //Resources to avoid |
|
182 | + case RESOURCE_FORUMCATEGORY: |
|
183 | 183 | foreach ($resources as $id => $resource) { |
184 | 184 | $forum_categories[$id] = $resource; |
185 | 185 | } |
@@ -206,30 +206,30 @@ discard block |
||
206 | 206 | break; |
207 | 207 | default: |
208 | 208 | echo '<div class="item-backup" onclick="javascript:exp('."'$type'".');">'; |
209 | - echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>'; |
|
210 | - echo '<span class="title">'.$resource_titles[$type].'</span></div>'; |
|
211 | - echo '<div class="item-content" id="div_'.$type.'">'; |
|
212 | - if ($type == RESOURCE_LEARNPATH) { |
|
213 | - Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz')); |
|
214 | - Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments')); |
|
215 | - } |
|
216 | - if ($type == RESOURCE_DOCUMENT) { |
|
209 | + echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>'; |
|
210 | + echo '<span class="title">'.$resource_titles[$type].'</span></div>'; |
|
211 | + echo '<div class="item-content" id="div_'.$type.'">'; |
|
212 | + if ($type == RESOURCE_LEARNPATH) { |
|
213 | + Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz')); |
|
214 | + Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments')); |
|
215 | + } |
|
216 | + if ($type == RESOURCE_DOCUMENT) { |
|
217 | 217 | if (api_get_setting('show_glossary_in_documents') != 'none') { |
218 | 218 | Display::display_warning_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary')); |
219 | 219 | } |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - echo '<div class="well">'; |
|
222 | + echo '<div class="well">'; |
|
223 | 223 | |
224 | 224 | echo '<div class="btn-group">'; |
225 | - echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>"; |
|
225 | + echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>"; |
|
226 | 226 | echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>"; |
227 | - echo '</div>'; |
|
227 | + echo '</div>'; |
|
228 | 228 | echo '<ul class="list-backups-options">'; |
229 | - foreach ($resources as $id => $resource) { |
|
229 | + foreach ($resources as $id => $resource) { |
|
230 | 230 | if ($resource) { |
231 | 231 | echo '<li>'; |
232 | - // Event obj in 1.9.x in 1.10.x the class is CalendarEvent |
|
232 | + // Event obj in 1.9.x in 1.10.x the class is CalendarEvent |
|
233 | 233 | Resource::setClassType($resource); |
234 | 234 | echo '<label class="checkbox">'; |
235 | 235 | echo '<input type="checkbox" name="resource['.$type.']['.$id.']" id="resource['.$type.']['.$id.']" />'; |
@@ -237,15 +237,15 @@ discard block |
||
237 | 237 | echo '</label>'; |
238 | 238 | echo '</li>'; |
239 | 239 | } |
240 | - } |
|
240 | + } |
|
241 | 241 | echo '</ul>'; |
242 | - echo '</div>'; |
|
243 | - echo '</div>'; |
|
244 | - echo '<script language="javascript">exp('."'$type'".')</script>'; |
|
245 | - $element_count++; |
|
242 | + echo '</div>'; |
|
243 | + echo '</div>'; |
|
244 | + echo '<script language="javascript">exp('."'$type'".')</script>'; |
|
245 | + $element_count++; |
|
246 | 246 | } |
247 | - } |
|
248 | - } |
|
247 | + } |
|
248 | + } |
|
249 | 249 | |
250 | 250 | //Fixes forum order |
251 | 251 | if (!empty($forum_categories)) { |
@@ -301,66 +301,66 @@ discard block |
||
301 | 301 | echo '<script language="javascript">exp('."'$type'".')</script>'; |
302 | 302 | } |
303 | 303 | |
304 | - if ($avoid_serialize) { |
|
305 | - /*Documents are avoided due the huge amount of memory that the serialize php function "eats" |
|
304 | + if ($avoid_serialize) { |
|
305 | + /*Documents are avoided due the huge amount of memory that the serialize php function "eats" |
|
306 | 306 | (when there are directories with hundred/thousand of files) */ |
307 | - // this is a known issue of serialize |
|
308 | - $course->resources['document']= null; |
|
309 | - } |
|
307 | + // this is a known issue of serialize |
|
308 | + $course->resources['document']= null; |
|
309 | + } |
|
310 | 310 | |
311 | - echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
311 | + echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
312 | 312 | |
313 | - if (is_array($hidden_fields)) { |
|
314 | - foreach ($hidden_fields as $key => $value) { |
|
315 | - echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
316 | - } |
|
317 | - } |
|
313 | + if (is_array($hidden_fields)) { |
|
314 | + foreach ($hidden_fields as $key => $value) { |
|
315 | + echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
316 | + } |
|
317 | + } |
|
318 | 318 | |
319 | 319 | $recycleOption = isset($_POST['recycle_option']) ? true : false; |
320 | 320 | |
321 | - if (empty($element_count)) { |
|
322 | - Display::display_warning_message(get_lang('NoDataAvailable')); |
|
323 | - } else { |
|
324 | - if (!empty($hidden_fields['destination_session'])) { |
|
325 | - echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
321 | + if (empty($element_count)) { |
|
322 | + Display::display_warning_message(get_lang('NoDataAvailable')); |
|
323 | + } else { |
|
324 | + if (!empty($hidden_fields['destination_session'])) { |
|
325 | + echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
326 | 326 | get_lang('Ok').'</button>'; |
327 | - } else { |
|
327 | + } else { |
|
328 | 328 | if ($recycleOption) { |
329 | 329 | echo '<br /><button class="save" type="submit">'. |
330 | 330 | get_lang('Ok').'</button>'; |
331 | 331 | } else { |
332 | - echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'. |
|
332 | + echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'. |
|
333 | 333 | get_lang('Ok').'</button>'; |
334 | 334 | } |
335 | - } |
|
336 | - } |
|
335 | + } |
|
336 | + } |
|
337 | 337 | |
338 | - CourseSelectForm::display_hidden_quiz_questions($course); |
|
339 | - CourseSelectForm::display_hidden_scorm_directories($course); |
|
340 | - echo '</form>'; |
|
338 | + CourseSelectForm::display_hidden_quiz_questions($course); |
|
339 | + CourseSelectForm::display_hidden_scorm_directories($course); |
|
340 | + echo '</form>'; |
|
341 | 341 | echo '</div>'; |
342 | - echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
343 | - } |
|
342 | + echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
343 | + } |
|
344 | 344 | |
345 | 345 | /** |
346 | 346 | * @param $course |
347 | 347 | */ |
348 | 348 | public static function display_hidden_quiz_questions($course) |
349 | 349 | { |
350 | - if(is_array($course->resources)){ |
|
351 | - foreach ($course->resources as $type => $resources) { |
|
352 | - if (count($resources) > 0) { |
|
353 | - switch ($type) { |
|
354 | - case RESOURCE_QUIZQUESTION: |
|
355 | - foreach ($resources as $id => $resource) { |
|
356 | - echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />'; |
|
357 | - } |
|
358 | - break; |
|
359 | - } |
|
360 | - } |
|
361 | - } |
|
362 | - } |
|
363 | - } |
|
350 | + if(is_array($course->resources)){ |
|
351 | + foreach ($course->resources as $type => $resources) { |
|
352 | + if (count($resources) > 0) { |
|
353 | + switch ($type) { |
|
354 | + case RESOURCE_QUIZQUESTION: |
|
355 | + foreach ($resources as $id => $resource) { |
|
356 | + echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />'; |
|
357 | + } |
|
358 | + break; |
|
359 | + } |
|
360 | + } |
|
361 | + } |
|
362 | + } |
|
363 | + } |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * @param $course |
@@ -368,30 +368,30 @@ discard block |
||
368 | 368 | public static function display_hidden_scorm_directories($course) |
369 | 369 | { |
370 | 370 | if (is_array($course->resources)){ |
371 | - foreach ($course->resources as $type => $resources) { |
|
372 | - if (count($resources) > 0) { |
|
373 | - switch($type) { |
|
374 | - case RESOURCE_SCORM: |
|
375 | - foreach ($resources as $id => $resource) { |
|
376 | - echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />'; |
|
377 | - } |
|
378 | - break; |
|
379 | - } |
|
380 | - } |
|
381 | - } |
|
382 | - } |
|
383 | - } |
|
371 | + foreach ($course->resources as $type => $resources) { |
|
372 | + if (count($resources) > 0) { |
|
373 | + switch($type) { |
|
374 | + case RESOURCE_SCORM: |
|
375 | + foreach ($resources as $id => $resource) { |
|
376 | + echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />'; |
|
377 | + } |
|
378 | + break; |
|
379 | + } |
|
380 | + } |
|
381 | + } |
|
382 | + } |
|
383 | + } |
|
384 | 384 | |
385 | - /** |
|
386 | - * Get the posted course |
|
387 | - * @param string $from who calls the function? |
|
385 | + /** |
|
386 | + * Get the posted course |
|
387 | + * @param string $from who calls the function? |
|
388 | 388 | * It can be copy_course, create_backup, import_backup or recycle_course |
389 | 389 | * @param int $session_id |
390 | 390 | * @param string $course_code |
391 | - * @return course The course-object with all resources selected by the user |
|
392 | - * in the form given by display_form(...) |
|
393 | - */ |
|
394 | - public static function get_posted_course($from = '', $session_id = 0, $course_code = '') |
|
391 | + * @return course The course-object with all resources selected by the user |
|
392 | + * in the form given by display_form(...) |
|
393 | + */ |
|
394 | + public static function get_posted_course($from = '', $session_id = 0, $course_code = '') |
|
395 | 395 | { |
396 | 396 | $course = null; |
397 | 397 | |
@@ -401,30 +401,30 @@ discard block |
||
401 | 401 | return false; |
402 | 402 | } |
403 | 403 | |
404 | - // Create the resource DOCUMENT objects |
|
405 | - // Loading the results from the checkboxes of ethe javascript |
|
406 | - $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
404 | + // Create the resource DOCUMENT objects |
|
405 | + // Loading the results from the checkboxes of ethe javascript |
|
406 | + $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
407 | 407 | |
408 | - $course_info = api_get_course_info($course_code); |
|
409 | - $table_doc = Database::get_course_table(TABLE_DOCUMENT); |
|
410 | - $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
411 | - $course_id = $course_info['real_id']; |
|
408 | + $course_info = api_get_course_info($course_code); |
|
409 | + $table_doc = Database::get_course_table(TABLE_DOCUMENT); |
|
410 | + $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
411 | + $course_id = $course_info['real_id']; |
|
412 | 412 | |
413 | - /* Searching the documents resource that have been set to null because |
|
413 | + /* Searching the documents resource that have been set to null because |
|
414 | 414 | $avoid_serialize is true in the display_form() function*/ |
415 | - if ($from === 'copy_course') { |
|
416 | - if (is_array($resource)) { |
|
417 | - $resource = array_keys($resource); |
|
415 | + if ($from === 'copy_course') { |
|
416 | + if (is_array($resource)) { |
|
417 | + $resource = array_keys($resource); |
|
418 | 418 | |
419 | - foreach ($resource as $resource_item) { |
|
419 | + foreach ($resource as $resource_item) { |
|
420 | 420 | |
421 | - $condition_session = ''; |
|
422 | - if (!empty($session_id)) { |
|
423 | - $session_id = intval($session_id); |
|
424 | - $condition_session = ' AND d.session_id ='.$session_id; |
|
425 | - } |
|
421 | + $condition_session = ''; |
|
422 | + if (!empty($session_id)) { |
|
423 | + $session_id = intval($session_id); |
|
424 | + $condition_session = ' AND d.session_id ='.$session_id; |
|
425 | + } |
|
426 | 426 | |
427 | - $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size |
|
427 | + $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size |
|
428 | 428 | FROM '.$table_doc.' d, '.$table_prop.' p |
429 | 429 | WHERE |
430 | 430 | d.c_id = '.$course_id.' AND |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | p.ref = d.id AND p.visibility != 2 AND |
434 | 434 | d.id = '.$resource_item.$condition_session.' |
435 | 435 | ORDER BY path'; |
436 | - $db_result = Database::query($sql); |
|
437 | - while ($obj = Database::fetch_object($db_result)) { |
|
436 | + $db_result = Database::query($sql); |
|
437 | + while ($obj = Database::fetch_object($db_result)) { |
|
438 | 438 | $doc = new Document( |
439 | 439 | $obj->id, |
440 | 440 | $obj->path, |
@@ -458,25 +458,25 @@ discard block |
||
458 | 458 | } |
459 | 459 | $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties; |
460 | 460 | } |
461 | - } |
|
462 | - } |
|
463 | - } |
|
464 | - } |
|
461 | + } |
|
462 | + } |
|
463 | + } |
|
464 | + } |
|
465 | 465 | |
466 | - if (is_array($course->resources)) { |
|
467 | - foreach ($course->resources as $type => $resources) { |
|
466 | + if (is_array($course->resources)) { |
|
467 | + foreach ($course->resources as $type => $resources) { |
|
468 | 468 | |
469 | - switch ($type) { |
|
470 | - case RESOURCE_SURVEYQUESTION: |
|
471 | - foreach($resources as $id => $obj) { |
|
472 | - if (isset($_POST['resource'][RESOURCE_SURVEY]) && |
|
469 | + switch ($type) { |
|
470 | + case RESOURCE_SURVEYQUESTION: |
|
471 | + foreach($resources as $id => $obj) { |
|
472 | + if (isset($_POST['resource'][RESOURCE_SURVEY]) && |
|
473 | 473 | is_array($_POST['resource'][RESOURCE_SURVEY]) && |
474 | 474 | !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY])) |
475 | 475 | ) { |
476 | - unset($course->resources[$type][$id]); |
|
477 | - } |
|
478 | - } |
|
479 | - break; |
|
476 | + unset($course->resources[$type][$id]); |
|
477 | + } |
|
478 | + } |
|
479 | + break; |
|
480 | 480 | case RESOURCE_FORUMTOPIC: |
481 | 481 | case RESOURCE_FORUMPOST: |
482 | 482 | //Add post from topic |
@@ -528,63 +528,63 @@ discard block |
||
528 | 528 | } |
529 | 529 | } |
530 | 530 | } |
531 | - case RESOURCE_LINKCATEGORY: |
|
532 | - case RESOURCE_FORUMCATEGORY: |
|
533 | - case RESOURCE_QUIZQUESTION: |
|
534 | - case RESOURCE_DOCUMENT: |
|
535 | - // Mark folders to import which are not selected by the user to import, |
|
536 | - // but in which a document was selected. |
|
537 | - $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
538 | - if (!empty($resources) && is_array($resources)) |
|
539 | - foreach ($resources as $id => $obj) { |
|
540 | - if (isset($obj->file_type) && $obj->file_type == 'folder' && |
|
531 | + case RESOURCE_LINKCATEGORY: |
|
532 | + case RESOURCE_FORUMCATEGORY: |
|
533 | + case RESOURCE_QUIZQUESTION: |
|
534 | + case RESOURCE_DOCUMENT: |
|
535 | + // Mark folders to import which are not selected by the user to import, |
|
536 | + // but in which a document was selected. |
|
537 | + $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
538 | + if (!empty($resources) && is_array($resources)) |
|
539 | + foreach ($resources as $id => $obj) { |
|
540 | + if (isset($obj->file_type) && $obj->file_type == 'folder' && |
|
541 | 541 | !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && |
542 | 542 | is_array($documents) |
543 | 543 | ) { |
544 | - foreach ($documents as $id_to_check => $post_value) { |
|
545 | - $obj_to_check = $resources[$id_to_check]; |
|
546 | - $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); |
|
547 | - if ($id_to_check != $id && $obj->path == $shared_path_part) { |
|
548 | - $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1; |
|
549 | - break; |
|
550 | - } |
|
551 | - } |
|
552 | - } |
|
553 | - } |
|
554 | - default : |
|
555 | - if (!empty($resources) && is_array($resources)) { |
|
556 | - foreach ($resources as $id => $obj) { |
|
557 | - $resource_is_used_elsewhere = $course->is_linked_resource($obj); |
|
558 | - // check if document is in a quiz (audio/video) |
|
559 | - if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) { |
|
560 | - foreach($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
544 | + foreach ($documents as $id_to_check => $post_value) { |
|
545 | + $obj_to_check = $resources[$id_to_check]; |
|
546 | + $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); |
|
547 | + if ($id_to_check != $id && $obj->path == $shared_path_part) { |
|
548 | + $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1; |
|
549 | + break; |
|
550 | + } |
|
551 | + } |
|
552 | + } |
|
553 | + } |
|
554 | + default : |
|
555 | + if (!empty($resources) && is_array($resources)) { |
|
556 | + foreach ($resources as $id => $obj) { |
|
557 | + $resource_is_used_elsewhere = $course->is_linked_resource($obj); |
|
558 | + // check if document is in a quiz (audio/video) |
|
559 | + if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) { |
|
560 | + foreach($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
561 | 561 | $quiz = $quiz->obj; |
562 | - if (isset($quiz->media) && $quiz->media == $id) { |
|
563 | - $resource_is_used_elsewhere = true; |
|
564 | - } |
|
565 | - } |
|
566 | - } |
|
567 | - if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) { |
|
568 | - unset($course->resources[$type][$id]); |
|
569 | - } |
|
570 | - } |
|
571 | - } |
|
572 | - } |
|
573 | - } |
|
574 | - } |
|
562 | + if (isset($quiz->media) && $quiz->media == $id) { |
|
563 | + $resource_is_used_elsewhere = true; |
|
564 | + } |
|
565 | + } |
|
566 | + } |
|
567 | + if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) { |
|
568 | + unset($course->resources[$type][$id]); |
|
569 | + } |
|
570 | + } |
|
571 | + } |
|
572 | + } |
|
573 | + } |
|
574 | + } |
|
575 | 575 | |
576 | - return $course; |
|
577 | - } |
|
576 | + return $course; |
|
577 | + } |
|
578 | 578 | |
579 | - /** |
|
580 | - * Display the form session export |
|
579 | + /** |
|
580 | + * Display the form session export |
|
581 | 581 | * @param array $list_course |
582 | - * @param array $hidden_fields Hidden fields to add to the form. |
|
582 | + * @param array $hidden_fields Hidden fields to add to the form. |
|
583 | 583 | * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file |
584 | - */ |
|
585 | - public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) |
|
586 | - { |
|
587 | - ?> |
|
584 | + */ |
|
585 | + public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) |
|
586 | + { |
|
587 | + ?> |
|
588 | 588 | <script> |
589 | 589 | function exp(item) { |
590 | 590 | el = document.getElementById('div_'+item); |
@@ -626,68 +626,68 @@ discard block |
||
626 | 626 | </script> |
627 | 627 | <?php |
628 | 628 | |
629 | - //get destination course title |
|
630 | - if(!empty($hidden_fields['destination_course'])) { |
|
631 | - if (!empty($hidden_fields['destination_session'])) { |
|
632 | - $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')'; |
|
633 | - } else { |
|
634 | - $sessionTitle = null; |
|
635 | - } |
|
629 | + //get destination course title |
|
630 | + if(!empty($hidden_fields['destination_course'])) { |
|
631 | + if (!empty($hidden_fields['destination_session'])) { |
|
632 | + $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')'; |
|
633 | + } else { |
|
634 | + $sessionTitle = null; |
|
635 | + } |
|
636 | 636 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
637 | - echo '<h3>'; |
|
638 | - echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle; |
|
639 | - echo '</h3>'; |
|
640 | - } |
|
637 | + echo '<h3>'; |
|
638 | + echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle; |
|
639 | + echo '</h3>'; |
|
640 | + } |
|
641 | 641 | |
642 | - echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>'; |
|
643 | - echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
642 | + echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>'; |
|
643 | + echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
644 | 644 | $icon = Display::returnIconPath('progress_bar.gif'); |
645 | 645 | echo '<div class="tool-backups-options">'; |
646 | - echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">'; |
|
647 | - echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
648 | - foreach ($list_course as $course) { |
|
649 | - foreach ($course->resources as $type => $resources) { |
|
650 | - if (count($resources) > 0) { |
|
646 | + echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">'; |
|
647 | + echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
648 | + foreach ($list_course as $course) { |
|
649 | + foreach ($course->resources as $type => $resources) { |
|
650 | + if (count($resources) > 0) { |
|
651 | 651 | echo '<div class="item-backup" onclick="javascript:exp('."'$course->code'".');">'; |
652 | - echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>'; |
|
653 | - echo '<span class="title"> '.$course->code.'</span></div>'; |
|
654 | - echo '<div class="item-content" id="div_'.$course->code.'">'; |
|
655 | - echo '<blockquote>'; |
|
652 | + echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>'; |
|
653 | + echo '<span class="title"> '.$course->code.'</span></div>'; |
|
654 | + echo '<div class="item-content" id="div_'.$course->code.'">'; |
|
655 | + echo '<blockquote>'; |
|
656 | 656 | |
657 | 657 | echo '<div class="btn-group">'; |
658 | - echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>"; |
|
658 | + echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>"; |
|
659 | 659 | echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>"; |
660 | - echo '</div>'; |
|
660 | + echo '</div>'; |
|
661 | 661 | |
662 | - foreach ($resources as $id => $resource) { |
|
663 | - echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">'; |
|
662 | + foreach ($resources as $id => $resource) { |
|
663 | + echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">'; |
|
664 | 664 | echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>'; |
665 | - $resource->show(); |
|
666 | - echo '</label>'; |
|
667 | - } |
|
668 | - echo '</blockquote>'; |
|
669 | - echo '</div>'; |
|
670 | - echo '<script type="text/javascript">exp('."'$course->code'".')</script>'; |
|
671 | - } |
|
672 | - } |
|
673 | - } |
|
674 | - if ($avoid_serialize) { |
|
675 | - //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files) |
|
676 | - // this is a known issue of serialize |
|
677 | - $course->resources['document']= null; |
|
678 | - } |
|
679 | - echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
680 | - if (is_array($hidden_fields)) { |
|
681 | - foreach ($hidden_fields as $key => $value) { |
|
682 | - echo "\n"; |
|
683 | - echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
684 | - } |
|
685 | - } |
|
686 | - echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>'; |
|
687 | - CourseSelectForm :: display_hidden_quiz_questions($course); |
|
688 | - CourseSelectForm :: display_hidden_scorm_directories($course); |
|
689 | - echo '</form>'; |
|
665 | + $resource->show(); |
|
666 | + echo '</label>'; |
|
667 | + } |
|
668 | + echo '</blockquote>'; |
|
669 | + echo '</div>'; |
|
670 | + echo '<script type="text/javascript">exp('."'$course->code'".')</script>'; |
|
671 | + } |
|
672 | + } |
|
673 | + } |
|
674 | + if ($avoid_serialize) { |
|
675 | + //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files) |
|
676 | + // this is a known issue of serialize |
|
677 | + $course->resources['document']= null; |
|
678 | + } |
|
679 | + echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
680 | + if (is_array($hidden_fields)) { |
|
681 | + foreach ($hidden_fields as $key => $value) { |
|
682 | + echo "\n"; |
|
683 | + echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
684 | + } |
|
685 | + } |
|
686 | + echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>'; |
|
687 | + CourseSelectForm :: display_hidden_quiz_questions($course); |
|
688 | + CourseSelectForm :: display_hidden_scorm_directories($course); |
|
689 | + echo '</form>'; |
|
690 | 690 | echo '</div>'; |
691 | - echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
692 | - } |
|
691 | + echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
692 | + } |
|
693 | 693 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $oskill = new Skill(); |
71 | 71 | $skill_id = $oskill->add($skill); |
72 | 72 | $parents[$saved_id] = $skill_id; |
73 | - } |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function parse_csv_data($file) |
83 | 83 | { |
84 | - $skills = Import :: csvToArray($file); |
|
85 | - foreach ($skills as $index => $skill) { |
|
86 | - $skills[$index] = $skill; |
|
87 | - } |
|
84 | + $skills = Import :: csvToArray($file); |
|
85 | + foreach ($skills as $index => $skill) { |
|
86 | + $skills[$index] = $skill; |
|
87 | + } |
|
88 | 88 | |
89 | - return $skills; |
|
89 | + return $skills; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | */ |
95 | 95 | function element_start($parser, $data) |
96 | 96 | { |
97 | - $data = api_utf8_decode($data); |
|
98 | - global $skill; |
|
99 | - global $current_tag; |
|
100 | - switch ($data) { |
|
101 | - case 'Skill' : |
|
102 | - $skill = array (); |
|
103 | - break; |
|
104 | - default : |
|
105 | - $current_tag = $data; |
|
106 | - } |
|
97 | + $data = api_utf8_decode($data); |
|
98 | + global $skill; |
|
99 | + global $current_tag; |
|
100 | + switch ($data) { |
|
101 | + case 'Skill' : |
|
102 | + $skill = array (); |
|
103 | + break; |
|
104 | + default : |
|
105 | + $current_tag = $data; |
|
106 | + } |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function element_end($parser, $data) |
113 | 113 | { |
114 | - $data = api_utf8_decode($data); |
|
115 | - global $skill; |
|
116 | - global $skills; |
|
117 | - global $current_value; |
|
118 | - switch ($data) { |
|
119 | - case 'Skill' : |
|
120 | - $skills[] = $skill; |
|
121 | - break; |
|
122 | - default : |
|
123 | - $skill[$data] = $current_value; |
|
124 | - break; |
|
125 | - } |
|
114 | + $data = api_utf8_decode($data); |
|
115 | + global $skill; |
|
116 | + global $skills; |
|
117 | + global $current_value; |
|
118 | + switch ($data) { |
|
119 | + case 'Skill' : |
|
120 | + $skills[] = $skill; |
|
121 | + break; |
|
122 | + default : |
|
123 | + $skill[$data] = $current_value; |
|
124 | + break; |
|
125 | + } |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | */ |
131 | 131 | function character_data($parser, $data) |
132 | 132 | { |
133 | - $data = trim(api_utf8_decode($data)); |
|
134 | - global $current_value; |
|
135 | - $current_value = $data; |
|
133 | + $data = trim(api_utf8_decode($data)); |
|
134 | + global $current_value; |
|
135 | + $current_value = $data; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | */ |
143 | 143 | function parse_xml_data($file) |
144 | 144 | { |
145 | - global $current_tag; |
|
146 | - global $current_value; |
|
147 | - global $skill; |
|
148 | - global $skills; |
|
149 | - $skills = array(); |
|
150 | - $parser = xml_parser_create('UTF-8'); |
|
151 | - xml_set_element_handler($parser, 'element_start', 'element_end'); |
|
152 | - xml_set_character_data_handler($parser, 'character_data'); |
|
153 | - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); |
|
154 | - xml_parse($parser, api_utf8_encode_xml(file_get_contents($file))); |
|
155 | - xml_parser_free($parser); |
|
145 | + global $current_tag; |
|
146 | + global $current_value; |
|
147 | + global $skill; |
|
148 | + global $skills; |
|
149 | + $skills = array(); |
|
150 | + $parser = xml_parser_create('UTF-8'); |
|
151 | + xml_set_element_handler($parser, 'element_start', 'element_end'); |
|
152 | + xml_set_character_data_handler($parser, 'character_data'); |
|
153 | + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); |
|
154 | + xml_parse($parser, api_utf8_encode_xml(file_get_contents($file))); |
|
155 | + xml_parser_free($parser); |
|
156 | 156 | |
157 | - return $skills; |
|
157 | + return $skills; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | $this_section = SECTION_PLATFORM_ADMIN; |
@@ -169,73 +169,73 @@ discard block |
||
169 | 169 | $error_message = ''; |
170 | 170 | |
171 | 171 | if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) { |
172 | - $file_type = $_POST['file_type']; |
|
173 | - Security::clear_token(); |
|
174 | - $tok = Security::get_token(); |
|
175 | - $allowed_file_mimetype = array('csv','xml'); |
|
176 | - $error_kind_file = false; |
|
172 | + $file_type = $_POST['file_type']; |
|
173 | + Security::clear_token(); |
|
174 | + $tok = Security::get_token(); |
|
175 | + $allowed_file_mimetype = array('csv','xml'); |
|
176 | + $error_kind_file = false; |
|
177 | 177 | $error_message = ''; |
178 | 178 | |
179 | - $ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'],'.')+1)); |
|
179 | + $ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'],'.')+1)); |
|
180 | 180 | |
181 | - if (in_array($ext_import_file,$allowed_file_mimetype)) { |
|
182 | - if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) { |
|
183 | - $skills = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
184 | - $errors = validate_data($skills); |
|
185 | - $error_kind_file = false; |
|
186 | - } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) { |
|
187 | - $skills = parse_xml_data($_FILES['import_file']['tmp_name']); |
|
188 | - $errors = validate_data($skills); |
|
189 | - $error_kind_file = false; |
|
190 | - } else { |
|
191 | - $error_kind_file = true; |
|
192 | - } |
|
193 | - } else { |
|
194 | - $error_kind_file = true; |
|
195 | - } |
|
181 | + if (in_array($ext_import_file,$allowed_file_mimetype)) { |
|
182 | + if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) { |
|
183 | + $skills = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
184 | + $errors = validate_data($skills); |
|
185 | + $error_kind_file = false; |
|
186 | + } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) { |
|
187 | + $skills = parse_xml_data($_FILES['import_file']['tmp_name']); |
|
188 | + $errors = validate_data($skills); |
|
189 | + $error_kind_file = false; |
|
190 | + } else { |
|
191 | + $error_kind_file = true; |
|
192 | + } |
|
193 | + } else { |
|
194 | + $error_kind_file = true; |
|
195 | + } |
|
196 | 196 | |
197 | - // List skill id with error. |
|
198 | - $skills_to_insert = $skill_id_error = array(); |
|
199 | - if (is_array($errors)) { |
|
200 | - foreach ($errors as $my_errors) { |
|
201 | - $skill_id_error[] = $my_errors['SkillName']; |
|
202 | - } |
|
203 | - } |
|
204 | - if (is_array($skills)) { |
|
205 | - foreach ($skills as $my_skill) { |
|
206 | - if (isset($my_skill['name']) && !in_array($my_skill['name'], $skill_id_error)) { |
|
207 | - $skills_to_insert[] = $my_skill; |
|
208 | - } |
|
209 | - } |
|
210 | - } |
|
197 | + // List skill id with error. |
|
198 | + $skills_to_insert = $skill_id_error = array(); |
|
199 | + if (is_array($errors)) { |
|
200 | + foreach ($errors as $my_errors) { |
|
201 | + $skill_id_error[] = $my_errors['SkillName']; |
|
202 | + } |
|
203 | + } |
|
204 | + if (is_array($skills)) { |
|
205 | + foreach ($skills as $my_skill) { |
|
206 | + if (isset($my_skill['name']) && !in_array($my_skill['name'], $skill_id_error)) { |
|
207 | + $skills_to_insert[] = $my_skill; |
|
208 | + } |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | - if (strcmp($file_type, 'csv') === 0) { |
|
213 | - save_data($skills_to_insert); |
|
214 | - } elseif (strcmp($file_type, 'xml') === 0) { |
|
215 | - save_data($skills_to_insert); |
|
216 | - } else { |
|
217 | - $error_message = get_lang('YouMustImportAFileAccordingToSelectedOption'); |
|
218 | - } |
|
212 | + if (strcmp($file_type, 'csv') === 0) { |
|
213 | + save_data($skills_to_insert); |
|
214 | + } elseif (strcmp($file_type, 'xml') === 0) { |
|
215 | + save_data($skills_to_insert); |
|
216 | + } else { |
|
217 | + $error_message = get_lang('YouMustImportAFileAccordingToSelectedOption'); |
|
218 | + } |
|
219 | 219 | |
220 | - if (count($errors) > 0) { |
|
221 | - $see_message_import = get_lang('FileImportedJustSkillsThatAreNotRegistered'); |
|
222 | - } else { |
|
223 | - $see_message_import = get_lang('FileImported'); |
|
224 | - } |
|
220 | + if (count($errors) > 0) { |
|
221 | + $see_message_import = get_lang('FileImportedJustSkillsThatAreNotRegistered'); |
|
222 | + } else { |
|
223 | + $see_message_import = get_lang('FileImported'); |
|
224 | + } |
|
225 | 225 | |
226 | - if (count($errors) != 0) { |
|
227 | - $warning_message = '<ul>'; |
|
228 | - foreach ($errors as $index => $error_skill) { |
|
229 | - $warning_message .= '<li><b>'.$error_skill['error'].'</b>: '; |
|
230 | - $warning_message .= '<strong>'.$error_skill['SkillName'].'</strong> ('.$error_skill['SkillName'].')'; |
|
231 | - $warning_message .= '</li>'; |
|
232 | - } |
|
233 | - $warning_message .= '</ul>'; |
|
234 | - } |
|
226 | + if (count($errors) != 0) { |
|
227 | + $warning_message = '<ul>'; |
|
228 | + foreach ($errors as $index => $error_skill) { |
|
229 | + $warning_message .= '<li><b>'.$error_skill['error'].'</b>: '; |
|
230 | + $warning_message .= '<strong>'.$error_skill['SkillName'].'</strong> ('.$error_skill['SkillName'].')'; |
|
231 | + $warning_message .= '</li>'; |
|
232 | + } |
|
233 | + $warning_message .= '</ul>'; |
|
234 | + } |
|
235 | 235 | |
236 | 236 | if ($error_kind_file) { |
237 | - $error_message = get_lang('YouMustImportAFileAccordingToSelectedOption'); |
|
238 | - } |
|
237 | + $error_message = get_lang('YouMustImportAFileAccordingToSelectedOption'); |
|
238 | + } |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | $interbreadcrumb[] = array ("url" => 'skill_list.php', "name" => get_lang('ManageSkills')); |
@@ -243,34 +243,34 @@ discard block |
||
243 | 243 | Display :: display_header($tool_name); |
244 | 244 | |
245 | 245 | if (!empty($error_message)) { |
246 | - Display::display_error_message($error_message); |
|
246 | + Display::display_error_message($error_message); |
|
247 | 247 | } |
248 | 248 | if (!empty($see_message_import)) { |
249 | - Display::display_normal_message($see_message_import); |
|
249 | + Display::display_normal_message($see_message_import); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | $toolbar = Display::toolbarButton( |
253 | - get_lang('ManageSkills'), |
|
254 | - api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php', |
|
255 | - 'list', |
|
256 | - 'success', |
|
257 | - ['title' => get_lang('CreateSkill')] |
|
253 | + get_lang('ManageSkills'), |
|
254 | + api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php', |
|
255 | + 'list', |
|
256 | + 'success', |
|
257 | + ['title' => get_lang('CreateSkill')] |
|
258 | 258 | ); |
259 | 259 | $toolbar .= ' '; |
260 | 260 | $toolbar .= Display::toolbarButton( |
261 | - get_lang('SkillsWheel'), |
|
262 | - api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php', |
|
263 | - 'bullseye', |
|
264 | - 'primary', |
|
265 | - ['title' => get_lang('CreateSkill')] |
|
261 | + get_lang('SkillsWheel'), |
|
262 | + api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php', |
|
263 | + 'bullseye', |
|
264 | + 'primary', |
|
265 | + ['title' => get_lang('CreateSkill')] |
|
266 | 266 | ); |
267 | 267 | $toolbar .= ' '; |
268 | 268 | $toolbar .= Display::toolbarButton( |
269 | - get_lang('BadgesManagement'), |
|
270 | - api_get_path(WEB_CODE_PATH) . 'admin/skill_badge_list.php', |
|
271 | - 'shield', |
|
272 | - 'warning', |
|
273 | - ['title' => get_lang('BadgesManagement')] |
|
269 | + get_lang('BadgesManagement'), |
|
270 | + api_get_path(WEB_CODE_PATH) . 'admin/skill_badge_list.php', |
|
271 | + 'shield', |
|
272 | + 'warning', |
|
273 | + ['title' => get_lang('BadgesManagement')] |
|
274 | 274 | ); |
275 | 275 | $toolbar .= '<br /><br />'; |
276 | 276 | |
@@ -296,16 +296,16 @@ discard block |
||
296 | 296 | $i = 0; |
297 | 297 | $count_fields = count($extra_fields); |
298 | 298 | if ($count_fields > 0) { |
299 | - foreach ($extra_fields as $extra) { |
|
300 | - $list[] = $extra[1]; |
|
301 | - $list_reponse[] = 'xxx'; |
|
302 | - $spaces = ' '; |
|
303 | - $result_xml .= $spaces.'<'.$extra[1].'>xxx</'.$extra[1].'>'; |
|
304 | - if ($i != $count_fields - 1) { |
|
305 | - $result_xml .= '<br/>'; |
|
306 | - } |
|
307 | - $i++; |
|
308 | - } |
|
299 | + foreach ($extra_fields as $extra) { |
|
300 | + $list[] = $extra[1]; |
|
301 | + $list_reponse[] = 'xxx'; |
|
302 | + $spaces = ' '; |
|
303 | + $result_xml .= $spaces.'<'.$extra[1].'>xxx</'.$extra[1].'>'; |
|
304 | + if ($i != $count_fields - 1) { |
|
305 | + $result_xml .= '<br/>'; |
|
306 | + } |
|
307 | + $i++; |
|
308 | + } |
|
309 | 309 | } |
310 | 310 | ?> |
311 | 311 | <p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p> |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $add_type = 'unique'; |
39 | 39 | |
40 | 40 | if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') { |
41 | - $add_type = Security::remove_XSS($_REQUEST['add_type']); |
|
41 | + $add_type = Security::remove_XSS($_REQUEST['add_type']); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null; |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | |
427 | 427 | if ($use_extra_fields) { |
428 | 428 | $final_result = array(); |
429 | - if (count($extra_field_result)>1) { |
|
430 | - for($i=0;$i<count($extra_field_result)-1;$i++) { |
|
429 | + if (count($extra_field_result)>1) { |
|
430 | + for($i=0;$i<count($extra_field_result)-1;$i++) { |
|
431 | 431 | if (is_array($extra_field_result[$i+1])) { |
432 | 432 | $final_result = array_intersect($extra_field_result[$i],$extra_field_result[$i+1]); |
433 | 433 | } |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | 'official_code' => $user['official_code'] |
504 | 504 | ) ; |
505 | 505 | unset($users[$uid]); |
506 | - } |
|
506 | + } |
|
507 | 507 | } |
508 | 508 | unset($users); //clean to free memory |
509 | 509 | |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | } |
548 | 548 | |
549 | 549 | if ($add_type == 'multiple') { |
550 | - $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=unique">'. |
|
550 | + $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=unique">'. |
|
551 | 551 | Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; |
552 | - $link_add_type_multiple = Display::url(Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'), ''); |
|
552 | + $link_add_type_multiple = Display::url(Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'), ''); |
|
553 | 553 | } else { |
554 | - $link_add_type_unique = Display::url(Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'), ''); |
|
555 | - $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; |
|
554 | + $link_add_type_unique = Display::url(Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'), ''); |
|
555 | + $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; |
|
556 | 556 | } |
557 | 557 | $link_add_group = Display::url( |
558 | 558 | Display::return_icon('multiple.gif',get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups'), |
@@ -580,17 +580,17 @@ discard block |
||
580 | 580 | <?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?> |
581 | 581 | <?php |
582 | 582 | if ($add_type=='multiple') { |
583 | - if (is_array($extra_field_list)) { |
|
584 | - if (is_array($new_field_list) && count($new_field_list)>0 ) { |
|
585 | - echo '<h3>'.get_lang('FilterUsers').'</h3>'; |
|
586 | - foreach ($new_field_list as $new_field) { |
|
587 | - echo $new_field['name']; |
|
588 | - $varname = 'field_'.$new_field['variable']; |
|
583 | + if (is_array($extra_field_list)) { |
|
584 | + if (is_array($new_field_list) && count($new_field_list)>0 ) { |
|
585 | + echo '<h3>'.get_lang('FilterUsers').'</h3>'; |
|
586 | + foreach ($new_field_list as $new_field) { |
|
587 | + echo $new_field['name']; |
|
588 | + $varname = 'field_'.$new_field['variable']; |
|
589 | 589 | $fieldtype = $new_field['type']; |
590 | - echo ' <select name="'.$varname.'">'; |
|
591 | - echo '<option value="0">--'.get_lang('Select').'--</option>'; |
|
592 | - foreach ($new_field['data'] as $option) { |
|
593 | - $checked=''; |
|
590 | + echo ' <select name="'.$varname.'">'; |
|
591 | + echo '<option value="0">--'.get_lang('Select').'--</option>'; |
|
592 | + foreach ($new_field['data'] as $option) { |
|
593 | + $checked=''; |
|
594 | 594 | if ($fieldtype == ExtraField::FIELD_TYPE_TAG) { |
595 | 595 | if (isset($_POST[$varname])) { |
596 | 596 | if ($_POST[$varname] == $option['tag']) { |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | $extraHidden = $fieldtype == ExtraField::FIELD_TYPE_TAG ? '<input type="hidden" name="field_id" value="'.$option['field_id'].'" />' : ''; |
612 | 612 | echo $extraHidden; |
613 | 613 | echo ' '; |
614 | - } |
|
615 | - echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />'; |
|
616 | - echo '<br /><br />'; |
|
617 | - } |
|
618 | - } |
|
614 | + } |
|
615 | + echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />'; |
|
616 | + echo '<br /><br />'; |
|
617 | + } |
|
618 | + } |
|
619 | 619 | } |
620 | 620 | ?> |
621 | 621 | <input type="hidden" name="form_sent" value="1" /> |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | |
624 | 624 | <?php |
625 | 625 | if (!empty($errorMsg)) { |
626 | - Display::display_normal_message($errorMsg); //main API |
|
626 | + Display::display_normal_message($errorMsg); //main API |
|
627 | 627 | } |
628 | 628 | ?> |
629 | 629 | <div id="multiple-add-session" class="row"> |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | <label><?php echo get_lang('UserListInPlatform') ?> </label> |
633 | 633 | <?php |
634 | 634 | if (!($add_type=='multiple')) { |
635 | - ?> |
|
635 | + ?> |
|
636 | 636 | <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" class="form-control" /> |
637 | 637 | <div id="ajax_list_users_single" class="select-list-ajax"></div> |
638 | 638 | <?php |
@@ -641,21 +641,21 @@ discard block |
||
641 | 641 | <div id="ajax_list_users_multiple"> |
642 | 642 | <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" class="form-control"> |
643 | 643 | <?php |
644 | - foreach ($nosessionUsersList as $uid => $enreg) { |
|
645 | - ?> |
|
644 | + foreach ($nosessionUsersList as $uid => $enreg) { |
|
645 | + ?> |
|
646 | 646 | <option value="<?php echo $uid; ?>" <?php if(in_array($uid,$UserList)) echo 'selected="selected"'; ?>> |
647 | 647 | <?php |
648 | - $personName = api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].') '.$enreg['official_code']; |
|
649 | - if ($showOfficialCode) { |
|
650 | - $officialCode = !empty($enreg['official_code']) ? $enreg['official_code'].' - ' : '? - '; |
|
651 | - $personName = $officialCode.api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')'; |
|
652 | - } |
|
653 | - echo $personName; |
|
654 | - ?> |
|
648 | + $personName = api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].') '.$enreg['official_code']; |
|
649 | + if ($showOfficialCode) { |
|
650 | + $officialCode = !empty($enreg['official_code']) ? $enreg['official_code'].' - ' : '? - '; |
|
651 | + $personName = $officialCode.api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')'; |
|
652 | + } |
|
653 | + echo $personName; |
|
654 | + ?> |
|
655 | 655 | </option> |
656 | 656 | <?php |
657 | - } |
|
658 | - ?> |
|
657 | + } |
|
658 | + ?> |
|
659 | 659 | </select> |
660 | 660 | </div> |
661 | 661 | <input type="checkbox" onchange="checked_in_no_session(this.checked);" name="user_with_any_session" id="user_with_any_session_id"> |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | <?php |
664 | 664 | } |
665 | 665 | unset($nosessionUsersList); |
666 | - ?> |
|
666 | + ?> |
|
667 | 667 | </div> |
668 | 668 | </div> |
669 | 669 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | <?php |
708 | 708 | } |
709 | 709 | if (!empty($addProcess)) { |
710 | - echo '<button class="btn btn-success" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>'; |
|
710 | + echo '<button class="btn btn-success" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>'; |
|
711 | 711 | } else { |
712 | 712 | echo '<button class="btn btn-success" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToSession').'</button>'; |
713 | 713 | } |