Completed
Push — 1.11.x ( 78f130...f6f5c2 )
by José
50:40 queued 24:26
created
main/document/edit_document.php 2 patches
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 $sessionId = api_get_session_id();
70 70
 
71 71
 if (api_is_in_group()) {
72
-	$group_properties = GroupManager::get_group_properties($group_id);
72
+    $group_properties = GroupManager::get_group_properties($group_id);
73 73
 }
74 74
 
75 75
 $dir = '/';
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         $_GET['id'],
82 82
         api_get_course_id(),
83 83
         true,
84
-		0
84
+        0
85 85
     );
86 86
 
87 87
     if (!empty($sessionId) && empty($document_data)) {
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
         );
94 94
     }
95 95
 
96
-	$document_id = $document_data['id'];
97
-	$file = $document_data['path'];
98
-	$parent_id = DocumentManager::get_document_id($course_info, dirname($file));
99
-	$dir = dirname($document_data['path']);
100
-	$dir_original = $dir;
101
-	$doc = basename($file);
102
-	$readonly = $document_data['readonly'];
96
+    $document_id = $document_data['id'];
97
+    $file = $document_data['path'];
98
+    $parent_id = DocumentManager::get_document_id($course_info, dirname($file));
99
+    $dir = dirname($document_data['path']);
100
+    $dir_original = $dir;
101
+    $doc = basename($file);
102
+    $readonly = $document_data['readonly'];
103 103
 }
104 104
 
105 105
 if (empty($document_data)) {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
 // Level correction for group documents.
123 123
 if (!empty($group_properties['directory'])) {
124
-	$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
124
+    $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
125 125
 }
126 126
 $relative_url = '';
127 127
 for ($i = 0; $i < ($count_dir); $i++) {
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 );
144 144
 
145 145
 if ($is_certificate_mode) {
146
-	$editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
147
-	$editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
148
-	$editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
146
+    $editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
147
+    $editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
148
+    $editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
149 149
 }
150 150
 
151 151
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights']||
152
-	DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId);
152
+    DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId);
153 153
 $noPHP_SELF = true;
154 154
 
155 155
 /*	Other initialization code */
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
         'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
163 163
         'name' => get_lang('GroupSpace'),
164 164
     );
165
-	$group_document = true;
166
-	$noPHP_SELF = true;
165
+    $group_document = true;
166
+    $noPHP_SELF = true;
167 167
 }
168 168
 
169 169
 if (!$is_certificate_mode) {
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 
198 198
 //TODO:check the below code and his funcionality
199 199
 if (!api_is_allowed_to_edit()) {
200
-	if (DocumentManager::check_readonly($course_info, $user_id, $file)) {
201
-		api_not_allowed();
202
-	}
200
+    if (DocumentManager::check_readonly($course_info, $user_id, $file)) {
201
+        api_not_allowed();
202
+    }
203 203
 }
204 204
 
205 205
 /* MAIN TOOL CODE */
@@ -207,18 +207,18 @@  discard block
 block discarded – undo
207 207
 /*	Code to change the comment	*/
208 208
 
209 209
 if (isset($_POST['comment'])) {
210
-	// Fixing the path if it is wrong
211
-	$comment = trim($_POST['comment']);
212
-	$title = trim($_POST['title']);
210
+    // Fixing the path if it is wrong
211
+    $comment = trim($_POST['comment']);
212
+    $title = trim($_POST['title']);
213 213
 
214 214
     // Just in case see BT#3525
215 215
     if (empty($title)) {
216
-		$title = $document_data['title'];
217
-	}
216
+        $title = $document_data['title'];
217
+    }
218 218
 
219
-	if (empty($title)) {
220
-		$title = get_document_title($_POST['filename']);
221
-	}
219
+    if (empty($title)) {
220
+        $title = get_document_title($_POST['filename']);
221
+    }
222 222
 
223 223
     if (!empty($document_id)) {
224 224
         $params = [
@@ -230,43 +230,43 @@  discard block
 block discarded – undo
230 230
             $params,
231 231
             ['c_id = ? AND id = ?' => [$course_id, $document_id]]
232 232
         );
233
-		Display::addFlash(Display::return_message(get_lang('fileModified')));
233
+        Display::addFlash(Display::return_message(get_lang('fileModified')));
234 234
     }
235 235
 }
236 236
 
237 237
 /*	WYSIWYG HTML EDITOR - Program Logic */
238 238
 if ($is_allowed_to_edit) {
239
-	if (isset($_POST['formSent']) && $_POST['formSent'] == 1) {
239
+    if (isset($_POST['formSent']) && $_POST['formSent'] == 1) {
240 240
 
241
-		$filename = stripslashes($_POST['filename']);
241
+        $filename = stripslashes($_POST['filename']);
242 242
         $extension = $_POST['extension'];
243
-		$content = isset($_POST['content']) ? trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content']))) : null;
244
-		$content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY);
243
+        $content = isset($_POST['content']) ? trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content']))) : null;
244
+        $content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY);
245 245
 
246 246
         if ($dir == '/') {
247 247
             $dir = '';
248 248
         }
249 249
 
250
-		$file = $dir.'/'.$filename.'.'.$extension;
251
-		$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
252
-		$read_only_flag = empty($read_only_flag) ? 0 : 1;
250
+        $file = $dir.'/'.$filename.'.'.$extension;
251
+        $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
252
+        $read_only_flag = empty($read_only_flag) ? 0 : 1;
253 253
 
254
-		if (empty($filename)) {
254
+        if (empty($filename)) {
255 255
             Display::addFlash(Display::return_message(get_lang('NoFileName'), 'warning'));
256
-		} else {
256
+        } else {
257 257
 
258
-		    $file_size = filesize($document_data['absolute_path']);
258
+            $file_size = filesize($document_data['absolute_path']);
259 259
 
260
-			if ($read_only_flag == 0) {
261
-				if (!empty($content)) {
262
-					if ($fp = @fopen($document_data['absolute_path'], 'w')) {
263
-						// For flv player, change absolute path temporarily to prevent from erasing it in the following lines
264
-						$content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content);
265
- 						fputs($fp, $content);
266
-						fclose($fp);
260
+            if ($read_only_flag == 0) {
261
+                if (!empty($content)) {
262
+                    if ($fp = @fopen($document_data['absolute_path'], 'w')) {
263
+                        // For flv player, change absolute path temporarily to prevent from erasing it in the following lines
264
+                        $content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content);
265
+                            fputs($fp, $content);
266
+                        fclose($fp);
267 267
 
268 268
                         $filepath = $document_data['absolute_parent_path'];
269
-						/*
269
+                        /*
270 270
 						if (!is_dir($filepath.'css')) {
271 271
 							mkdir($filepath.'css', api_get_permissions_for_new_directories());
272 272
 							$doc_id = add_document($_course, $dir.'css', 'folder', 0, 'css');
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 							);
297 297
 						}*/
298 298
 
299
-						/*if (!is_file($filepath.'css/frames.css')) {
299
+                        /*if (!is_file($filepath.'css/frames.css')) {
300 300
 							$platform_theme = api_get_setting('stylesheets');
301 301
 							if (file_exists(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css')) {
302 302
 								copy(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css', $filepath.'css/frames.css');
@@ -334,54 +334,54 @@  discard block
 block discarded – undo
334 334
 							}
335 335
 						}*/
336 336
 
337
-						// "WHAT'S NEW" notification: update table item_property
338
-						$document_id = DocumentManager::get_document_id($_course, $file);
339
-
340
-						if ($document_id) {
341
-							update_existing_document(
342
-								$_course,
343
-								$document_id,
344
-								$file_size,
345
-								$read_only_flag
346
-							);
347
-							api_item_property_update(
348
-								$_course,
349
-								TOOL_DOCUMENT,
350
-								$document_id,
351
-								'DocumentUpdated',
352
-								api_get_user_id(),
353
-								null,
354
-								null,
355
-								null,
356
-								null,
357
-								$sessionId
358
-							);
359
-							// Update parent folders
360
-							item_property_update_on_folder(
361
-								$_course,
362
-								$dir,
363
-								api_get_user_id()
364
-							);
365
-							header('Location: document.php?id=' . $document_data['parent_id'] . '&' . api_get_cidreq() . ($is_certificate_mode?'&curdirpath=/certificates&selectcat=1':''));
366
-							exit;
367
-						} else {
337
+                        // "WHAT'S NEW" notification: update table item_property
338
+                        $document_id = DocumentManager::get_document_id($_course, $file);
339
+
340
+                        if ($document_id) {
341
+                            update_existing_document(
342
+                                $_course,
343
+                                $document_id,
344
+                                $file_size,
345
+                                $read_only_flag
346
+                            );
347
+                            api_item_property_update(
348
+                                $_course,
349
+                                TOOL_DOCUMENT,
350
+                                $document_id,
351
+                                'DocumentUpdated',
352
+                                api_get_user_id(),
353
+                                null,
354
+                                null,
355
+                                null,
356
+                                null,
357
+                                $sessionId
358
+                            );
359
+                            // Update parent folders
360
+                            item_property_update_on_folder(
361
+                                $_course,
362
+                                $dir,
363
+                                api_get_user_id()
364
+                            );
365
+                            header('Location: document.php?id=' . $document_data['parent_id'] . '&' . api_get_cidreq() . ($is_certificate_mode?'&curdirpath=/certificates&selectcat=1':''));
366
+                            exit;
367
+                        } else {
368 368
                             Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning'));
369
-						}
370
-					} else {
369
+                        }
370
+                    } else {
371 371
                         Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning'));
372
-					}
373
-				} else {
374
-					if ($document_id) {
372
+                    }
373
+                } else {
374
+                    if ($document_id) {
375 375
                         update_existing_document($_course, $document_id, $file_size, $read_only_flag);
376
-					}
377
-				}
378
-			} else {
376
+                    }
377
+                }
378
+            } else {
379 379
                 if ($document_id) {
380 380
                     update_existing_document($_course, $document_id, $file_size, $read_only_flag);
381 381
                 }
382
-			}
383
-		}
384
-	}
382
+            }
383
+        }
384
+    }
385 385
 }
386 386
 
387 387
 // Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/')
@@ -435,35 +435,35 @@  discard block
 block discarded – undo
435 435
         api_get_group_id()
436 436
     )
437 437
 ) {
438
-	$action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq();
438
+    $action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq();
439 439
     if ($is_certificate_mode) {
440 440
         $action .= '&curdirpath=/certificates&selectcat=1';
441 441
     }
442
-	$form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical'));
443
-
444
-	// Form title
445
-	$form->addElement('header', $nameTools);
446
-	$form->addElement('hidden', 'filename');
447
-	$form->addElement('hidden', 'extension');
448
-	$form->addElement('hidden', 'file_path');
449
-	$form->addElement('hidden', 'commentPath');
450
-	$form->addElement('hidden', 'showedit');
451
-	$form->addElement('hidden', 'origin');
452
-	$form->addElement('hidden', 'origin_opt');
442
+    $form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical'));
443
+
444
+    // Form title
445
+    $form->addElement('header', $nameTools);
446
+    $form->addElement('hidden', 'filename');
447
+    $form->addElement('hidden', 'extension');
448
+    $form->addElement('hidden', 'file_path');
449
+    $form->addElement('hidden', 'commentPath');
450
+    $form->addElement('hidden', 'showedit');
451
+    $form->addElement('hidden', 'origin');
452
+    $form->addElement('hidden', 'origin_opt');
453 453
     $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
454 454
 
455
-	$defaults['title'] = $document_data['title'];
455
+    $defaults['title'] = $document_data['title'];
456 456
 
457
-	$form->addElement('hidden', 'formSent');
458
-	$defaults['formSent'] = 1;
457
+    $form->addElement('hidden', 'formSent');
458
+    $defaults['formSent'] = 1;
459 459
 
460
-	$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
460
+    $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
461 461
 
462
-	// Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor.
463
-	// This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
464
-	$defaults['content'] = str_replace('<!--[', '<!-- [', $content);
462
+    // Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor.
463
+    // This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
464
+    $defaults['content'] = str_replace('<!--[', '<!-- [', $content);
465 465
 
466
-	// HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
466
+    // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
467 467
 
468 468
     $showSystemFolders = api_get_course_setting('show_system_folders');
469 469
     $condition = stripos($dir, '/HotPotatoes_files') === false;
@@ -471,44 +471,44 @@  discard block
 block discarded – undo
471 471
         $condition = true;
472 472
     }
473 473
 
474
-	if (($extension == 'htm' || $extension == 'html') && $condition) {
475
-		if (empty($readonly) && $readonly == 0) {
474
+    if (($extension == 'htm' || $extension == 'html') && $condition) {
475
+        if (empty($readonly) && $readonly == 0) {
476 476
             $form->addHtmlEditor('content', '', true, true, $editorConfig);
477
-		}
478
-	}
477
+        }
478
+    }
479 479
 
480
-	if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
481
-		// Updated on field
480
+    if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
481
+        // Updated on field
482 482
         $display_date = date_to_str_ago($last_edit_date).
483
-			' <span class="dropbox_date">'.api_format_date(api_get_local_time($last_edit_date)).'</span>';
484
-		$form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
485
-	}
483
+            ' <span class="dropbox_date">'.api_format_date(api_get_local_time($last_edit_date)).'</span>';
484
+        $form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
485
+    }
486 486
 
487
-	$form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
487
+    $form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
488 488
 
489
-	if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
490
-		$checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
491
-		if ($readonly == 1) {
492
-			$checked->setChecked(true);
493
-		}
494
-	}
489
+    if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
490
+        $checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
491
+        if ($readonly == 1) {
492
+            $checked->setChecked(true);
493
+        }
494
+    }
495 495
 
496
-	if ($is_certificate_mode) {
497
-		$form->addButtonUpdate(get_lang('SaveCertificate'));
496
+    if ($is_certificate_mode) {
497
+        $form->addButtonUpdate(get_lang('SaveCertificate'));
498 498
     } else {
499
-		$form->addButtonUpdate(get_lang('SaveDocument'));
499
+        $form->addButtonUpdate(get_lang('SaveDocument'));
500 500
     }
501 501
 
502
-	$defaults['filename'] = $filename;
503
-	$defaults['extension'] = $extension;
504
-	$defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
505
-	$defaults['commentPath'] = $file;
506
-	$defaults['renameTo'] = $file_name;
507
-	$defaults['comment'] = $document_data['comment'];
508
-	$defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
509
-	$defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
502
+    $defaults['filename'] = $filename;
503
+    $defaults['extension'] = $extension;
504
+    $defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
505
+    $defaults['commentPath'] = $file;
506
+    $defaults['renameTo'] = $file_name;
507
+    $defaults['comment'] = $document_data['comment'];
508
+    $defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
509
+    $defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
510 510
 
511
-	$form->setDefaults($defaults);
511
+    $form->setDefaults($defaults);
512 512
 
513 513
     show_return(
514 514
         $parent_id,
@@ -518,25 +518,25 @@  discard block
 block discarded – undo
518 518
         $is_certificate_mode
519 519
     );
520 520
 
521
-	if ($is_certificate_mode) {
522
-		$all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
523
-			api_get_user_id(),
524
-			api_get_course_id()
525
-		);
526
-		$str_info = '';
527
-		foreach ($all_information_by_create_certificate[0] as $info_value) {
528
-			$str_info .= $info_value.'<br/>';
529
-		}
530
-		$create_certificate=get_lang('CreateCertificateWithTags');
531
-		Display::display_normal_message(
532
-			$create_certificate.': <br /><br />'.$str_info,
533
-			false
534
-		);
535
-	}
536
-
537
-	if ($extension=='svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true'){
538
-		Display::display_warning_message(get_lang('BrowserDontSupportsSVG'));
539
-	}
521
+    if ($is_certificate_mode) {
522
+        $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
523
+            api_get_user_id(),
524
+            api_get_course_id()
525
+        );
526
+        $str_info = '';
527
+        foreach ($all_information_by_create_certificate[0] as $info_value) {
528
+            $str_info .= $info_value.'<br/>';
529
+        }
530
+        $create_certificate=get_lang('CreateCertificateWithTags');
531
+        Display::display_normal_message(
532
+            $create_certificate.': <br /><br />'.$str_info,
533
+            false
534
+        );
535
+    }
536
+
537
+    if ($extension=='svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true'){
538
+        Display::display_warning_message(get_lang('BrowserDontSupportsSVG'));
539
+    }
540 540
     // HTML-editor
541 541
     echo '<div class="page-create">
542 542
             <div class="row" style="overflow:hidden">
@@ -563,26 +563,26 @@  discard block
 block discarded – undo
563 563
 */
564 564
 function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc)
565 565
 {
566
-	$file_name_for_change = $base_work_dir.$dir.$source_file;
566
+    $file_name_for_change = $base_work_dir.$dir.$source_file;
567 567
     $rename_to = disable_dangerous_file($rename_to); // Avoid renaming to .htaccess file
568
-	$rename_to = my_rename($file_name_for_change, stripslashes($rename_to)); // fileManage API
569
-
570
-	if ($rename_to) {
571
-		if (isset($dir) && $dir != '') {
572
-			$source_file = $dir.$source_file;
573
-			$new_full_file_name = dirname($source_file).'/'.$rename_to;
574
-		} else {
575
-			$source_file = '/'.$source_file;
576
-			$new_full_file_name = '/'.$rename_to;
577
-		}
578
-
579
-		update_db_info('update', $source_file, $new_full_file_name); // fileManage API
568
+    $rename_to = my_rename($file_name_for_change, stripslashes($rename_to)); // fileManage API
569
+
570
+    if ($rename_to) {
571
+        if (isset($dir) && $dir != '') {
572
+            $source_file = $dir.$source_file;
573
+            $new_full_file_name = dirname($source_file).'/'.$rename_to;
574
+        } else {
575
+            $source_file = '/'.$source_file;
576
+            $new_full_file_name = '/'.$rename_to;
577
+        }
578
+
579
+        update_db_info('update', $source_file, $new_full_file_name); // fileManage API
580 580
         Display::addFlash(Display::return_message(get_lang('fileModified')));
581 581
 
582
-		return true;
583
-	} else {
582
+        return true;
583
+    } else {
584 584
         Display::addFlash(Display::return_message(get_lang('FileExists')));
585
-	}
585
+    }
586 586
 }
587 587
 
588 588
 //return button back to
@@ -595,32 +595,32 @@  discard block
 block discarded – undo
595 595
     global $parent_id;
596 596
     $url = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&id='.$parent_id;
597 597
 
598
-	if ($is_certificate_mode) {
599
-		$selectedCategory = (isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : '');
600
-		$actionsLeft .= '<a href="document.php?curdirpath='. $selectedCategory .'&selectcat=' . $selectedCategory .'">'.
598
+    if ($is_certificate_mode) {
599
+        $selectedCategory = (isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : '');
600
+        $actionsLeft .= '<a href="document.php?curdirpath='. $selectedCategory .'&selectcat=' . $selectedCategory .'">'.
601 601
             Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>';
602 602
         $actionsLeft .= '<a id="hide_bar_template" href="#">'.Display::return_icon('expand.png',get_lang('Expand'),array('id'=>'expand'),ICON_SIZE_MEDIUM).Display::return_icon('contract.png',get_lang('Collapse'),array('id'=>'contract', 'class'=>'hide'),ICON_SIZE_MEDIUM).'</a>';
603
-	} elseif($call_from_tool=='slideshow') {
604
-		$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'.
603
+    } elseif($call_from_tool=='slideshow') {
604
+        $actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'.
605 605
             Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('ViewSlideshow'),'',ICON_SIZE_MEDIUM).'</a>';
606
-	} elseif($call_from_tool=='editdraw') {
607
-		$actionsLeft .= '<a href="'.$url.'">'.
606
+    } elseif($call_from_tool=='editdraw') {
607
+        $actionsLeft .= '<a href="'.$url.'">'.
608 608
             Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
609
-		$actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), array(), 32).'</a>';
610
-	} elseif($call_from_tool=='editodf') {
609
+        $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), array(), 32).'</a>';
610
+    } elseif($call_from_tool=='editodf') {
611 611
         $actionsLeft .= '<a href="'.$url.'">'.
612 612
             Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
613 613
         $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Write'), array(), 32).'</a>';
614 614
         $actionsLeft .= '<a id="hide_bar_template" href="#">'.Display::return_icon('expand.png',get_lang('Expand'),array('id'=>'expand'),ICON_SIZE_MEDIUM).Display::return_icon('contract.png',get_lang('Collapse'),array('id'=>'contract', 'class'=>'hide'),ICON_SIZE_MEDIUM).'</a>';
615 615
     } elseif($call_from_tool=='editpaint'){
616
-		$actionsLeft .= '<a href="'.$url.'">'.
616
+        $actionsLeft .= '<a href="'.$url.'">'.
617 617
             Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), array(), ICON_SIZE_MEDIUM).'</a>';
618
-		$actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), array(), 32).'</a>';
619
-	} else {
620
-		$actionsLeft .= '<a href="'.$url.'">'.
618
+        $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), array(), 32).'</a>';
619
+    } else {
620
+        $actionsLeft .= '<a href="'.$url.'">'.
621 621
             Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
622 622
         $actionsLeft .= '<a id="hide_bar_template" href="#">'.Display::return_icon('expand.png',get_lang('Expand'),array('id'=>'expand'),ICON_SIZE_MEDIUM).Display::return_icon('contract.png',get_lang('Collapse'),array('id'=>'contract', 'class'=>'hide'),ICON_SIZE_MEDIUM).'</a>';
623
-	}
623
+    }
624 624
     
625 625
     echo $toolbar = Display::toolbarAction('actions-documents', array(0 => $actionsLeft, 1 => ''));
626 626
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 }
122 122
 
123 123
 $editorConfig = array(
124
-    'ToolbarSet' => (api_is_allowed_to_edit(null, true) ? 'Documents' :'DocumentsStudent'),
124
+    'ToolbarSet' => (api_is_allowed_to_edit(null, true) ? 'Documents' : 'DocumentsStudent'),
125 125
     'Width' => '100%',
126 126
     'Height' => '400',
127 127
     'cols-size' => [2, 10, 0],
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
         "name" => get_lang('Documents'),
165 165
     );
166 166
 } else {
167
-    $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
167
+    $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
168 168
 }
169 169
 
170 170
 if (empty($document_data['parents'])) {
171 171
     $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
172 172
 } else {
173
-    foreach($document_data['parents'] as $document_sub_data) {
173
+    foreach ($document_data['parents'] as $document_sub_data) {
174 174
         if ($document_data['title'] == $document_sub_data['title']) {
175 175
             continue;
176 176
         }
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 								$dir,
355 355
 								api_get_user_id()
356 356
 							);
357
-							header('Location: document.php?id=' . $document_data['parent_id'] . '&' . api_get_cidreq() . ($is_certificate_mode?'&curdirpath=/certificates&selectcat=1':''));
357
+							header('Location: document.php?id='.$document_data['parent_id'].'&'.api_get_cidreq().($is_certificate_mode ? '&curdirpath=/certificates&selectcat=1' : ''));
358 358
 							exit;
359 359
 						} else {
360 360
                             Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning'));
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 /*	Display user interface */
398 398
 
399 399
 // Display the header
400
-$nameTools = get_lang('EditDocument') . ': '.Security::remove_XSS($document_data['title']);
400
+$nameTools = get_lang('EditDocument').': '.Security::remove_XSS($document_data['title']);
401 401
 Display::display_header($nameTools, 'Doc');
402 402
 
403 403
 $document_info = api_get_item_property_info(
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	$form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
480 480
 
481 481
 	if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
482
-		$checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
482
+		$checked = & $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
483 483
 		if ($readonly == 1) {
484 484
 			$checked->setChecked(true);
485 485
 		}
@@ -519,14 +519,14 @@  discard block
 block discarded – undo
519 519
 		foreach ($all_information_by_create_certificate[0] as $info_value) {
520 520
 			$str_info .= $info_value.'<br/>';
521 521
 		}
522
-		$create_certificate=get_lang('CreateCertificateWithTags');
522
+		$create_certificate = get_lang('CreateCertificateWithTags');
523 523
 		Display::display_normal_message(
524 524
 			$create_certificate.': <br /><br />'.$str_info,
525 525
 			false
526 526
 		);
527 527
 	}
528 528
 
529
-	if ($extension=='svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true'){
529
+	if ($extension == 'svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
530 530
 		Display::display_warning_message(get_lang('BrowserDontSupportsSVG'));
531 531
 	}
532 532
     // HTML-editor
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 }
579 579
 
580 580
 //return button back to
581
-function show_return($document_id, $path, $call_from_tool='', $slide_id=0, $is_certificate_mode=false)
581
+function show_return($document_id, $path, $call_from_tool = '', $slide_id = 0, $is_certificate_mode = false)
582 582
 {
583 583
     $actionsLeft = null;
584 584
     
@@ -587,29 +587,29 @@  discard block
 block discarded – undo
587 587
 
588 588
 	if ($is_certificate_mode) {
589 589
 		$selectedCategory = (isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : '');
590
-		$actionsLeft .= '<a href="document.php?curdirpath='. $selectedCategory .'&selectcat=' . $selectedCategory .'">'.
591
-            Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>';
592
-        $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png',get_lang('Expand'),array('id'=>'expand'),ICON_SIZE_MEDIUM).Display::return_icon('contract.png',get_lang('Collapse'),array('id'=>'contract', 'class'=>'hide'),ICON_SIZE_MEDIUM).'</a>';
593
-	} elseif($call_from_tool=='slideshow') {
590
+		$actionsLeft .= '<a href="document.php?curdirpath='.$selectedCategory.'&selectcat='.$selectedCategory.'">'.
591
+            Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM).'</a>';
592
+        $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png', get_lang('Expand'), array('id'=>'expand'), ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), array('id'=>'contract', 'class'=>'hide'), ICON_SIZE_MEDIUM).'</a>';
593
+	} elseif ($call_from_tool == 'slideshow') {
594 594
 		$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'.
595
-            Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('ViewSlideshow'),'',ICON_SIZE_MEDIUM).'</a>';
596
-	} elseif($call_from_tool=='editdraw') {
595
+            Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('ViewSlideshow'), '', ICON_SIZE_MEDIUM).'</a>';
596
+	} elseif ($call_from_tool == 'editdraw') {
597 597
 		$actionsLeft .= '<a href="'.$url.'">'.
598
-            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
598
+            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
599 599
 		$actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), array(), 32).'</a>';
600
-	} elseif($call_from_tool=='editodf') {
600
+	} elseif ($call_from_tool == 'editodf') {
601 601
         $actionsLeft .= '<a href="'.$url.'">'.
602
-            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
602
+            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
603 603
         $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Write'), array(), 32).'</a>';
604
-        $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png',get_lang('Expand'),array('id'=>'expand'),ICON_SIZE_MEDIUM).Display::return_icon('contract.png',get_lang('Collapse'),array('id'=>'contract', 'class'=>'hide'),ICON_SIZE_MEDIUM).'</a>';
605
-    } elseif($call_from_tool=='editpaint'){
604
+        $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png', get_lang('Expand'), array('id'=>'expand'), ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), array('id'=>'contract', 'class'=>'hide'), ICON_SIZE_MEDIUM).'</a>';
605
+    } elseif ($call_from_tool == 'editpaint') {
606 606
 		$actionsLeft .= '<a href="'.$url.'">'.
607 607
             Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), array(), ICON_SIZE_MEDIUM).'</a>';
608 608
 		$actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), array(), 32).'</a>';
609 609
 	} else {
610 610
 		$actionsLeft .= '<a href="'.$url.'">'.
611
-            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
612
-        $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png',get_lang('Expand'),array('id'=>'expand'),ICON_SIZE_MEDIUM).Display::return_icon('contract.png',get_lang('Collapse'),array('id'=>'contract', 'class'=>'hide'),ICON_SIZE_MEDIUM).'</a>';
611
+            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
612
+        $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png', get_lang('Expand'), array('id'=>'expand'), ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), array('id'=>'contract', 'class'=>'hide'), ICON_SIZE_MEDIUM).'</a>';
613 613
 	}
614 614
 
615 615
     echo $toolbar = Display::toolbarAction('actions-documents', array($actionsLeft));
Please login to merge, or discard this patch.
main/admin/careers.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 
84 84
 //With this function we can add actions to the jgrid (edit, delete, etc)
85 85
 $action_links = 'function action_formatter(cellvalue, options, rowObject) {
86
-    return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
87
-    '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;"  href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png',get_lang('Copy'),'',ICON_SIZE_SMALL).'</a>'.
88
-    '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;"  href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
86
+    return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'.
87
+    '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;"  href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png', get_lang('Copy'), '', ICON_SIZE_SMALL).'</a>'.
88
+    '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;"  href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'.
89 89
     '\';
90 90
 }';
91 91
 ?>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         break;
134 134
     case 'edit':
135 135
         // Action handling: Editing
136
-        $url  = api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&id=' . intval($_GET['id']);
136
+        $url  = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
137 137
         $form = $career->return_form($url, 'edit');
138 138
 
139 139
         // The validation or display
Please login to merge, or discard this patch.
main/exercise/export/scorm/scorm_classes.php 2 patches
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 		$question->type = $qst->type;
44 44
 		$question->question = $qst->question;
45 45
 		$question->description = $qst->description;
46
-		$question->weighting=$qst->weighting;
47
-		$question->position=$qst->position;
48
-		$question->picture=$qst->picture;
46
+		$question->weighting = $qst->weighting;
47
+		$question->position = $qst->position;
48
+		$question->picture = $qst->picture;
49 49
 		$assessmentItem = new ScormAssessmentItem($question, $standalone);
50 50
 
51 51
 		return $assessmentItem->export();
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 					<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />
228 228
 					</td>
229 229
 					<td width="95%">
230
-					<label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label>
230
+					<label for="'.$identifier.'">'.Security::remove_XSS($this->answer[$i]).'</label>
231 231
 					</td>
232 232
 					</tr>';
233 233
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
                 $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';';
240 240
 				$id++;
241 241
 			}
242
-			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
242
+			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n";
243 243
             $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n";
244 244
 			$js .= $jstmpw;
245 245
 		} elseif ($type == MULTIPLE_ANSWER_COMBINATION) {
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 					<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />
256 256
 					</td>
257 257
 					<td width="95%">
258
-					<label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label>
258
+					<label for="'.$identifier.'">'.Security::remove_XSS($this->answer[$i]).'</label>
259 259
 					</td>
260 260
 					</tr>';
261 261
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                 $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].";";
268 268
                 $id++;
269 269
             }
270
-            $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
270
+            $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');';
271 271
             $js .= 'questions_types['.$this->questionJSId.'] = "exact";';
272 272
             $js .= $jstmpw;
273 273
 		} else {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 					<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="checkbox"/>
284 284
 					</td>
285 285
 					<td width="95%">
286
-					<label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label>
286
+					<label for="'.$identifier.'">'.Security::remove_XSS($this->answer[$i]).'</label>
287 287
 					</td>
288 288
 					</tr>';
289 289
 				$jstmp .= $i.',';
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
                 $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';';
295 295
 				$id++;
296 296
 			}
297
-			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
297
+			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');';
298 298
 			$js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';';
299 299
 			$js .= $jstmpw;
300 300
 		}
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 				<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" />
330 330
 				</td>
331 331
 				<td width="95%">
332
-				<label for="'.$identifier_true.'">' . get_lang('True') . '</label>
332
+				<label for="'.$identifier_true.'">'.get_lang('True').'</label>
333 333
 				</td>
334 334
 				</tr>';
335 335
 		$html .=
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 			<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" />
339 339
 			</td>
340 340
 			<td width="95%">
341
-			<label for="'.$identifier_false.'">' . get_lang('False') . '</label>
341
+			<label for="'.$identifier_false.'">'.get_lang('False').'</label>
342 342
 			</td>
343 343
 			</tr></table></td></tr>';
344 344
 		$js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n";
@@ -383,30 +383,30 @@  discard block
 block discarded – undo
383 383
 		}
384 384
 
385 385
 		// splits text and weightings that are joined with the character '::'
386
-		list($answer,$weight)=explode('::',$answer);
387
-		$weights = explode(',',$weight);
386
+		list($answer, $weight) = explode('::', $answer);
387
+		$weights = explode(',', $weight);
388 388
 		// because [] is parsed here we follow this procedure:
389 389
 		// 1. find everything between the [ and ] tags
390
-		$i=1;
390
+		$i = 1;
391 391
 		$jstmp = '';
392 392
 		$jstmpc = '';
393 393
 		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
394 394
 		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
395
-		$startlocations=api_strpos($answer,'[');
396
-		$endlocations=api_strpos($answer,']');
395
+		$startlocations = api_strpos($answer, '[');
396
+		$endlocations = api_strpos($answer, ']');
397 397
 		while ($startlocations !== false && $endlocations !== false) {
398
-			$texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1);
398
+			$texstring = api_substr($answer, $startlocations, ($endlocations - $startlocations) + 1);
399 399
 			$answer = api_substr_replace(
400 400
                 $answer,
401 401
                 '<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',
402 402
                 $startlocations,
403
-                ($endlocations-$startlocations)+1
403
+                ($endlocations - $startlocations) + 1
404 404
             );
405 405
             $jstmp .= $i.',';
406 406
 			if (!empty($texstring)) {
407 407
 				$sub = api_substr($texstring, 1, -1);
408 408
 				if (!empty($sub)) {
409
-					$jstmpc .= "'" . api_htmlentities($sub, ENT_QUOTES, $charset) . "',";
409
+					$jstmpc .= "'".api_htmlentities($sub, ENT_QUOTES, $charset)."',";
410 410
 				}
411 411
 			}
412 412
             $my_weight = explode('@', $weights[$i - 1]);
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
 			'.$answer.'
427 427
 			</td>
428 428
 			</tr></table></td></tr>';
429
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n";
430
-		$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n";
429
+		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp, 0, -1).');'."\n";
430
+		$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc, 0, -1).');'."\n";
431 431
 		$js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
432 432
 		$js .= $jstmpw;
433 433
 
434
-		return array($js,$html);
434
+		return array($js, $html);
435 435
 	}
436 436
 }
437 437
 
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
 		// get max length of displayed array
458 458
 
459 459
 		$nbrAnswers = $this->selectNbrAnswers();
460
-		$cpt1='A';
461
-		$cpt2=1;
460
+		$cpt1 = 'A';
461
+		$cpt2 = 1;
462 462
 		$Select = array();
463 463
 		$qId = $this->questionJSId;
464 464
 		$s = '';
@@ -467,37 +467,37 @@  discard block
 block discarded – undo
467 467
 		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
468 468
 		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
469 469
 
470
-		for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
470
+		for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
471 471
 			$identifier = 'question_'.$qId.'_matching_';
472
-			$answer=$this->selectAnswer($answerId);
473
-			$answerCorrect=$this->isCorrect($answerId);
474
-			$weight=$this->selectWeighting($answerId);
472
+			$answer = $this->selectAnswer($answerId);
473
+			$answerCorrect = $this->isCorrect($answerId);
474
+			$weight = $this->selectWeighting($answerId);
475 475
 			$jstmp .= $answerId.',';
476 476
 
477 477
 			if (!$answerCorrect) {
478 478
 				// options (A, B, C, ...) that will be put into the list-box
479
-				$Select[$answerId]['Lettre']=$cpt1;
479
+				$Select[$answerId]['Lettre'] = $cpt1;
480 480
 				// answers that will be shown at the right side
481 481
 				$Select[$answerId]['Reponse'] = $answer;
482 482
 				$cpt1++;
483 483
 			} else {
484
-				$s.='<tr>';
485
-				$s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>.&nbsp;'.$answer."</td>";
486
-				$s.='<td width="20%" align="center">&nbsp;&nbsp;<select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">';
487
-				$s.=' <option value="0">--</option>';
484
+				$s .= '<tr>';
485
+				$s .= '<td width="40%" valign="top"><b>'.$cpt2.'</b>.&nbsp;'.$answer."</td>";
486
+				$s .= '<td width="20%" align="center">&nbsp;&nbsp;<select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">';
487
+				$s .= ' <option value="0">--</option>';
488 488
 				// fills the list-box
489 489
                 foreach ($Select as $key => $val) {
490 490
                     $s .= '<option value="'.$key.'">'.$val['Lettre'].'</option>';
491 491
                 }  // end foreach()
492 492
 
493
-				$s.='</select>&nbsp;&nbsp;</td>';
494
-				$s.='<td width="40%" valign="top">';
493
+				$s .= '</select>&nbsp;&nbsp;</td>';
494
+				$s .= '<td width="40%" valign="top">';
495 495
                 if (isset($Select[$cpt2])) {
496 496
                     $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
497 497
                 } else {
498 498
                     $s .= '&nbsp;';
499 499
                 }
500
-				$s.="</td></tr>";
500
+				$s .= "</td></tr>";
501 501
 
502 502
 				$jstmpc .= '['.$answerCorrect.','.$cpt2.'],';
503 503
 
@@ -514,22 +514,22 @@  discard block
 block discarded – undo
514 514
 				if ($answerId == $nbrAnswers) {
515 515
 					// if there remain answers to be shown on the right side
516 516
 					while (isset($Select[$cpt2])) {
517
-						$s.= '<tr>';
518
-						$s.= '<td width="60%" colspan="2">&nbsp;</td>';
519
-						$s.= '<td width="40%" valign="top">';
520
-						$s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
521
-						$s.= "</td></tr>";
517
+						$s .= '<tr>';
518
+						$s .= '<td width="60%" colspan="2">&nbsp;</td>';
519
+						$s .= '<td width="40%" valign="top">';
520
+						$s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
521
+						$s .= "</td></tr>";
522 522
 						$cpt2++;
523 523
 					}	// end while()
524 524
 				}  // end if()
525 525
 			}
526 526
 		}
527
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
528
-		$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
527
+		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n";
528
+		$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc, 0, -1).');'."\n";
529 529
 		$js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n";
530 530
 		$js .= $jstmpw;
531 531
 		$html .= $s;
532
-		$html .= '</table></td></tr>' . "\n";
532
+		$html .= '</table></td></tr>'."\n";
533 533
 
534 534
 		return array($js, $html);
535 535
 	}
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 		$html .= '';
635 635
 
636 636
 		// Get the answers, make a list
637
-		$nbrAnswers=$this->selectNbrAnswers();
637
+		$nbrAnswers = $this->selectNbrAnswers();
638 638
 
639 639
 		$answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>';
640 640
         for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	{
699 699
 		$this->question = $question;
700 700
 		$this->question->setAnswer();
701
-		$this->questionIdent = "QST_" . $question->id ;
701
+		$this->questionIdent = "QST_".$question->id;
702 702
 		$this->standalone = $standalone;
703 703
 	}
704 704
 
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		$js .= 'var questions_answers = new Array();';
799 799
 		$js .= 'var questions_answers_correct = new Array();';
800 800
 		$js .= 'var questions_types = new Array();';
801
-		$js .= "\n" .
801
+		$js .= "\n".
802 802
 			'/**
803 803
              * Assigns any event handler to any element
804 804
              * @param	object	Element on which the event is added
@@ -1018,11 +1018,11 @@  discard block
 block discarded – undo
1018 1018
 	{
1019 1019
 		$js = file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
1020 1020
 
1021
-		$js .= 'var questions = new Array();' . "\n";
1022
-		$js .= 'var questions_answers = new Array();' . "\n";
1023
-		$js .= 'var questions_answers_correct = new Array();' . "\n";
1024
-		$js .= 'var questions_types = new Array();' . "\n";
1025
-		$js .= "\n" .
1021
+		$js .= 'var questions = new Array();'."\n";
1022
+		$js .= 'var questions_answers = new Array();'."\n";
1023
+		$js .= 'var questions_answers_correct = new Array();'."\n";
1024
+		$js .= 'var questions_types = new Array();'."\n";
1025
+		$js .= "\n".
1026 1026
 			'/**
1027 1027
              * Assigns any event handler to any element
1028 1028
              * @param	object	Element on which the event is added
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 
1068 1068
 		$js .= '';
1069 1069
 		$js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
1070
-		return $js. "\n";
1070
+		return $js."\n";
1071 1071
 	}
1072 1072
 
1073 1073
 	/**
@@ -1114,8 +1114,8 @@  discard block
 block discarded – undo
1114 1114
 
1115 1115
 		$head = '';
1116 1116
 		if ($this->standalone) {
1117
-			$head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n"
1118
-				. '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n";
1117
+			$head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>'."\n"
1118
+				. '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n";
1119 1119
 		}
1120 1120
 
1121 1121
 		list($js, $html) = $this->export_questions();
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		$js = $html = "";
1158 1158
 		$js_id = 0;
1159 1159
 		foreach ($this->exercise->selectQuestionList() as $q) {
1160
-			list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id);
1160
+			list($jstmp, $htmltmp) = ScormQuestion::export_question($q, false, $js_id);
1161 1161
 			$js .= $jstmp."\n";
1162 1162
 			$html .= $htmltmp."\n";
1163 1163
 			++$js_id;
Please login to merge, or discard this patch.
Indentation   +773 added lines, -773 removed lines patch added patch discarded remove patch
@@ -20,140 +20,140 @@  discard block
 block discarded – undo
20 20
 {
21 21
     public $js_id;
22 22
     public $answer;
23
-	/**
24
-	 * Returns the HTML + JS flow corresponding to one question
25
-	 *
26
-	 * @param int $questionId The question ID
27
-	 * @param bool $standalone (ie including XML tag, DTD declaration, etc)
28
-	 * @param int  $js_id The JavaScript ID for this question.
29
-	 * Due to the nature of interactions, we must have a natural sequence for
30
-	 * questions in the generated JavaScript.
31
-	 * @param integer $js_id
23
+    /**
24
+     * Returns the HTML + JS flow corresponding to one question
25
+     *
26
+     * @param int $questionId The question ID
27
+     * @param bool $standalone (ie including XML tag, DTD declaration, etc)
28
+     * @param int  $js_id The JavaScript ID for this question.
29
+     * Due to the nature of interactions, we must have a natural sequence for
30
+     * questions in the generated JavaScript.
31
+     * @param integer $js_id
32 32
      * @return string|array
33
-	 */
34
-	public static function export_question($questionId, $standalone = true, $js_id)
35
-	{
36
-		$question = new ScormQuestion();
37
-		$qst = $question->read($questionId);
38
-		if (!$qst) {
39
-			return '';
40
-		}
41
-		$question->id = $qst->id;
42
-		$question->js_id = $js_id;
43
-		$question->type = $qst->type;
44
-		$question->question = $qst->question;
45
-		$question->description = $qst->description;
46
-		$question->weighting=$qst->weighting;
47
-		$question->position=$qst->position;
48
-		$question->picture=$qst->picture;
49
-		$assessmentItem = new ScormAssessmentItem($question, $standalone);
50
-
51
-		return $assessmentItem->export();
52
-	}
53
-
54
-	/**
55
-	 * Include the correct answer class and create answer
56
-	 */
57
-	public function setAnswer()
58
-	{
59
-		switch ($this->type) {
60
-			case MCUA:
61
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
62
-				$this->answer->questionJSId = $this->js_id;
63
-				break;
64
-			case MCMA:
65
-			case GLOBAL_MULTIPLE_ANSWER:
66
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
67
-				$this->answer->questionJSId = $this->js_id;
68
-				break;
69
-			case TF:
70
-				$this->answer = new ScormAnswerTrueFalse($this->id);
71
-				$this->answer->questionJSId = $this->js_id;
72
-				break;
73
-			case FIB:
74
-				$this->answer = new ScormAnswerFillInBlanks($this->id);
75
-				$this->answer->questionJSId = $this->js_id;
76
-				break;
77
-			case MATCHING:
78
-			case MATCHING_DRAGGABLE:
79
-			case DRAGGABLE:
80
-				$this->answer = new ScormAnswerMatching($this->id);
81
-				$this->answer->questionJSId = $this->js_id;
82
-				break;
83
-			case ORAL_EXPRESSION:
84
-			case FREE_ANSWER:
85
-				$this->answer = new ScormAnswerFree($this->id);
86
-				$this->answer->questionJSId = $this->js_id;
87
-				break;
88
-			case HOT_SPOT:
89
-				$this->answer = new ScormAnswerHotspot($this->id);
90
-				$this->answer->questionJSId = $this->js_id;
91
-				break;
92
-			case MULTIPLE_ANSWER_COMBINATION:
93
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
94
-				$this->answer->questionJSId = $this->js_id;
95
-				break;
96
-			case HOT_SPOT_ORDER:
97
-				$this->answer = new ScormAnswerHotspot($this->id);
98
-				$this->answer->questionJSId = $this->js_id;
99
-				break;
100
-			case HOT_SPOT_DELINEATION:
101
-				$this->answer = new ScormAnswerHotspot($this->id);
102
-				$this->answer->questionJSId = $this->js_id;
103
-				break;
104
-			// not supported
105
-			case UNIQUE_ANSWER_NO_OPTION:
106
-			case MULTIPLE_ANSWER_TRUE_FALSE:
107
-			case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
108
-			case UNIQUE_ANSWER_IMAGE:
109
-			case CALCULATED_ANSWER:
110
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
111
-				$this->answer->questionJSId = $this->js_id;
112
-				break;
113
-			default:
114
-				$this->answer = new stdClass();
115
-				$this->answer->questionJSId = $this->js_id;
116
-				break;
117
-		}
118
-
119
-		return true;
120
-	}
121
-
122
-	function export()
123
-	{
124
-		$html = $this->getQuestionHTML();
125
-		$js = $this->getQuestionJS();
126
-
127
-		if (is_object($this->answer) && $this->answer instanceof Answer) {
128
-			list($js2, $html2) = $this->answer->export();
129
-			$js .= $js2;
130
-			$html .= $html2;
131
-		} else {
132
-			throw new \Exception('Question not supported. Exercise: '.$this->selectTitle());
133
-		}
134
-
135
-		return array($js, $html);
136
-	}
137
-
138
-	function createAnswersForm($form)
139
-	{
140
-		return true;
141
-	}
142
-
143
-	function processAnswersCreation($form)
144
-	{
145
-		return true;
146
-	}
147
-
148
-	/**
149
-	 * Returns an HTML-formatted question
150
-	 */
151
-	function getQuestionHTML()
152
-	{
33
+     */
34
+    public static function export_question($questionId, $standalone = true, $js_id)
35
+    {
36
+        $question = new ScormQuestion();
37
+        $qst = $question->read($questionId);
38
+        if (!$qst) {
39
+            return '';
40
+        }
41
+        $question->id = $qst->id;
42
+        $question->js_id = $js_id;
43
+        $question->type = $qst->type;
44
+        $question->question = $qst->question;
45
+        $question->description = $qst->description;
46
+        $question->weighting=$qst->weighting;
47
+        $question->position=$qst->position;
48
+        $question->picture=$qst->picture;
49
+        $assessmentItem = new ScormAssessmentItem($question, $standalone);
50
+
51
+        return $assessmentItem->export();
52
+    }
53
+
54
+    /**
55
+     * Include the correct answer class and create answer
56
+     */
57
+    public function setAnswer()
58
+    {
59
+        switch ($this->type) {
60
+            case MCUA:
61
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
62
+                $this->answer->questionJSId = $this->js_id;
63
+                break;
64
+            case MCMA:
65
+            case GLOBAL_MULTIPLE_ANSWER:
66
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
67
+                $this->answer->questionJSId = $this->js_id;
68
+                break;
69
+            case TF:
70
+                $this->answer = new ScormAnswerTrueFalse($this->id);
71
+                $this->answer->questionJSId = $this->js_id;
72
+                break;
73
+            case FIB:
74
+                $this->answer = new ScormAnswerFillInBlanks($this->id);
75
+                $this->answer->questionJSId = $this->js_id;
76
+                break;
77
+            case MATCHING:
78
+            case MATCHING_DRAGGABLE:
79
+            case DRAGGABLE:
80
+                $this->answer = new ScormAnswerMatching($this->id);
81
+                $this->answer->questionJSId = $this->js_id;
82
+                break;
83
+            case ORAL_EXPRESSION:
84
+            case FREE_ANSWER:
85
+                $this->answer = new ScormAnswerFree($this->id);
86
+                $this->answer->questionJSId = $this->js_id;
87
+                break;
88
+            case HOT_SPOT:
89
+                $this->answer = new ScormAnswerHotspot($this->id);
90
+                $this->answer->questionJSId = $this->js_id;
91
+                break;
92
+            case MULTIPLE_ANSWER_COMBINATION:
93
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
94
+                $this->answer->questionJSId = $this->js_id;
95
+                break;
96
+            case HOT_SPOT_ORDER:
97
+                $this->answer = new ScormAnswerHotspot($this->id);
98
+                $this->answer->questionJSId = $this->js_id;
99
+                break;
100
+            case HOT_SPOT_DELINEATION:
101
+                $this->answer = new ScormAnswerHotspot($this->id);
102
+                $this->answer->questionJSId = $this->js_id;
103
+                break;
104
+            // not supported
105
+            case UNIQUE_ANSWER_NO_OPTION:
106
+            case MULTIPLE_ANSWER_TRUE_FALSE:
107
+            case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
108
+            case UNIQUE_ANSWER_IMAGE:
109
+            case CALCULATED_ANSWER:
110
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
111
+                $this->answer->questionJSId = $this->js_id;
112
+                break;
113
+            default:
114
+                $this->answer = new stdClass();
115
+                $this->answer->questionJSId = $this->js_id;
116
+                break;
117
+        }
118
+
119
+        return true;
120
+    }
121
+
122
+    function export()
123
+    {
124
+        $html = $this->getQuestionHTML();
125
+        $js = $this->getQuestionJS();
126
+
127
+        if (is_object($this->answer) && $this->answer instanceof Answer) {
128
+            list($js2, $html2) = $this->answer->export();
129
+            $js .= $js2;
130
+            $html .= $html2;
131
+        } else {
132
+            throw new \Exception('Question not supported. Exercise: '.$this->selectTitle());
133
+        }
134
+
135
+        return array($js, $html);
136
+    }
137
+
138
+    function createAnswersForm($form)
139
+    {
140
+        return true;
141
+    }
142
+
143
+    function processAnswersCreation($form)
144
+    {
145
+        return true;
146
+    }
147
+
148
+    /**
149
+     * Returns an HTML-formatted question
150
+     */
151
+    function getQuestionHTML()
152
+    {
153 153
         $title = $this->selectTitle();
154 154
         $description = $this->selectDescription();
155
-		$cols = 2;
156
-		$s = '<tr>
155
+        $cols = 2;
156
+        $s = '<tr>
157 157
 			<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">
158 158
 			'.$title.'
159 159
 			</td>
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 			<i>'.$description.'</i>
164 164
 			</td>
165 165
 			</tr>';
166
-		return $s;
167
-	}
166
+        return $s;
167
+    }
168 168
 
169
-	/**
170
-	 * Return the JavaScript code bound to the question
171
-	 */
172
-	public function getQuestionJS()
173
-	{
174
-		$weight = $this->selectWeighting();
175
-		$js = 'questions.push('.$this->js_id.');'."\n";
169
+    /**
170
+     * Return the JavaScript code bound to the question
171
+     */
172
+    public function getQuestionJS()
173
+    {
174
+        $weight = $this->selectWeighting();
175
+        $js = 'questions.push('.$this->js_id.');'."\n";
176 176
 
177 177
         switch ($this->type) {
178 178
             case ORAL_EXPRESSION:
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                 $script .= file_get_contents(api_get_path(LIBRARY_PATH) . 'wami-recorder/gui.js');
182 182
                 $js .= $script;*/
183 183
                 break;
184
-           case HOT_SPOT:
184
+            case HOT_SPOT:
185 185
                 //put the max score to 0 to avoid discounting the points of
186 186
                 //non-exported quiz types in the SCORM
187 187
                 $weight = 0;
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
         }
190 190
         $js .= 'questions_score_max['.$this->js_id.'] = '.$weight.";";
191 191
 
192
-		return $js;
193
-	}
192
+        return $js;
193
+    }
194 194
 }
195 195
 
196 196
 /**
@@ -200,29 +200,29 @@  discard block
 block discarded – undo
200 200
  */
201 201
 class ScormAnswerMultipleChoice extends Answer
202 202
 {
203
-	/**
204
-	 * Return HTML code for possible answers
205
-	 */
206
-	function export()
207
-	{
208
-		$js = '';
209
-		$html = '<tr><td colspan="2"><table width="100%">';
210
-		$type = $this->getQuestionType();
211
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();';
212
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;';
203
+    /**
204
+     * Return HTML code for possible answers
205
+     */
206
+    function export()
207
+    {
208
+        $js = '';
209
+        $html = '<tr><td colspan="2"><table width="100%">';
210
+        $type = $this->getQuestionType();
211
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();';
212
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;';
213 213
 
214 214
         $jstmpw .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();';
215 215
 
216
-		//not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM
217
-		//if ($type == MCMA  || $type == MULTIPLE_ANSWER_COMBINATION ) {
218
-		if ($type == MCMA) {
216
+        //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM
217
+        //if ($type == MCMA  || $type == MULTIPLE_ANSWER_COMBINATION ) {
218
+        if ($type == MCMA) {
219 219
             $id = 1;
220
-			$jstmp = '';
221
-			$jstmpc = '';
220
+            $jstmp = '';
221
+            $jstmpc = '';
222 222
             foreach ($this->answer as $i => $answer) {
223
-				$identifier = 'question_'.$this->questionJSId.'_multiple_'.$i;
224
-				$html .=
225
-					'<tr>
223
+                $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i;
224
+                $html .=
225
+                    '<tr>
226 226
 					<td align="center" width="5%">
227 227
 					<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />
228 228
 					</td>
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
 					</td>
232 232
 					</tr>';
233 233
 
234
-				$jstmp .= $i.',';
234
+                $jstmp .= $i.',';
235 235
                 if ($this->correct[$i]) {
236 236
                     $jstmpc .= $i.',';
237 237
                 }
238
-				$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
238
+                $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
239 239
                 $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';';
240
-				$id++;
241
-			}
242
-			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
240
+                $id++;
241
+            }
242
+            $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
243 243
             $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n";
244
-			$js .= $jstmpw;
245
-		} elseif ($type == MULTIPLE_ANSWER_COMBINATION) {
246
-	    	$js = '';
244
+            $js .= $jstmpw;
245
+        } elseif ($type == MULTIPLE_ANSWER_COMBINATION) {
246
+            $js = '';
247 247
             $id = 1;
248 248
             $jstmp = '';
249 249
             $jstmpc = '';
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
             $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
271 271
             $js .= 'questions_types['.$this->questionJSId.'] = "exact";';
272 272
             $js .= $jstmpw;
273
-		} else {
274
-			$id = 1;
275
-			$jstmp = '';
276
-			$jstmpc = '';
273
+        } else {
274
+            $id = 1;
275
+            $jstmp = '';
276
+            $jstmpc = '';
277 277
             foreach ($this->answer as $i => $answer) {
278 278
                 $identifier = 'question_'.$this->questionJSId.'_unique_'.$i;
279
-				$identifier_name = 'question_'.$this->questionJSId.'_unique_answer';
280
-				$html .=
281
-					'<tr>
279
+                $identifier_name = 'question_'.$this->questionJSId.'_unique_answer';
280
+                $html .=
281
+                    '<tr>
282 282
 					<td align="center" width="5%">
283 283
 					<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="checkbox"/>
284 284
 					</td>
@@ -286,22 +286,22 @@  discard block
 block discarded – undo
286 286
 					<label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label>
287 287
 					</td>
288 288
 					</tr>';
289
-				$jstmp .= $i.',';
289
+                $jstmp .= $i.',';
290 290
                 if ($this->correct[$i]) {
291 291
                     $jstmpc .= $i;
292 292
                 }
293
-				$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
293
+                $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
294 294
                 $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';';
295
-				$id++;
296
-			}
297
-			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
298
-			$js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';';
299
-			$js .= $jstmpw;
300
-		}
301
-		$html .= '</table></td></tr>';
302
-
303
-		return array($js, $html);
304
-	}
295
+                $id++;
296
+            }
297
+            $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
298
+            $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';';
299
+            $js .= $jstmpw;
300
+        }
301
+        $html .= '</table></td></tr>';
302
+
303
+        return array($js, $html);
304
+    }
305 305
 }
306 306
 
307 307
 /**
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
  */
311 311
 class ScormAnswerTrueFalse extends Answer
312 312
 {
313
-	/**
314
-	 * Return the XML flow for the possible answers.
315
-	 * That's one <response_lid>, containing several <flow_label>
316
-	 *
317
-	 * @author Amand Tihon <[email protected]>
318
-	 */
319
-	function export()
320
-	{
321
-		$js = '';
322
-		$html = '<tr><td colspan="2"><table width="100%">';
323
-		$identifier = 'question_'.$this->questionJSId.'_tf';
324
-		$identifier_true  = $identifier.'_true';
325
-		$identifier_false = $identifier.'_false';
326
-		$html .=
327
-			'<tr>
313
+    /**
314
+     * Return the XML flow for the possible answers.
315
+     * That's one <response_lid>, containing several <flow_label>
316
+     *
317
+     * @author Amand Tihon <[email protected]>
318
+     */
319
+    function export()
320
+    {
321
+        $js = '';
322
+        $html = '<tr><td colspan="2"><table width="100%">';
323
+        $identifier = 'question_'.$this->questionJSId.'_tf';
324
+        $identifier_true  = $identifier.'_true';
325
+        $identifier_false = $identifier.'_false';
326
+        $html .=
327
+            '<tr>
328 328
 				<td align="center" width="5%">
329 329
 				<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" />
330 330
 				</td>
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
 				<label for="'.$identifier_true.'">' . get_lang('True') . '</label>
333 333
 				</td>
334 334
 				</tr>';
335
-		$html .=
336
-			'<tr>
335
+        $html .=
336
+            '<tr>
337 337
 			<td align="center" width="5%">
338 338
 			<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" />
339 339
 			</td>
@@ -341,20 +341,20 @@  discard block
 block discarded – undo
341 341
 			<label for="'.$identifier_false.'">' . get_lang('False') . '</label>
342 342
 			</td>
343 343
 			</tr></table></td></tr>';
344
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n";
345
-		$js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n";
346
-		if ($this->response === 'TRUE') {
347
-			$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n";
348
-		} else {
349
-			$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n";
350
-		}
351
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
352
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
353
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n";
354
-		$js .= $jstmpw;
355
-
356
-		return array($js, $html);
357
-	}
344
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n";
345
+        $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n";
346
+        if ($this->response === 'TRUE') {
347
+            $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n";
348
+        } else {
349
+            $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n";
350
+        }
351
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
352
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
353
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n";
354
+        $js .= $jstmpw;
355
+
356
+        return array($js, $html);
357
+    }
358 358
 }
359 359
 
360 360
 /**
@@ -363,76 +363,76 @@  discard block
 block discarded – undo
363 363
  */
364 364
 class ScormAnswerFillInBlanks extends Answer
365 365
 {
366
-	/**
367
-	 * Export the text with missing words.
368
-	 *
369
-	 * As a side effect, it stores two lists in the class :
370
-	 * the missing words and their respective weightings.
371
-	 */
372
-	function export()
373
-	{
374
-		global $charset;
375
-		$js = '';
376
-		$html = '<tr><td colspan="2"><table width="100%">';
377
-		// get all enclosed answers
378
-		$blankList = array();
379
-		// build replacement
380
-		$replacementList = array();
381
-		foreach ($this->answer as $i => $answer) {
382
-			$blankList[] = '['.$answer.']';
383
-		}
384
-
385
-		// splits text and weightings that are joined with the character '::'
386
-		list($answer,$weight)=explode('::',$answer);
387
-		$weights = explode(',',$weight);
388
-		// because [] is parsed here we follow this procedure:
389
-		// 1. find everything between the [ and ] tags
390
-		$i=1;
391
-		$jstmp = '';
392
-		$jstmpc = '';
393
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
394
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
395
-		$startlocations=api_strpos($answer,'[');
396
-		$endlocations=api_strpos($answer,']');
397
-		while ($startlocations !== false && $endlocations !== false) {
398
-			$texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1);
399
-			$answer = api_substr_replace(
366
+    /**
367
+     * Export the text with missing words.
368
+     *
369
+     * As a side effect, it stores two lists in the class :
370
+     * the missing words and their respective weightings.
371
+     */
372
+    function export()
373
+    {
374
+        global $charset;
375
+        $js = '';
376
+        $html = '<tr><td colspan="2"><table width="100%">';
377
+        // get all enclosed answers
378
+        $blankList = array();
379
+        // build replacement
380
+        $replacementList = array();
381
+        foreach ($this->answer as $i => $answer) {
382
+            $blankList[] = '['.$answer.']';
383
+        }
384
+
385
+        // splits text and weightings that are joined with the character '::'
386
+        list($answer,$weight)=explode('::',$answer);
387
+        $weights = explode(',',$weight);
388
+        // because [] is parsed here we follow this procedure:
389
+        // 1. find everything between the [ and ] tags
390
+        $i=1;
391
+        $jstmp = '';
392
+        $jstmpc = '';
393
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
394
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
395
+        $startlocations=api_strpos($answer,'[');
396
+        $endlocations=api_strpos($answer,']');
397
+        while ($startlocations !== false && $endlocations !== false) {
398
+            $texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1);
399
+            $answer = api_substr_replace(
400 400
                 $answer,
401 401
                 '<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',
402 402
                 $startlocations,
403 403
                 ($endlocations-$startlocations)+1
404 404
             );
405 405
             $jstmp .= $i.',';
406
-			if (!empty($texstring)) {
407
-				$sub = api_substr($texstring, 1, -1);
408
-				if (!empty($sub)) {
409
-					$jstmpc .= "'" . api_htmlentities($sub, ENT_QUOTES, $charset) . "',";
410
-				}
411
-			}
406
+            if (!empty($texstring)) {
407
+                $sub = api_substr($texstring, 1, -1);
408
+                if (!empty($sub)) {
409
+                    $jstmpc .= "'" . api_htmlentities($sub, ENT_QUOTES, $charset) . "',";
410
+                }
411
+            }
412 412
             $my_weight = explode('@', $weights[$i - 1]);
413 413
             if (count($my_weight) == 2) {
414 414
                 $weight_db = $my_weight[0];
415 415
             } else {
416 416
                 $weight_db = $my_weight[0];
417 417
             }
418
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n";
419
-			$i++;
420
-			$startlocations = api_strpos($answer, '[');
421
-			$endlocations = api_strpos($answer, ']');
422
-		}
418
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n";
419
+            $i++;
420
+            $startlocations = api_strpos($answer, '[');
421
+            $endlocations = api_strpos($answer, ']');
422
+        }
423 423
 
424
-		$html .= '<tr>
424
+        $html .= '<tr>
425 425
 			<td>
426 426
 			'.$answer.'
427 427
 			</td>
428 428
 			</tr></table></td></tr>';
429
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n";
430
-		$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n";
431
-		$js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
432
-		$js .= $jstmpw;
429
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n";
430
+        $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n";
431
+        $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
432
+        $js .= $jstmpw;
433 433
 
434
-		return array($js,$html);
435
-	}
434
+        return array($js,$html);
435
+    }
436 436
 }
437 437
 
438 438
 /**
@@ -441,65 +441,65 @@  discard block
 block discarded – undo
441 441
  */
442 442
 class ScormAnswerMatching extends Answer
443 443
 {
444
-	/**
445
-	 * Export the question part as a matrix-choice, with only one possible answer per line.
446
-	 * @author Amand Tihon <[email protected]>
447
-	 */
448
-	function export()
449
-	{
450
-		$js = '';
451
-		$html = '<tr><td colspan="2"><table width="100%">';
452
-		// prepare list of right proposition to allow
453
-		// - easiest display
454
-		// - easiest randomisation if needed one day
455
-		// (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...)
456
-
457
-		// get max length of displayed array
458
-
459
-		$nbrAnswers = $this->selectNbrAnswers();
460
-		$cpt1='A';
461
-		$cpt2=1;
462
-		$Select = array();
463
-		$qId = $this->questionJSId;
464
-		$s = '';
465
-		$jstmp = '';
466
-		$jstmpc = '';
467
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
468
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
469
-
470
-		for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
471
-			$identifier = 'question_'.$qId.'_matching_';
472
-			$answer=$this->selectAnswer($answerId);
473
-			$answerCorrect=$this->isCorrect($answerId);
474
-			$weight=$this->selectWeighting($answerId);
475
-			$jstmp .= $answerId.',';
476
-
477
-			if (!$answerCorrect) {
478
-				// options (A, B, C, ...) that will be put into the list-box
479
-				$Select[$answerId]['Lettre']=$cpt1;
480
-				// answers that will be shown at the right side
481
-				$Select[$answerId]['Reponse'] = $answer;
482
-				$cpt1++;
483
-			} else {
484
-				$s.='<tr>';
485
-				$s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>.&nbsp;'.$answer."</td>";
486
-				$s.='<td width="20%" align="center">&nbsp;&nbsp;<select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">';
487
-				$s.=' <option value="0">--</option>';
488
-				// fills the list-box
444
+    /**
445
+     * Export the question part as a matrix-choice, with only one possible answer per line.
446
+     * @author Amand Tihon <[email protected]>
447
+     */
448
+    function export()
449
+    {
450
+        $js = '';
451
+        $html = '<tr><td colspan="2"><table width="100%">';
452
+        // prepare list of right proposition to allow
453
+        // - easiest display
454
+        // - easiest randomisation if needed one day
455
+        // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...)
456
+
457
+        // get max length of displayed array
458
+
459
+        $nbrAnswers = $this->selectNbrAnswers();
460
+        $cpt1='A';
461
+        $cpt2=1;
462
+        $Select = array();
463
+        $qId = $this->questionJSId;
464
+        $s = '';
465
+        $jstmp = '';
466
+        $jstmpc = '';
467
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
468
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
469
+
470
+        for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
471
+            $identifier = 'question_'.$qId.'_matching_';
472
+            $answer=$this->selectAnswer($answerId);
473
+            $answerCorrect=$this->isCorrect($answerId);
474
+            $weight=$this->selectWeighting($answerId);
475
+            $jstmp .= $answerId.',';
476
+
477
+            if (!$answerCorrect) {
478
+                // options (A, B, C, ...) that will be put into the list-box
479
+                $Select[$answerId]['Lettre']=$cpt1;
480
+                // answers that will be shown at the right side
481
+                $Select[$answerId]['Reponse'] = $answer;
482
+                $cpt1++;
483
+            } else {
484
+                $s.='<tr>';
485
+                $s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>.&nbsp;'.$answer."</td>";
486
+                $s.='<td width="20%" align="center">&nbsp;&nbsp;<select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">';
487
+                $s.=' <option value="0">--</option>';
488
+                // fills the list-box
489 489
                 foreach ($Select as $key => $val) {
490 490
                     $s .= '<option value="'.$key.'">'.$val['Lettre'].'</option>';
491 491
                 }  // end foreach()
492 492
 
493
-				$s.='</select>&nbsp;&nbsp;</td>';
494
-				$s.='<td width="40%" valign="top">';
493
+                $s.='</select>&nbsp;&nbsp;</td>';
494
+                $s.='<td width="40%" valign="top">';
495 495
                 if (isset($Select[$cpt2])) {
496 496
                     $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
497 497
                 } else {
498 498
                     $s .= '&nbsp;';
499 499
                 }
500
-				$s.="</td></tr>";
500
+                $s.="</td></tr>";
501 501
 
502
-				$jstmpc .= '['.$answerCorrect.','.$cpt2.'],';
502
+                $jstmpc .= '['.$answerCorrect.','.$cpt2.'],';
503 503
 
504 504
                 $my_weight = explode('@', $weight);
505 505
                 if (count($my_weight) == 2) {
@@ -507,32 +507,32 @@  discard block
 block discarded – undo
507 507
                 } else {
508 508
                     $weight = $my_weight[0];
509 509
                 }
510
-				$jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n";
511
-				$cpt2++;
512
-
513
-				// if the left side of the "matching" has been completely shown
514
-				if ($answerId == $nbrAnswers) {
515
-					// if there remain answers to be shown on the right side
516
-					while (isset($Select[$cpt2])) {
517
-						$s.= '<tr>';
518
-						$s.= '<td width="60%" colspan="2">&nbsp;</td>';
519
-						$s.= '<td width="40%" valign="top">';
520
-						$s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
521
-						$s.= "</td></tr>";
522
-						$cpt2++;
523
-					}	// end while()
524
-				}  // end if()
525
-			}
526
-		}
527
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
528
-		$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
529
-		$js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n";
530
-		$js .= $jstmpw;
531
-		$html .= $s;
532
-		$html .= '</table></td></tr>' . "\n";
533
-
534
-		return array($js, $html);
535
-	}
510
+                $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n";
511
+                $cpt2++;
512
+
513
+                // if the left side of the "matching" has been completely shown
514
+                if ($answerId == $nbrAnswers) {
515
+                    // if there remain answers to be shown on the right side
516
+                    while (isset($Select[$cpt2])) {
517
+                        $s.= '<tr>';
518
+                        $s.= '<td width="60%" colspan="2">&nbsp;</td>';
519
+                        $s.= '<td width="40%" valign="top">';
520
+                        $s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
521
+                        $s.= "</td></tr>";
522
+                        $cpt2++;
523
+                    }	// end while()
524
+                }  // end if()
525
+            }
526
+        }
527
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
528
+        $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
529
+        $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n";
530
+        $js .= $jstmpw;
531
+        $html .= $s;
532
+        $html .= '</table></td></tr>' . "\n";
533
+
534
+        return array($js, $html);
535
+    }
536 536
 }
537 537
 
538 538
 /**
@@ -541,19 +541,19 @@  discard block
 block discarded – undo
541 541
  */
542 542
 class ScormAnswerFree extends Answer
543 543
 {
544
-	/**
545
-	 * Export the text with missing words.
546
-	 *
547
-	 * As a side effect, it stores two lists in the class :
548
-	 * the missing words and their respective weightings.
549
-	 *
550
-	 */
551
-	function export()
552
-	{
553
-		$js = '';
544
+    /**
545
+     * Export the text with missing words.
546
+     *
547
+     * As a side effect, it stores two lists in the class :
548
+     * the missing words and their respective weightings.
549
+     *
550
+     */
551
+    function export()
552
+    {
553
+        $js = '';
554 554
         $identifier = 'question_'.$this->questionJSId.'_free';
555
-		// currently the free answers cannot be displayed, so ignore the textarea
556
-		$html = '<tr><td colspan="2">';
555
+        // currently the free answers cannot be displayed, so ignore the textarea
556
+        $html = '<tr><td colspan="2">';
557 557
         $type = $this->getQuestionType();
558 558
 
559 559
         if ($type == ORAL_EXPRESSION) {
@@ -565,21 +565,21 @@  discard block
 block discarded – undo
565 565
             $layout = $template->get_template('document/record_audio.tpl');
566 566
             $html .= $template->fetch($layout);*/
567 567
 
568
-			$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
568
+            $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
569 569
 
570 570
             return array($js, $html);
571 571
         }
572 572
 
573 573
         $html .= '<textarea minlength="20" name="'.$identifier.'" id="'.$identifier.'" ></textarea>';
574 574
         $html .= '</td></tr>';
575
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array();';
576
-		$js .= 'questions_answers_correct['.$this->questionJSId.'] = "";';
577
-		$js .= 'questions_types['.$this->questionJSId.'] = \'free\';';
578
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";';
579
-		$js .= $jstmpw;
580
-
581
-		return array($js, $html);
582
-	}
575
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array();';
576
+        $js .= 'questions_answers_correct['.$this->questionJSId.'] = "";';
577
+        $js .= 'questions_types['.$this->questionJSId.'] = \'free\';';
578
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";';
579
+        $js .= $jstmpw;
580
+
581
+        return array($js, $html);
582
+    }
583 583
 }
584 584
 /**
585 585
  * This class handles the SCORM export of hotpot questions
@@ -587,63 +587,63 @@  discard block
 block discarded – undo
587 587
  */
588 588
 class ScormAnswerHotspot extends Answer
589 589
 {
590
-	/**
591
-	 * Returns the javascript code that goes with HotSpot exercises
592
-	 * @return string	The JavaScript code
593
-	 */
594
-	function get_js_header()
595
-	{
596
-		if ($this->standalone) {
597
-			$header = '<script>';
598
-			$header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
599
-			$header .= '</script>';
600
-			//because this header closes so many times the <script> tag, we have to reopen our own
601
-			$header .= '<script>';
602
-			$header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
603
-			$header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
604
-			$header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
605
-			$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
606
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
607
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
608
-			$header .= $jstmpw;
609
-		} else {
610
-			$header = '';
611
-			$header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
612
-			$header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
613
-			$header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
614
-			$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
615
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
616
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n";
617
-			$header .= $jstmpw;
618
-		}
619
-
620
-		return $header;
621
-	}
622
-	/**
623
-	 * Export the text with missing words.
624
-	 *
625
-	 * As a side effect, it stores two lists in the class :
626
-	 * the missing words and their respective weightings.
627
-	 *
628
-	 */
629
-	function export()
630
-	{
631
-		$js = $this->get_js_header();
632
-		$html = '<tr><td colspan="2"><table width="100%">';
633
-		// some javascript must be added for that kind of questions
634
-		$html .= '';
635
-
636
-		// Get the answers, make a list
637
-		$nbrAnswers=$this->selectNbrAnswers();
638
-
639
-		$answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>';
590
+    /**
591
+     * Returns the javascript code that goes with HotSpot exercises
592
+     * @return string	The JavaScript code
593
+     */
594
+    function get_js_header()
595
+    {
596
+        if ($this->standalone) {
597
+            $header = '<script>';
598
+            $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
599
+            $header .= '</script>';
600
+            //because this header closes so many times the <script> tag, we have to reopen our own
601
+            $header .= '<script>';
602
+            $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
603
+            $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
604
+            $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
605
+            $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
606
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
607
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
608
+            $header .= $jstmpw;
609
+        } else {
610
+            $header = '';
611
+            $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
612
+            $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
613
+            $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
614
+            $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
615
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
616
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n";
617
+            $header .= $jstmpw;
618
+        }
619
+
620
+        return $header;
621
+    }
622
+    /**
623
+     * Export the text with missing words.
624
+     *
625
+     * As a side effect, it stores two lists in the class :
626
+     * the missing words and their respective weightings.
627
+     *
628
+     */
629
+    function export()
630
+    {
631
+        $js = $this->get_js_header();
632
+        $html = '<tr><td colspan="2"><table width="100%">';
633
+        // some javascript must be added for that kind of questions
634
+        $html .= '';
635
+
636
+        // Get the answers, make a list
637
+        $nbrAnswers=$this->selectNbrAnswers();
638
+
639
+        $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>';
640 640
         for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
641 641
             $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>';
642 642
         }
643 643
         $answer_list .= '</ol></div>';
644
-		$canClick = true;
645
-		$relPath = api_get_path(REL_PATH);
646
-		$html .= <<<HTML
644
+        $canClick = true;
645
+        $relPath = api_get_path(REL_PATH);
646
+        $html .= <<<HTML
647 647
             <tr>
648 648
                 <td>
649 649
                     <div id="hotspot-{$this->questionJSId}"></div>
@@ -663,13 +663,13 @@  discard block
 block discarded – undo
663 663
                 </td>
664 664
             <tr>
665 665
 HTML;
666
-		$html .= '</table></td></tr>';
666
+        $html .= '</table></td></tr>';
667 667
 
668
-		// currently the free answers cannot be displayed, so ignore the textarea
669
-		$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
668
+        // currently the free answers cannot be displayed, so ignore the textarea
669
+        $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
670 670
 
671
-		return array($js, $html);
672
-	}
671
+        return array($js, $html);
672
+    }
673 673
 }
674 674
 
675 675
 /**
@@ -684,32 +684,32 @@  discard block
 block discarded – undo
684 684
  */
685 685
 class ScormAssessmentItem
686 686
 {
687
-	public $question;
688
-	public $question_ident;
689
-	public $answer;
690
-	public $standalone;
691
-
692
-	/**
693
-	 * Constructor.
694
-	 *
695
-	 * @param ScormQuestion $question The Question object we want to export.
696
-	 */
697
-	public function __construct($question, $standalone = false)
698
-	{
699
-		$this->question = $question;
700
-		$this->question->setAnswer();
701
-		$this->questionIdent = "QST_" . $question->id ;
702
-		$this->standalone = $standalone;
703
-	}
704
-
705
-	/**
706
-	 * Start the XML flow.
707
-	 *
708
-	 * This opens the <item> block, with correct attributes.
709
-	 *
710
-	 */
711
-	function start_page()
712
-	{
687
+    public $question;
688
+    public $question_ident;
689
+    public $answer;
690
+    public $standalone;
691
+
692
+    /**
693
+     * Constructor.
694
+     *
695
+     * @param ScormQuestion $question The Question object we want to export.
696
+     */
697
+    public function __construct($question, $standalone = false)
698
+    {
699
+        $this->question = $question;
700
+        $this->question->setAnswer();
701
+        $this->questionIdent = "QST_" . $question->id ;
702
+        $this->standalone = $standalone;
703
+    }
704
+
705
+    /**
706
+     * Start the XML flow.
707
+     *
708
+     * This opens the <item> block, with correct attributes.
709
+     *
710
+     */
711
+    function start_page()
712
+    {
713 713
         $head = '';
714 714
         if ($this->standalone) {
715 715
             $charset = 'UTF-8';
@@ -717,89 +717,89 @@  discard block
 block discarded – undo
717 717
             $head .= '<html>';
718 718
         }
719 719
 
720
-		return $head;
721
-	}
720
+        return $head;
721
+    }
722 722
 
723
-	/**
724
-	 * End the XML flow, closing the </item> tag.
725
-	 *
726
-	 */
727
-	function end_page()
723
+    /**
724
+     * End the XML flow, closing the </item> tag.
725
+     *
726
+     */
727
+    function end_page()
728
+    {
729
+        if ($this->standalone) {
730
+            return '</html>';
731
+        }
732
+
733
+        return '';
734
+    }
735
+
736
+    /**
737
+     * Start document header
738
+     */
739
+    function start_header()
740
+    {
741
+        if ($this->standalone) {
742
+            return '<head>';
743
+        }
744
+
745
+        return '';
746
+    }
747
+
748
+    /**
749
+     * Print CSS inclusion
750
+     */
751
+    function css()
752
+    {
753
+        $css = '';
754
+        if ($this->standalone) {
755
+            $css = '<style type="text/css" media="screen, projection">';
756
+            $css .= '/*<![CDATA[*/'."\n";
757
+            $css .= '/*]]>*/'."\n";
758
+            $css .= '</style>'."\n";
759
+            $css .= '<style type="text/css" media="print">';
760
+            $css .= '/*<![CDATA[*/'."\n";
761
+            $css .= '/*]]>*/'."\n";
762
+            $css .= '</style>';
763
+        }
764
+
765
+        return $css;
766
+    }
767
+
768
+    /**
769
+     * End document header
770
+     */
771
+    function end_header()
772
+    {
773
+        if ($this->standalone) {
774
+            return '</head>';
775
+        }
776
+
777
+        return '';
778
+    }
779
+    /**
780
+     * Start the itemBody
781
+     *
782
+     */
783
+    function start_js()
728 784
     {
729
-		if ($this->standalone) {
730
-			return '</html>';
731
-		}
732
-
733
-		return '';
734
-	}
735
-
736
-	/**
737
-	 * Start document header
738
-	 */
739
-	function start_header()
740
-	{
741
-		if ($this->standalone) {
742
-			return '<head>';
743
-		}
744
-
745
-		return '';
746
-	}
747
-
748
-	/**
749
-	 * Print CSS inclusion
750
-	 */
751
-	function css()
752
-	{
753
-		$css = '';
754
-		if ($this->standalone) {
755
-			$css = '<style type="text/css" media="screen, projection">';
756
-			$css .= '/*<![CDATA[*/'."\n";
757
-			$css .= '/*]]>*/'."\n";
758
-			$css .= '</style>'."\n";
759
-			$css .= '<style type="text/css" media="print">';
760
-			$css .= '/*<![CDATA[*/'."\n";
761
-			$css .= '/*]]>*/'."\n";
762
-			$css .= '</style>';
763
-		}
764
-
765
-		return $css;
766
-	}
767
-
768
-	/**
769
-	 * End document header
770
-	 */
771
-	function end_header()
772
-	{
773
-		if ($this->standalone) {
774
-			return '</head>';
775
-		}
776
-
777
-		return '';
778
-	}
779
-	/**
780
-	 * Start the itemBody
781
-	 *
782
-	 */
783
-	function start_js()
784
-	{
785 785
         $js = '<script type="text/javascript" src="assets/api_wrapper.js"></script>';
786
-		if ($this->standalone) {
787
-			return '<script>';
788
-		}
789
-		return $js;
790
-	}
791
-
792
-	/**
793
-	 * Common JS functions
794
-	 */
795
-	function common_js()
796
-	{
797
-		$js = 'var questions = new Array();';
798
-		$js .= 'var questions_answers = new Array();';
799
-		$js .= 'var questions_answers_correct = new Array();';
800
-		$js .= 'var questions_types = new Array();';
801
-		$js .= "\n" .
802
-			'/**
786
+        if ($this->standalone) {
787
+            return '<script>';
788
+        }
789
+        return $js;
790
+    }
791
+
792
+    /**
793
+     * Common JS functions
794
+     */
795
+    function common_js()
796
+    {
797
+        $js = 'var questions = new Array();';
798
+        $js .= 'var questions_answers = new Array();';
799
+        $js .= 'var questions_answers_correct = new Array();';
800
+        $js .= 'var questions_types = new Array();';
801
+        $js .= "\n" .
802
+            '/**
803 803
              * Assigns any event handler to any element
804 804
              * @param	object	Element on which the event is added
805 805
              * @param	string	Name of event
@@ -834,79 +834,79 @@  discard block
 block discarded – undo
834 834
             	addEvent(window,\'unload\',unloadPage,false);
835 835
             }'."\n\n";
836 836
 
837
-		$js .= '';
838
-		$js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
837
+        $js .= '';
838
+        $js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
839 839
         if ($this->standalone) {
840 840
             return $js."\n";
841 841
         }
842
-		return '';
843
-	}
844
-
845
-	/**
846
-	 * End the itemBody part.
847
-	 *
848
-	 */
849
-	function end_js()
850
-	{
842
+        return '';
843
+    }
844
+
845
+    /**
846
+     * End the itemBody part.
847
+     *
848
+     */
849
+    function end_js()
850
+    {
851 851
         if ($this->standalone) {
852 852
             return '</script>';
853 853
         }
854 854
 
855 855
         return '';
856
-	}
857
-
858
-	/**
859
-	 * Start the itemBody
860
-	 *
861
-	 */
862
-	function start_body()
863
-	{
864
-		if ($this->standalone) {
865
-			return '<body><form id="dokeos_scorm_form" method="post" action="">';
866
-		}
867
-
868
-		return '';
869
-	}
870
-
871
-	/**
872
-	 * End the itemBody part.
873
-	 *
874
-	 */
875
-	function end_body()
876
-	{
877
-		if ($this->standalone) {
878
-			return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
879
-		}
880
-
881
-		return '';
882
-	}
883
-
884
-	/**
885
-	 * Export the question as a SCORM Item.
886
-	 * This is a default behaviour, some classes may want to override this.
887
-	 * @return string|array A string, the XML flow for an Item.
888
-	 */
889
-	function export()
890
-	{
891
-		list($js, $html) = $this->question->export();
892
-		if ($this->standalone) {
893
-			$res = $this->start_page()
894
-				. $this->start_header()
895
-				. $this->css()
896
-				. $this->start_js()
897
-				. $this->common_js()
898
-				. $js
899
-				. $this->end_js()
900
-				. $this->end_header()
901
-				. $this->start_body()
856
+    }
857
+
858
+    /**
859
+     * Start the itemBody
860
+     *
861
+     */
862
+    function start_body()
863
+    {
864
+        if ($this->standalone) {
865
+            return '<body><form id="dokeos_scorm_form" method="post" action="">';
866
+        }
867
+
868
+        return '';
869
+    }
870
+
871
+    /**
872
+     * End the itemBody part.
873
+     *
874
+     */
875
+    function end_body()
876
+    {
877
+        if ($this->standalone) {
878
+            return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
879
+        }
880
+
881
+        return '';
882
+    }
883
+
884
+    /**
885
+     * Export the question as a SCORM Item.
886
+     * This is a default behaviour, some classes may want to override this.
887
+     * @return string|array A string, the XML flow for an Item.
888
+     */
889
+    function export()
890
+    {
891
+        list($js, $html) = $this->question->export();
892
+        if ($this->standalone) {
893
+            $res = $this->start_page()
894
+                . $this->start_header()
895
+                . $this->css()
896
+                . $this->start_js()
897
+                . $this->common_js()
898
+                . $js
899
+                . $this->end_js()
900
+                . $this->end_header()
901
+                . $this->start_body()
902 902
                 . $html
903
-				. $this->end_body()
904
-				. $this->end_page();
905
-			return $res;
906
-		} else {
907
-			return array($js, $html);
908
-		}
909
-	}
903
+                . $this->end_body()
904
+                . $this->end_page();
905
+            return $res;
906
+        } else {
907
+            return array($js, $html);
908
+        }
909
+    }
910 910
 }
911 911
 
912 912
 /**
@@ -923,103 +923,103 @@  discard block
 block discarded – undo
923 923
  */
924 924
 class ScormSection
925 925
 {
926
-	public $exercise;
927
-	public $standalone;
928
-
929
-	/**
930
-	 * Send a complete exercise in SCORM format, from its ID
931
-	 *
932
-	 * @param Exercise $exercise The exercise to export
933
-	 * @param boolean $standalone Wether it should include XML tag and DTD line.
934
-	 * @return string XML as a string, or an empty string if there's no exercise with given ID.
935
-	 */
936
-	public static function export_exercise_to_scorm(Exercise $exercise, $standalone = true)
937
-	{
938
-		$ims = new ScormSection($exercise);
939
-		$xml = $ims->export($standalone);
940
-
941
-		return $xml;
942
-	}
943
-
944
-	/**
945
-	 * Constructor.
946
-	 * @param Exercise $exe The Exercise instance to export
947
-	 * @author Amand Tihon <[email protected]>
948
-	 */
949
-	public function __construct($exe)
950
-	{
951
-		$this->exercise = $exe;
952
-	}
953
-
954
-	/**
955
-	 * Start the XML flow.
956
-	 *
957
-	 * This opens the <item> block, with correct attributes.
958
-	 *
959
-	 */
960
-	function start_page()
961
-	{
926
+    public $exercise;
927
+    public $standalone;
928
+
929
+    /**
930
+     * Send a complete exercise in SCORM format, from its ID
931
+     *
932
+     * @param Exercise $exercise The exercise to export
933
+     * @param boolean $standalone Wether it should include XML tag and DTD line.
934
+     * @return string XML as a string, or an empty string if there's no exercise with given ID.
935
+     */
936
+    public static function export_exercise_to_scorm(Exercise $exercise, $standalone = true)
937
+    {
938
+        $ims = new ScormSection($exercise);
939
+        $xml = $ims->export($standalone);
940
+
941
+        return $xml;
942
+    }
943
+
944
+    /**
945
+     * Constructor.
946
+     * @param Exercise $exe The Exercise instance to export
947
+     * @author Amand Tihon <[email protected]>
948
+     */
949
+    public function __construct($exe)
950
+    {
951
+        $this->exercise = $exe;
952
+    }
953
+
954
+    /**
955
+     * Start the XML flow.
956
+     *
957
+     * This opens the <item> block, with correct attributes.
958
+     *
959
+     */
960
+    function start_page()
961
+    {
962 962
         $charset = 'UTF-8';
963
-		$head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>';
964
-
965
-		return $head;
966
-	}
967
-
968
-	/**
969
-	 * End the XML flow, closing the </item> tag.
970
-	 *
971
-	 */
972
-	function end_page()
973
-	{
974
-		return '</html>';
975
-	}
976
-
977
-	/**
978
-	 * Start document header
979
-	 */
980
-	function start_header()
981
-	{
982
-		return '<head>';
983
-	}
984
-
985
-	/**
986
-	 * Print CSS inclusion
987
-	 */
988
-	private function css()
989
-	{
990
-		return '';
991
-	}
992
-
993
-	/**
994
-	 * End document header
995
-	 */
963
+        $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>';
964
+
965
+        return $head;
966
+    }
967
+
968
+    /**
969
+     * End the XML flow, closing the </item> tag.
970
+     *
971
+     */
972
+    function end_page()
973
+    {
974
+        return '</html>';
975
+    }
976
+
977
+    /**
978
+     * Start document header
979
+     */
980
+    function start_header()
981
+    {
982
+        return '<head>';
983
+    }
984
+
985
+    /**
986
+     * Print CSS inclusion
987
+     */
988
+    private function css()
989
+    {
990
+        return '';
991
+    }
992
+
993
+    /**
994
+     * End document header
995
+     */
996 996
     private function end_header()
997
-	{
998
-		return '</head>';
999
-	}
1000
-
1001
-	/**
1002
-	 * Start the itemBody
1003
-	 *
1004
-	 */
997
+    {
998
+        return '</head>';
999
+    }
1000
+
1001
+    /**
1002
+     * Start the itemBody
1003
+     *
1004
+     */
1005 1005
     private function start_js()
1006
-	{
1007
-		return '<script>';
1008
-	}
1009
-
1010
-	/**
1011
-	 * Common JS functions
1012
-	 */
1013
-	public function common_js()
1014
-	{
1015
-		$js = file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
1016
-
1017
-		$js .= 'var questions = new Array();' . "\n";
1018
-		$js .= 'var questions_answers = new Array();' . "\n";
1019
-		$js .= 'var questions_answers_correct = new Array();' . "\n";
1020
-		$js .= 'var questions_types = new Array();' . "\n";
1021
-		$js .= "\n" .
1022
-			'/**
1006
+    {
1007
+        return '<script>';
1008
+    }
1009
+
1010
+    /**
1011
+     * Common JS functions
1012
+     */
1013
+    public function common_js()
1014
+    {
1015
+        $js = file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
1016
+
1017
+        $js .= 'var questions = new Array();' . "\n";
1018
+        $js .= 'var questions_answers = new Array();' . "\n";
1019
+        $js .= 'var questions_answers_correct = new Array();' . "\n";
1020
+        $js .= 'var questions_types = new Array();' . "\n";
1021
+        $js .= "\n" .
1022
+            '/**
1023 1023
              * Assigns any event handler to any element
1024 1024
              * @param	object	Element on which the event is added
1025 1025
              * @param	string	Name of event
@@ -1061,76 +1061,76 @@  discard block
 block discarded – undo
1061 1061
             }
1062 1062
             '."\n";
1063 1063
 
1064
-		$js .= '';
1065
-		$js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
1066
-		return $js. "\n";
1067
-	}
1064
+        $js .= '';
1065
+        $js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
1066
+        return $js. "\n";
1067
+    }
1068
+
1069
+    /**
1070
+     * End the itemBody part.
1071
+     *
1072
+     */
1073
+    function end_js()
1074
+    {
1075
+        return '</script>';
1076
+    }
1077
+
1078
+    /**
1079
+     * Start the itemBody
1080
+     *
1081
+     */
1082
+    function start_body()
1083
+    {
1084
+        return '<body>'.
1085
+        '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>".
1086
+        '<form id="dokeos_scorm_form" method="post" action="">'.
1087
+        '<table width="100%">';
1088
+    }
1089
+
1090
+    /**
1091
+     * End the itemBody part.
1092
+     *
1093
+     */
1094
+    function end_body()
1095
+    {
1096
+        return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
1097
+    }
1068 1098
 
1069
-	/**
1070
-	 * End the itemBody part.
1071
-	 *
1072
-	 */
1073
-	function end_js()
1099
+    /**
1100
+     * Export the question as a SCORM Item.
1101
+     *
1102
+     * This is a default behaviour, some classes may want to override this.
1103
+     *
1104
+     * @param $standalone: Boolean stating if it should be exported as a stand-alone question
1105
+     * @return string string, the XML flow for an Item.
1106
+     */
1107
+    function export()
1074 1108
     {
1075
-		return '</script>';
1076
-	}
1077
-
1078
-	/**
1079
-	 * Start the itemBody
1080
-	 *
1081
-	 */
1082
-	function start_body()
1083
-	{
1084
-		return '<body>'.
1085
-		'<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>".
1086
-		'<form id="dokeos_scorm_form" method="post" action="">'.
1087
-		'<table width="100%">';
1088
-	}
1089
-
1090
-	/**
1091
-	 * End the itemBody part.
1092
-	 *
1093
-	 */
1094
-	function end_body()
1095
-	{
1096
-		return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
1097
-	}
1098
-
1099
-	/**
1100
-	 * Export the question as a SCORM Item.
1101
-	 *
1102
-	 * This is a default behaviour, some classes may want to override this.
1103
-	 *
1104
-	 * @param $standalone: Boolean stating if it should be exported as a stand-alone question
1105
-	 * @return string string, the XML flow for an Item.
1106
-	 */
1107
-	function export()
1108
-	{
1109
-		global $charset;
1110
-
1111
-		$head = '';
1112
-		if ($this->standalone) {
1113
-			$head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n"
1114
-				. '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n";
1115
-		}
1116
-
1117
-		list($js, $html) = $this->export_questions();
1118
-		$res = $this->start_page()
1119
-			. $this->start_header()
1120
-			. $this->css()
1109
+        global $charset;
1110
+
1111
+        $head = '';
1112
+        if ($this->standalone) {
1113
+            $head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n"
1114
+                . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n";
1115
+        }
1116
+
1117
+        list($js, $html) = $this->export_questions();
1118
+        $res = $this->start_page()
1119
+            . $this->start_header()
1120
+            . $this->css()
1121 1121
             . $this->globalAssets()
1122
-			. $this->start_js()
1123
-			. $this->common_js()
1124
-			. $js
1125
-			. $this->end_js()
1126
-			. $this->end_header()
1127
-			. $this->start_body()
1128
-			. $html
1129
-			. $this->end_body()
1130
-			. $this->end_page();
1131
-
1132
-		return $res;
1133
-	}
1122
+            . $this->start_js()
1123
+            . $this->common_js()
1124
+            . $js
1125
+            . $this->end_js()
1126
+            . $this->end_header()
1127
+            . $this->start_body()
1128
+            . $html
1129
+            . $this->end_body()
1130
+            . $this->end_page();
1131
+
1132
+        return $res;
1133
+    }
1134 1134
 
1135 1135
     /**
1136 1136
      * @return string
@@ -1144,21 +1144,21 @@  discard block
 block discarded – undo
1144 1144
         return $assets;
1145 1145
     }
1146 1146
 
1147
-	/**
1148
-	 * Export the questions, as a succession of <items>
1149
-	 * @author Amand Tihon <[email protected]>
1150
-	 */
1151
-	function export_questions()
1152
-	{
1153
-		$js = $html = "";
1154
-		$js_id = 0;
1155
-		foreach ($this->exercise->selectQuestionList() as $q) {
1156
-			list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id);
1157
-			$js .= $jstmp."\n";
1158
-			$html .= $htmltmp."\n";
1159
-			++$js_id;
1160
-		}
1161
-
1162
-		return array($js, $html);
1163
-	}
1147
+    /**
1148
+     * Export the questions, as a succession of <items>
1149
+     * @author Amand Tihon <[email protected]>
1150
+     */
1151
+    function export_questions()
1152
+    {
1153
+        $js = $html = "";
1154
+        $js_id = 0;
1155
+        foreach ($this->exercise->selectQuestionList() as $q) {
1156
+            list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id);
1157
+            $js .= $jstmp."\n";
1158
+            $html .= $htmltmp."\n";
1159
+            ++$js_id;
1160
+        }
1161
+
1162
+        return array($js, $html);
1163
+    }
1164 1164
 }
Please login to merge, or discard this patch.
app/check.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -96,6 +96,9 @@
 block discarded – undo
96 96
     echo PHP_EOL;
97 97
 }
98 98
 
99
+/**
100
+ * @param string $message
101
+ */
99 102
 function echo_style($style, $message)
100 103
 {
101 104
     // ANSI color codes
Please login to merge, or discard this patch.
main/exercise/hotspot_savescore.inc.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 $objExercise = Session::read('objExercise');
17 17
 $exerciseId = $objExercise->selectId();
18 18
 // Save clicking order
19
-$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
19
+$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids']) + 1;
20 20
 if ($_GET['answerId'] == "0") {
21 21
     // click is NOT on a hotspot
22 22
     $hit = 0;
@@ -24,18 +24,18 @@  discard block
 block discarded – undo
24 24
 } else {
25 25
     // user clicked ON a hotspot
26 26
     $hit = 1;
27
-    $answerId = api_substr($_GET['answerId'],22,2);
27
+    $answerId = api_substr($_GET['answerId'], 22, 2);
28 28
 	// Save into session
29 29
 	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
30 30
 }
31 31
 //round-up the coordinates
32
-$coords = explode('/',$coordinates);
32
+$coords = explode('/', $coordinates);
33 33
 $coordinates = '';
34 34
 foreach ($coords as $coord) {
35
-    list($x,$y) = explode(';',$coord);
35
+    list($x, $y) = explode(';', $coord);
36 36
     $coordinates .= round($x).';'.round($y).'/';
37 37
 }
38
-$coordinates = substr($coordinates,0,-1);
38
+$coordinates = substr($coordinates, 0, -1);
39 39
 
40 40
 $TBL_TRACK_E_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
41 41
 // Save into db
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     'quiz_id' => $exerciseId,
46 46
     'question_id' => $questionId,
47 47
     'answer_id' =>  $answerId,
48
-    'correct' => $hit ,
48
+    'correct' => $hit,
49 49
     'coordinate' => $coordinates
50 50
 ];
51 51
 // Save insert id into session if users changes answer.
Please login to merge, or discard this patch.
main/exercise/hotspot_updatescore.inc.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,16 +20,16 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@
 block discarded – undo
33 33
 }
34 34
 
35 35
 //round-up the coordinates
36
-$coords = explode('/',$coordinates);
36
+$coords = explode('/', $coordinates);
37 37
 $coordinates = '';
38 38
 foreach ($coords as $coord) {
39
-    list($x,$y) = explode(';',$coord);
39
+    list($x, $y) = explode(';', $coord);
40 40
     $coordinates .= round($x).';'.round($y).'/';
41 41
 }
42
-$coordinates = substr($coordinates,0,-1);
42
+$coordinates = substr($coordinates, 0, -1);
43 43
 
44 44
 $TBL_TRACK_E_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
45 45
 
Please login to merge, or discard this patch.
main/mySpace/teachers.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 
21 21
 $this_section = SECTION_TRACKING;
22 22
 
23
-$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
23
+$interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('MySpace'));
24 24
 
25 25
 if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && !isset($_GET["type"])) {
26
-    $interbreadcrumb[] = array ("url" => "teachers.php", "name" => get_lang('Teachers'));
26
+    $interbreadcrumb[] = array("url" => "teachers.php", "name" => get_lang('Teachers'));
27 27
 }
28 28
 
29
-if (isset($_GET["user_id"]) && $_GET["user_id"]!="" && isset($_GET["type"]) && $_GET["type"] == "coach") {
30
-    $interbreadcrumb[] = array ("url" => "coaches.php", "name" => get_lang('Tutors'));
29
+if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && isset($_GET["type"]) && $_GET["type"] == "coach") {
30
+    $interbreadcrumb[] = array("url" => "coaches.php", "name" => get_lang('Tutors'));
31 31
 }
32 32
 
33 33
 function get_count_users()
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
                 $courseInfo = api_get_course_info($course_code);
123 123
                 $courseId = $courseInfo['real_id'];
124 124
                 if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
125
-                    $avg_time_spent 	+= Tracking :: get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']);
126
-                    $my_average 		 = Tracking :: get_avg_student_score($student_id, $course_code);
125
+                    $avg_time_spent += Tracking :: get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']);
126
+                    $my_average = Tracking :: get_avg_student_score($student_id, $course_code);
127 127
                     if (is_numeric($my_average)) {
128 128
                         $avg_student_score += $my_average;
129 129
                     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             $detailsLink = '<a href="myStudents.php?student='.$student_id.'&id_coach='.$coach_id.'&id_session='.$_GET['id_session'].'">
163 163
 				          '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a>';
164 164
         } else {
165
-            $detailsLink =  '<a href="myStudents.php?student='.$student_id.'">
165
+            $detailsLink = '<a href="myStudents.php?student='.$student_id.'">
166 166
 				            '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a>';
167 167
         }
168 168
         $row[] = $detailsLink;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 $actionsLeft = '';
182 182
 if (api_is_drh()) {
183 183
     $menu_items = array(
184
-        Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ),
184
+        Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php"),
185 185
         Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), 'student.php'),
186 186
         Display::url(Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php'),
187 187
         Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php'),
Please login to merge, or discard this patch.
main/course_home/activity.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     // Show message to confirm that a tool it to be hidden from available tools
23 23
     // visibility 0,1->2
24 24
     if (!empty($_GET['askDelete'])) {
25
-        $content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
25
+        $content .= '<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
26 26
             <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
27 27
             <a href="'.api_get_self().'?delete=yes&id='.$id.'">'.get_lang('Yes').'</a>
28 28
         </div>';
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 
50 50
 // Start of tools for CourseAdmins (teachers/tutors)
51 51
 if ($session_id === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
52
-    $content .=  '<div class="alert alert-success" style="border:0px; margin-top: 0px;padding:0px;">
52
+    $content .= '<div class="alert alert-success" style="border:0px; margin-top: 0px;padding:0px;">
53 53
 		<div class="normal-message" id="id_normal_message" style="display:none">';
54
-    $content .=  '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
55
-    $content .=  get_lang('PleaseStandBy');
56
-    $content .=  '</div>
54
+    $content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
55
+    $content .= get_lang('PleaseStandBy');
56
+    $content .= '</div>
57 57
 		<div class="alert alert-success" id="id_confirmation_message" style="display:none"></div>
58 58
 	</div>';
59 59
 
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
     $my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
79 79
     $list2 = CourseHome::get_tools_category(TOOL_COURSE_PLUGIN);
80 80
 
81
-    $my_list = array_merge($my_list,$list2);
82
-    $items =  CourseHome::show_tools_category($my_list);
81
+    $my_list = array_merge($my_list, $list2);
82
+    $items = CourseHome::show_tools_category($my_list);
83 83
     $content .= return_block(get_lang('Interaction'), $items, 'course-tools-interaction');
84 84
 
85 85
     $my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 			<span class="viewcaption">'.get_lang('SessionData').'</span>
95 95
 			<table class="course_activity_home">';
96 96
         $content .= CourseHome::show_session_data($session_id);
97
-        $content .=  '</table></div></div>';
97
+        $content .= '</table></div></div>';
98 98
     }
99 99
 
100
-    $content .=  '<div class="row">';
100
+    $content .= '<div class="row">';
101 101
     $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
102 102
     $content .= CourseHome::show_tools_category($my_list);
103 103
     $content .= '</div>';
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 {
180 180
     $html = '<div class="row">
181 181
                 <div class="col-xs-12 col-md-12">
182
-                    <div class="title-tools">' . $title . '</div>
182
+                    <div class="title-tools">' . $title.'</div>
183 183
                 </div>
184 184
             </div>
185 185
             <div class="row '.$class.'">'.$content.'</div>';
Please login to merge, or discard this patch.
main/lp/lp_admin_view.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
28 28
 $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
29 29
 
30
-$isStudentView = isset($_REQUEST['isStudentView']) ? (int)$_REQUEST['isStudentView'] : null;
31
-$learnpath_id = (int)$_REQUEST['lp_id'];
30
+$isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : null;
31
+$learnpath_id = (int) $_REQUEST['lp_id'];
32 32
 $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
33 33
 $_course = api_get_course_info();
34 34
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 }
56 56
 
57 57
 if (!empty($gradebook) && $gradebook == 'view') {
58
-    $interbreadcrumb[] = array (
58
+    $interbreadcrumb[] = array(
59 59
         'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
60 60
         'name' => get_lang('ToolGradebook')
61 61
     );
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             $in = implode(',', $lp_items_to_remove_audio);
97 97
         }
98 98
     }
99
-    if (count($lp_items_to_remove_audio)>0) {
99
+    if (count($lp_items_to_remove_audio) > 0) {
100 100
         $sql = "UPDATE $tbl_lp_item SET audio = '' 
101 101
                 WHERE c_id = $course_id AND id IN (".$in.")";
102 102
         $result = Database::query($sql);
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                 // Adding something random to prevent overwriting.
132 132
                 $filename_components[count($filename_components) - 1] = time();
133 133
                 // Reconstructing the new filename.
134
-                $clean_name = implode($filename_components) .'.'.$file_extension;
134
+                $clean_name = implode($filename_components).'.'.$file_extension;
135 135
                 // Using the new name in the $_FILES superglobal.
136 136
                 $_FILES[$key]['name'] = $clean_name;
137 137
             }
Please login to merge, or discard this patch.