Completed
Push — 1.10.x ( ac2491...356be2 )
by Angel Fernando Quiroz
227:50 queued 184:04
created
main/newscorm/learnpath.class.php 1 patch
Braces   +110 added lines, -76 removed lines patch added patch discarded remove patch
@@ -3939,8 +3939,9 @@  discard block
 block discarded – undo
3939 3939
                 WHERE c_id = ".$course_id."
3940 3940
                 ORDER BY display_order";
3941 3941
         $res = Database::query($sql);
3942
-        if ($res === false)
3943
-            return false;
3942
+        if ($res === false) {
3943
+                    return false;
3944
+        }
3944 3945
         $lps = array ();
3945 3946
         $lp_order = array ();
3946 3947
         $num = Database :: num_rows($res);
@@ -4540,8 +4541,9 @@  discard block
 block discarded – undo
4540 4541
         if ($this->debug > 0) {
4541 4542
             error_log('New LP - In learnpath::set_maker()', 0);
4542 4543
         }
4543
-        if (empty ($name))
4544
-            return false;
4544
+        if (empty ($name)) {
4545
+                    return false;
4546
+        }
4545 4547
         $this->maker = $name;
4546 4548
         $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
4547 4549
         $course_id = api_get_course_int_id();
@@ -4606,8 +4608,9 @@  discard block
 block discarded – undo
4606 4608
     public function set_terms_by_prefix($terms_string, $prefix)
4607 4609
     {
4608 4610
         $course_id = api_get_course_int_id();
4609
-        if (api_get_setting('search_enabled') !== 'true')
4610
-            return false;
4611
+        if (api_get_setting('search_enabled') !== 'true') {
4612
+                    return false;
4613
+        }
4611 4614
 
4612 4615
         if (!extension_loaded('xapian')) {
4613 4616
             return false;
@@ -4620,8 +4623,9 @@  discard block
 block discarded – undo
4620 4623
         $stored_terms = $this->get_common_index_terms_by_prefix($prefix);
4621 4624
 
4622 4625
         // Don't do anything if no change, verify only at DB, not the search engine.
4623
-        if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0))
4624
-            return false;
4626
+        if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) {
4627
+                    return false;
4628
+        }
4625 4629
 
4626 4630
         require_once 'xapian.php'; // TODO: Try catch every xapian use or make wrappers on API.
4627 4631
         require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
@@ -4813,8 +4817,9 @@  discard block
 block discarded – undo
4813 4817
         if ($this->debug > 0) {
4814 4818
             error_log('New LP - In learnpath::set_proximity()', 0);
4815 4819
         }
4816
-        if (empty ($name))
4817
-            return false;
4820
+        if (empty ($name)) {
4821
+                    return false;
4822
+        }
4818 4823
 
4819 4824
         $this->proximity = $name;
4820 4825
         $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
@@ -5156,8 +5161,9 @@  discard block
 block discarded – undo
5156 5161
 
5157 5162
         $sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." ORDER BY display_order";
5158 5163
         $res = Database::query($sql);
5159
-        if ($res === false)
5160
-            return false;
5164
+        if ($res === false) {
5165
+                    return false;
5166
+        }
5161 5167
 
5162 5168
         $num = Database :: num_rows($res);
5163 5169
         // First check the order is correct, globally (might be wrong because
@@ -5468,8 +5474,9 @@  discard block
 block discarded – undo
5468 5474
             $position[$key] = $row['display_order'];
5469 5475
         }
5470 5476
 
5471
-        if (count($array) > 0)
5472
-            array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array);
5477
+        if (count($array) > 0) {
5478
+                    array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array);
5479
+        }
5473 5480
 
5474 5481
         return $array;
5475 5482
     }
@@ -6037,8 +6044,9 @@  discard block
 block discarded – undo
6037 6044
         $tmp_filename = $filename;
6038 6045
 
6039 6046
         $i = 0;
6040
-        while (file_exists($filepath . $tmp_filename . '.'.$extension))
6041
-            $tmp_filename = $filename . '_' . ++ $i;
6047
+        while (file_exists($filepath . $tmp_filename . '.'.$extension)) {
6048
+                    $tmp_filename = $filename . '_' . ++ $i;
6049
+        }
6042 6050
 
6043 6051
         $filename = $tmp_filename . '.'.$extension;
6044 6052
         if ($extension == 'html') {
@@ -6117,10 +6125,12 @@  discard block
 block discarded – undo
6117 6125
                     if ($new_comment || $new_title) {
6118 6126
                         $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
6119 6127
                         $ct = '';
6120
-                        if ($new_comment)
6121
-                            $ct .= ", comment='" . Database::escape_string($new_comment). "'";
6122
-                        if ($new_title)
6123
-                            $ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset))."' ";
6128
+                        if ($new_comment) {
6129
+                                                    $ct .= ", comment='" . Database::escape_string($new_comment). "'";
6130
+                        }
6131
+                        if ($new_title) {
6132
+                                                    $ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset))."' ";
6133
+                        }
6124 6134
 
6125 6135
                         $sql = "UPDATE " . $tbl_doc ." SET " . substr($ct, 1)."
6126 6136
                                WHERE c_id = ".$course_id." AND id = " . $document_id;
@@ -6144,17 +6154,21 @@  discard block
 block discarded – undo
6144 6154
         // Please, do not modify this dirname formatting.
6145 6155
         $dir = isset($_GET['dir']) ? $_GET['dir'] : $_POST['dir'];
6146 6156
 
6147
-        if (strstr($dir, '..'))
6148
-            $dir = '/';
6157
+        if (strstr($dir, '..')) {
6158
+                    $dir = '/';
6159
+        }
6149 6160
 
6150
-        if ($dir[0] == '.')
6151
-            $dir = substr($dir, 1);
6161
+        if ($dir[0] == '.') {
6162
+                    $dir = substr($dir, 1);
6163
+        }
6152 6164
 
6153
-        if ($dir[0] != '/')
6154
-            $dir = '/' . $dir;
6165
+        if ($dir[0] != '/') {
6166
+                    $dir = '/' . $dir;
6167
+        }
6155 6168
 
6156
-        if ($dir[strlen($dir) - 1] != '/')
6157
-            $dir .= '/';
6169
+        if ($dir[strlen($dir) - 1] != '/') {
6170
+                    $dir .= '/';
6171
+        }
6158 6172
 
6159 6173
         $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
6160 6174
 
@@ -6219,8 +6233,9 @@  discard block
 block discarded – undo
6219 6233
                 }
6220 6234
                 $return .= '<div style="padding:10px;">';
6221 6235
 
6222
-                if ($msg != '')
6223
-                    $return .= $msg;
6236
+                if ($msg != '') {
6237
+                                    $return .= $msg;
6238
+                }
6224 6239
 
6225 6240
                 $return .= '<h3>'.$row['title'].'</h3>';
6226 6241
                 switch ($row['item_type']) {
@@ -6484,10 +6499,11 @@  discard block
 block discarded – undo
6484 6499
         $item_title			= Security::remove_XSS($item_title);
6485 6500
         $item_description 	= Security::remove_XSS($item_description);
6486 6501
 
6487
-        if ($id != 0 && is_array($extra_info))
6488
-            $parent = $extra_info['parent_item_id'];
6489
-        else
6490
-            $parent = 0;
6502
+        if ($id != 0 && is_array($extra_info)) {
6503
+                    $parent = $extra_info['parent_item_id'];
6504
+        } else {
6505
+                    $parent = 0;
6506
+        }
6491 6507
 
6492 6508
         $sql = "SELECT * FROM " . $tbl_lp_item . "
6493 6509
                 WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id;
@@ -6760,11 +6776,13 @@  discard block
 block discarded – undo
6760 6776
         }
6761 6777
 
6762 6778
         $legend = '<legend>';
6763
-        if ($action == 'add')
6764
-            $legend .= get_lang('CreateTheExercise');
6765
-        elseif ($action == 'move') $legend .= get_lang('MoveTheCurrentExercise');
6766
-        else
6767
-            $legend .= get_lang('EditCurrentExecice');
6779
+        if ($action == 'add') {
6780
+                    $legend .= get_lang('CreateTheExercise');
6781
+        } elseif ($action == 'move') {
6782
+            $legend .= get_lang('MoveTheCurrentExercise');
6783
+        } else {
6784
+                    $legend .= get_lang('EditCurrentExecice');
6785
+        }
6768 6786
         if (isset ($_GET['edit']) && $_GET['edit'] == 'true') {
6769 6787
             $legend .= Display :: return_warning_message(get_lang('Warning') . ' ! ' . get_lang('WarningEditingDocument'));
6770 6788
         }
@@ -6791,8 +6809,9 @@  discard block
 block discarded – undo
6791 6809
                         $arrHide[] = $arrLP[$i]['id'];
6792 6810
                     }
6793 6811
                 } else {
6794
-                    if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
6795
-                        $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
6812
+                    if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') {
6813
+                                            $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
6814
+                    }
6796 6815
                 }
6797 6816
             }
6798 6817
 
@@ -6810,11 +6829,13 @@  discard block
 block discarded – undo
6810 6829
 
6811 6830
         for ($i = 0; $i < count($arrLP); $i++) {
6812 6831
             if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) {
6813
-                if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
6832
+                if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
6833
+                                    $selected = 'selected="selected" ';
6834
+                } elseif ($action == 'add') {
6814 6835
                     $selected = 'selected="selected" ';
6815
-                elseif ($action == 'add') $selected = 'selected="selected" ';
6816
-                else
6817
-                    $selected = '';
6836
+                } else {
6837
+                                    $selected = '';
6838
+                }
6818 6839
 
6819 6840
                 $return .= '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">' . get_lang('After') . ' "' . $arrLP[$i]['title'] . '"</option>';
6820 6841
             }
@@ -6841,9 +6862,11 @@  discard block
 block discarded – undo
6841 6862
                 $arrHide = array ();
6842 6863
                 for ($i = 0; $i < count($arrLP); $i++) {
6843 6864
                     if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
6844
-                        if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
6845
-                            $s_selected_position = $arrLP[$i]['id'];
6846
-                        elseif ($action == 'add') $s_selected_position = 0;
6865
+                        if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
6866
+                                                    $s_selected_position = $arrLP[$i]['id'];
6867
+                        } elseif ($action == 'add') {
6868
+                            $s_selected_position = 0;
6869
+                        }
6847 6870
                         $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
6848 6871
 
6849 6872
                     }
@@ -7040,9 +7063,11 @@  discard block
 block discarded – undo
7040 7063
             $arrHide = array();
7041 7064
             for ($i = 0; $i < count($arrLP); $i++) {
7042 7065
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
7043
-                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
7044
-                        $s_selected_position = $arrLP[$i]['id'];
7045
-                    elseif ($action == 'add') $s_selected_position = 0;
7066
+                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7067
+                                            $s_selected_position = $arrLP[$i]['id'];
7068
+                    } elseif ($action == 'add') {
7069
+                        $s_selected_position = 0;
7070
+                    }
7046 7071
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7047 7072
                 }
7048 7073
             }
@@ -7245,9 +7270,11 @@  discard block
 block discarded – undo
7245 7270
 
7246 7271
             for ($i = 0; $i < count($arrLP); $i++) {
7247 7272
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
7248
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
7249
-                        $s_selected_position = $arrLP[$i]['id'];
7250
-                    elseif ($action == 'add') $s_selected_position = 0;
7273
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7274
+                                            $s_selected_position = $arrLP[$i]['id'];
7275
+                    } elseif ($action == 'add') {
7276
+                        $s_selected_position = 0;
7277
+                    }
7251 7278
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7252 7279
 
7253 7280
                 }
@@ -7281,8 +7308,7 @@  discard block
 block discarded – undo
7281 7308
 
7282 7309
         if (is_numeric($extra_info)) {
7283 7310
             $form->addHidden('path', $extra_info);
7284
-        }
7285
-        elseif (is_array($extra_info)) {
7311
+        } elseif (is_array($extra_info)) {
7286 7312
             $form->addHidden('path', $extra_info['path']);
7287 7313
         }
7288 7314
 
@@ -7335,8 +7361,9 @@  discard block
 block discarded – undo
7335 7361
                     lp_id = " . $this->lp_id . " AND
7336 7362
                     id != $id";
7337 7363
 
7338
-        if ($item_type == 'module')
7339
-            $sql .= " AND parent_item_id = 0";
7364
+        if ($item_type == 'module') {
7365
+                    $sql .= " AND parent_item_id = 0";
7366
+        }
7340 7367
 
7341 7368
         $result = Database::query($sql);
7342 7369
         $arrLP = array ();
@@ -7722,9 +7749,11 @@  discard block
 block discarded – undo
7722 7749
 
7723 7750
             for ($i = 0; $i < count($arrLP); $i++) {
7724 7751
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter' && $arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) {
7725
-                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
7752
+                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7753
+                                            $s_selected_position = $arrLP[$i]['id'];
7754
+                    } elseif ($action == 'add') {
7726 7755
                         $s_selected_position = $arrLP[$i]['id'];
7727
-                    elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id'];
7756
+                    }
7728 7757
 
7729 7758
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7730 7759
 
@@ -7735,17 +7764,18 @@  discard block
 block discarded – undo
7735 7764
                 $item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null;
7736 7765
                 $edit = isset($_GET['edit']) ? $_GET['edit'] : null;
7737 7766
                 if (($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $item_type == TOOL_LP_FINAL_ITEM || $edit == 'true')) {
7738
-                    if (isset ($_POST['content']))
7739
-                        $content = stripslashes($_POST['content']);
7740
-                    elseif (is_array($extra_info)) {
7767
+                    if (isset ($_POST['content'])) {
7768
+                                            $content = stripslashes($_POST['content']);
7769
+                    } elseif (is_array($extra_info)) {
7741 7770
                         //If it's an html document or a text file
7742 7771
                         if (!$no_display_edit_textarea) {
7743 7772
                             $content = $this->display_document($extra_info['path'], false, false);
7744 7773
                         }
7745
-                    } elseif (is_numeric($extra_info))
7746
-                        $content = $this->display_document($extra_info, false, false);
7747
-                    else
7748
-                        $content = '';
7774
+                    } elseif (is_numeric($extra_info)) {
7775
+                                            $content = $this->display_document($extra_info, false, false);
7776
+                    } else {
7777
+                                            $content = '';
7778
+                    }
7749 7779
 
7750 7780
                     if (!$no_display_edit_textarea) {
7751 7781
                         // We need to calculate here some specific settings for the online editor.
@@ -8013,9 +8043,11 @@  discard block
 block discarded – undo
8013 8043
             $arrHide = array();
8014 8044
             for ($i = 0; $i < count($arrLP); $i++) {
8015 8045
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
8016
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
8017
-                        $s_selected_position = $arrLP[$i]['id'];
8018
-                    elseif ($action == 'add') $s_selected_position = 0;
8046
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
8047
+                                            $s_selected_position = $arrLP[$i]['id'];
8048
+                    } elseif ($action == 'add') {
8049
+                        $s_selected_position = 0;
8050
+                    }
8019 8051
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
8020 8052
 
8021 8053
                 }
@@ -8218,9 +8250,11 @@  discard block
 block discarded – undo
8218 8250
             $arrHide = array ();
8219 8251
             for ($i = 0; $i < count($arrLP); $i++) {
8220 8252
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
8221
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
8222
-                        $s_selected_position = $arrLP[$i]['id'];
8223
-                    elseif ($action == 'add') $s_selected_position = 0;
8253
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
8254
+                                            $s_selected_position = $arrLP[$i]['id'];
8255
+                    } elseif ($action == 'add') {
8256
+                        $s_selected_position = 0;
8257
+                    }
8224 8258
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
8225 8259
 
8226 8260
                 }
@@ -9795,9 +9829,9 @@  discard block
 block discarded – undo
9795 9829
         $main_code_path = api_get_path(SYS_CODE_PATH).'newscorm/packaging/';
9796 9830
         $extra_files = scandir($main_code_path);
9797 9831
         foreach ($extra_files as $extra_file) {
9798
-            if (strpos($extra_file, '.') === 0)
9799
-                continue;
9800
-            else {
9832
+            if (strpos($extra_file, '.') === 0) {
9833
+                            continue;
9834
+            } else {
9801 9835
                 $dest_file = $archive_path . $temp_dir_short . '/' . $extra_file;
9802 9836
                 $this->create_path($dest_file);
9803 9837
                 copy($main_code_path.$extra_file, $dest_file);
Please login to merge, or discard this patch.
main/newscorm/lp_controller.php 1 patch
Braces   +233 added lines, -122 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 $use_anonymous = true;
14 14
 
15 15
 $debug = 0;
16
-if ($debug > 0) error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0);
16
+if ($debug > 0) {
17
+    error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0);
18
+}
17 19
 
18 20
 // Language files that needs to be included.
19 21
 if (isset($_GET['action'])) {
@@ -231,10 +233,14 @@  discard block
 block discarded – undo
231 233
     // If refresh is set, we regenerate the oLP object from the database (kind of flush).
232 234
     Session::erase('refresh');
233 235
     $myrefresh = 1;
234
-    if ($debug > 0) error_log('New LP - Refresh asked', 0);
235
-}
236
+    if ($debug > 0) {
237
+        error_log('New LP - Refresh asked', 0);
238
+    }
239
+    }
236 240
 
237
-if ($debug > 0) error_log('New LP - Passed refresh check', 0);
241
+if ($debug > 0) {
242
+    error_log('New LP - Passed refresh check', 0);
243
+}
238 244
 
239 245
 if (!empty($_REQUEST['dialog_box'])) {
240 246
     $dialog_box = stripslashes(urldecode($_REQUEST['dialog_box']));
@@ -244,17 +250,23 @@  discard block
 block discarded – undo
244 250
 $lp_found = false;
245 251
 
246 252
 if (isset($_SESSION['lpobject'])) {
247
-    if ($debug > 0) error_log('New LP - SESSION[lpobject] is defined', 0);
253
+    if ($debug > 0) {
254
+        error_log('New LP - SESSION[lpobject] is defined', 0);
255
+    }
248 256
     $oLP = unserialize($_SESSION['lpobject']);
249 257
     if (isset($oLP) && is_object($oLP)) {
250
-        if ($debug > 0) error_log('New LP - oLP is object', 0);
258
+        if ($debug > 0) {
259
+            error_log('New LP - oLP is object', 0);
260
+        }
251 261
         if ($myrefresh == 1 OR
252 262
             empty($oLP->cc) OR
253 263
             $oLP->cc != api_get_course_id() OR
254 264
             $oLP->lp_view_session_id != $session_id OR
255 265
             $oLP->scorm_debug == '1'
256 266
         ) {
257
-            if ($debug > 0) error_log('New LP - Course has changed, discard lp object', 0);
267
+            if ($debug > 0) {
268
+                error_log('New LP - Course has changed, discard lp object', 0);
269
+            }
258 270
             if ($myrefresh == 1) { $myrefresh_id = $oLP->get_id(); }
259 271
             $oLP = null;
260 272
             Session::erase('oLP');
@@ -268,13 +280,19 @@  discard block
 block discarded – undo
268 280
 
269 281
 $course_id = api_get_course_int_id();
270 282
 
271
-if ($debug>0) error_log('New LP - Passed data remains check', 0);
283
+if ($debug>0) {
284
+    error_log('New LP - Passed data remains check', 0);
285
+}
272 286
 
273 287
 if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) {
274
-    if ($debug > 0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
288
+    if ($debug > 0) {
289
+        error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
290
+    }
275 291
     // Regenerate a new lp object? Not always as some pages don't need the object (like upload?)
276 292
     if (!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)) {
277
-        if ($debug > 0) error_log('New LP - lp_id is defined', 0);
293
+        if ($debug > 0) {
294
+            error_log('New LP - lp_id is defined', 0);
295
+        }
278 296
         // Select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the
279 297
         // right object.
280 298
         if (!empty($_REQUEST['lp_id'])) {
@@ -286,49 +304,67 @@  discard block
 block discarded – undo
286 304
         $lp_table = Database::get_course_table(TABLE_LP_MAIN);
287 305
         if (is_numeric($lp_id)) {
288 306
             $sel = "SELECT lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id";
289
-            if ($debug > 0) error_log('New LP - querying '.$sel, 0);
307
+            if ($debug > 0) {
308
+                error_log('New LP - querying '.$sel, 0);
309
+            }
290 310
             $res = Database::query($sel);
291 311
 
292 312
             if (Database::num_rows($res)) {
293 313
                 $row = Database::fetch_array($res);
294 314
                 $type = $row['lp_type'];
295
-                if ($debug > 0) error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
315
+                if ($debug > 0) {
316
+                    error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
317
+                }
296 318
                 switch ($type) {
297 319
                     case 1:
298
-                        if ($debug > 0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
320
+                        if ($debug > 0) {
321
+                            error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
322
+                        }
299 323
 
300 324
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
301 325
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
302 326
                         break;
303 327
                     case 2:
304
-                        if ($debug > 0) error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
328
+                        if ($debug > 0) {
329
+                            error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
330
+                        }
305 331
                         $oLP = new scorm(api_get_course_id(), $lp_id, api_get_user_id());
306 332
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
307 333
                         break;
308 334
                     case 3:
309
-                        if ($debug > 0) error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
335
+                        if ($debug > 0) {
336
+                            error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
337
+                        }
310 338
                         $oLP = new aicc(api_get_course_id(), $lp_id, api_get_user_id());
311 339
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
312 340
                         break;
313 341
                     default:
314
-                        if ($debug > 0) error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
342
+                        if ($debug > 0) {
343
+                            error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
344
+                        }
315 345
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
316 346
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
317 347
                         break;
318 348
                 }
319 349
             }
320 350
         } else {
321
-            if ($debug > 0) error_log('New LP - Request[lp_id] is not numeric', 0);
351
+            if ($debug > 0) {
352
+                error_log('New LP - Request[lp_id] is not numeric', 0);
353
+            }
322 354
         }
323 355
     } else {
324
-        if ($debug > 0) error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
356
+        if ($debug > 0) {
357
+            error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
358
+        }
325 359
     }
326 360
     if ($lp_found) {
327 361
         $_SESSION['oLP'] = $oLP;
328 362
     }
329 363
 }
330 364
 
331
-if ($debug > 0) error_log('New LP - Passed oLP creation check', 0);
365
+if ($debug > 0) {
366
+    error_log('New LP - Passed oLP creation check', 0);
367
+}
332 368
 
333 369
 $is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
334 370
 
@@ -372,11 +408,15 @@  discard block
 block discarded – undo
372 408
         if (!$is_allowed_to_edit) {
373 409
             api_not_allowed(true);
374 410
         }
375
-        if ($debug > 0) error_log('New LP - add item action triggered', 0);
411
+        if ($debug > 0) {
412
+            error_log('New LP - add item action triggered', 0);
413
+        }
376 414
 
377 415
         if (!$lp_found) {
378 416
             //check if the learnpath ID was defined, otherwise send back to list
379
-            if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
417
+            if ($debug > 0) {
418
+                error_log('New LP - No learnpath given for add item', 0);
419
+            }
380 420
             require 'lp_list.php';
381 421
         } else {
382 422
             $_SESSION['refresh'] = 1;
@@ -450,11 +490,15 @@  discard block
 block discarded – undo
450 490
         if (!$is_allowed_to_edit) {
451 491
             api_not_allowed(true);
452 492
         }
453
-        if ($debug > 0) error_log('New LP - add audio action triggered', 0);
493
+        if ($debug > 0) {
494
+            error_log('New LP - add audio action triggered', 0);
495
+        }
454 496
 
455 497
         if (!$lp_found) {
456 498
             //check if the learnpath ID was defined, otherwise send back to list
457
-            if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0);
499
+            if ($debug > 0) {
500
+                error_log('New LP - No learnpath given for add audio', 0);
501
+            }
458 502
             require 'lp_list.php';
459 503
         } else {
460 504
             $_SESSION['refresh'] = 1;
@@ -528,7 +572,9 @@  discard block
 block discarded – undo
528 572
         if (!$is_allowed_to_edit) {
529 573
             api_not_allowed(true);
530 574
         }
531
-        if ($debug > 0) error_log('New LP - add_lp action triggered', 0);
575
+        if ($debug > 0) {
576
+            error_log('New LP - add_lp action triggered', 0);
577
+        }
532 578
         if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
533 579
             $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
534 580
             $_SESSION['refresh'] = 1;
@@ -587,9 +633,10 @@  discard block
 block discarded – undo
587 633
         if (!$is_allowed_to_edit) {
588 634
             api_not_allowed(true);
589 635
         }
590
-        if ($debug > 0) error_log('New LP - admin_view action triggered', 0);
591
-        if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; }
592
-        else {
636
+        if ($debug > 0) {
637
+            error_log('New LP - admin_view action triggered', 0);
638
+        }
639
+        if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; } else {
593 640
             $_SESSION['refresh'] = 1;
594 641
             require 'lp_admin_view.php';
595 642
         }
@@ -599,9 +646,10 @@  discard block
 block discarded – undo
599 646
             if (!$is_allowed_to_edit) {
600 647
                 api_not_allowed(true);
601 648
             }
602
-            if ($debug > 0) error_log('New LP - auto_launch action triggered', 0);
603
-            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; }
604
-            else {
649
+            if ($debug > 0) {
650
+                error_log('New LP - auto_launch action triggered', 0);
651
+            }
652
+            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; } else {
605 653
                 $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
606 654
                 require 'lp_list.php';
607 655
                 exit;
@@ -612,10 +660,11 @@  discard block
 block discarded – undo
612 660
         if (!$is_allowed_to_edit) {
613 661
             api_not_allowed(true);
614 662
         }
615
-        if ($debug > 0) error_log('New LP - build action triggered', 0);
663
+        if ($debug > 0) {
664
+            error_log('New LP - build action triggered', 0);
665
+        }
616 666
 
617
-        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; }
618
-        else {
667
+        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; } else {
619 668
             $_SESSION['refresh'] = 1;
620 669
             //require 'lp_build.php';
621 670
             $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
@@ -627,10 +676,11 @@  discard block
 block discarded – undo
627 676
         if (!$is_allowed_to_edit) {
628 677
             api_not_allowed(true);
629 678
         }
630
-        if ($debug > 0) error_log('New LP - edit item action triggered', 0);
679
+        if ($debug > 0) {
680
+            error_log('New LP - edit item action triggered', 0);
681
+        }
631 682
 
632
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item', 0); require 'lp_list.php'; }
633
-        else {
683
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item', 0); require 'lp_list.php'; } else {
634 684
             $_SESSION['refresh'] = 1;
635 685
             if (isset($_POST['submit_button']) && !empty($post_title)) {
636 686
 
@@ -680,9 +730,10 @@  discard block
 block discarded – undo
680 730
         if (!$is_allowed_to_edit) {
681 731
             api_not_allowed(true);
682 732
         }
683
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
684
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
685
-        else {
733
+        if ($debug > 0) {
734
+            error_log('New LP - edit item prereq action triggered', 0);
735
+        }
736
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
686 737
             if (isset($_POST['submit_button'])) {
687 738
                 //Updating the lp.modified_on
688 739
                 $_SESSION['oLP']->set_modified_on();
@@ -710,9 +761,10 @@  discard block
 block discarded – undo
710 761
         if (!$is_allowed_to_edit) {
711 762
             api_not_allowed(true);
712 763
         }
713
-        if ($debug > 0) error_log('New LP - move item action triggered', 0);
714
-        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; }
715
-        else {
764
+        if ($debug > 0) {
765
+            error_log('New LP - move item action triggered', 0);
766
+        }
767
+        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; } else {
716 768
             $_SESSION['refresh'] = 1;
717 769
             if (isset($_POST['submit_button'])) {
718 770
                 //Updating the lp.modified_on
@@ -745,7 +797,9 @@  discard block
 block discarded – undo
745 797
         if (!$is_allowed_to_edit) {
746 798
             api_not_allowed(true);
747 799
         }
748
-        if ($debug > 0) error_log('New LP - view_item action triggered', 0);
800
+        if ($debug > 0) {
801
+            error_log('New LP - view_item action triggered', 0);
802
+        }
749 803
         if (!$lp_found) {
750 804
             error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
751 805
         } else {
@@ -757,7 +811,9 @@  discard block
 block discarded – undo
757 811
         if (!$is_allowed_to_edit) {
758 812
             api_not_allowed(true);
759 813
         }
760
-        if ($debug > 0) error_log('New LP - upload action triggered', 0);
814
+        if ($debug > 0) {
815
+            error_log('New LP - upload action triggered', 0);
816
+        }
761 817
         $cwdir = getcwd();
762 818
         require 'lp_upload.php';
763 819
         // Reinit current working directory as many functions in upload change it.
@@ -774,9 +830,10 @@  discard block
 block discarded – undo
774 830
             api_not_allowed(true);
775 831
         }
776 832
 
777
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
778
-        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; }
779
-        else {
833
+        if ($debug > 0) {
834
+            error_log('New LP - export action triggered', 0);
835
+        }
836
+        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; } else {
780 837
             $_SESSION['oLP']->copy();
781 838
         }
782 839
         require 'lp_list.php';
@@ -789,9 +846,10 @@  discard block
 block discarded – undo
789 846
         if ($hideScormExportLink === 'true') {
790 847
             api_not_allowed(true);
791 848
         }
792
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
793
-        if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; }
794
-        else {
849
+        if ($debug > 0) {
850
+            error_log('New LP - export action triggered', 0);
851
+        }
852
+        if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; } else {
795 853
             $_SESSION['oLP']->scorm_export();
796 854
             exit();
797 855
             //require 'lp_list.php';
@@ -806,7 +864,9 @@  discard block
 block discarded – undo
806 864
             api_not_allowed(true);
807 865
         }
808 866
 
809
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
867
+        if ($debug > 0) {
868
+            error_log('New LP - export action triggered', 0);
869
+        }
810 870
         if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php';
811 871
         } else {
812 872
             $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
@@ -820,9 +880,10 @@  discard block
 block discarded – undo
820 880
         if (!$is_allowed_to_edit) {
821 881
             api_not_allowed(true);
822 882
         }
823
-        if ($debug > 0) error_log('New LP - delete action triggered', 0);
824
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; }
825
-        else {
883
+        if ($debug > 0) {
884
+            error_log('New LP - delete action triggered', 0);
885
+        }
886
+        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; } else {
826 887
             $_SESSION['refresh'] = 1;
827 888
             $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
828 889
             Session::erase('oLP');
@@ -834,9 +895,10 @@  discard block
 block discarded – undo
834 895
         if (!$is_allowed_to_edit) {
835 896
             api_not_allowed(true);
836 897
         }
837
-        if ($debug > 0) error_log('New LP - visibility action triggered', 0);
838
-        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; }
839
-        else {
898
+        if ($debug > 0) {
899
+            error_log('New LP - visibility action triggered', 0);
900
+        }
901
+        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; } else {
840 902
             learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
841 903
             require 'lp_list.php';
842 904
         }
@@ -846,9 +908,10 @@  discard block
 block discarded – undo
846 908
         if (!$is_allowed_to_edit) {
847 909
             api_not_allowed(true);
848 910
         }
849
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
850
-        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; }
851
-        else {
911
+        if ($debug > 0) {
912
+            error_log('New LP - publish action triggered', 0);
913
+        }
914
+        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; } else {
852 915
             learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
853 916
             require 'lp_list.php';
854 917
         }
@@ -858,7 +921,9 @@  discard block
 block discarded – undo
858 921
         if (!$is_allowed_to_edit) {
859 922
             api_not_allowed(true);
860 923
         }
861
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
924
+        if ($debug > 0) {
925
+            error_log('New LP - publish action triggered', 0);
926
+        }
862 927
         if (!$lp_found) {
863 928
             error_log('New LP - No learnpath given for publish', 0);
864 929
             require 'lp_list.php';
@@ -872,7 +937,9 @@  discard block
 block discarded – undo
872 937
         if (!$is_allowed_to_edit) {
873 938
             api_not_allowed(true);
874 939
         }
875
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
940
+        if ($debug > 0) {
941
+            error_log('New LP - publish action triggered', 0);
942
+        }
876 943
         if (!$lp_found) {
877 944
             error_log('New LP - No learnpath given for publish', 0);
878 945
             require 'lp_list.php';
@@ -885,9 +952,10 @@  discard block
 block discarded – undo
885 952
         if (!$is_allowed_to_edit) {
886 953
             api_not_allowed(true);
887 954
         }
888
-        if ($debug > 0) error_log('New LP - edit action triggered', 0);
889
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
890
-        else {
955
+        if ($debug > 0) {
956
+            error_log('New LP - edit action triggered', 0);
957
+        }
958
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
891 959
             $_SESSION['refresh'] = 1;
892 960
             require 'lp_edit.php';
893 961
         }
@@ -896,9 +964,10 @@  discard block
 block discarded – undo
896 964
         if (!$is_allowed_to_edit) {
897 965
             api_not_allowed(true);
898 966
         }
899
-        if ($debug > 0) error_log('New LP - update_lp action triggered', 0);
900
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
901
-        else {
967
+        if ($debug > 0) {
968
+            error_log('New LP - update_lp action triggered', 0);
969
+        }
970
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
902 971
             $_SESSION['refresh'] = 1;
903 972
             $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
904 973
             $_SESSION['oLP']->set_name($lp_name);
@@ -965,8 +1034,9 @@  discard block
 block discarded – undo
965 1034
             );
966 1035
             $extraFieldValue->saveFieldValues($_REQUEST);
967 1036
 
968
-            if ($_FILES['lp_preview_image']['size'] > 0)
969
-                $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1037
+            if ($_FILES['lp_preview_image']['size'] > 0) {
1038
+                            $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1039
+            }
970 1040
 
971 1041
             if (api_get_setting('search_enabled') === 'true') {
972 1042
                 require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
@@ -1006,9 +1076,10 @@  discard block
 block discarded – undo
1006 1076
         if (!$is_allowed_to_edit) {
1007 1077
             api_not_allowed(true);
1008 1078
         }
1009
-        if ($debug > 0) error_log('New LP - add sub item action triggered', 0);
1010
-        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; }
1011
-        else {
1079
+        if ($debug > 0) {
1080
+            error_log('New LP - add sub item action triggered', 0);
1081
+        }
1082
+        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; } else {
1012 1083
             $_SESSION['refresh'] = 1;
1013 1084
             if (!empty($_REQUEST['parent_item_id'])) {
1014 1085
                 $_SESSION['from_learnpath']='yes';
@@ -1024,9 +1095,10 @@  discard block
 block discarded – undo
1024 1095
         if (!$is_allowed_to_edit) {
1025 1096
             api_not_allowed(true);
1026 1097
         }
1027
-        if ($debug > 0) error_log('New LP - delete item action triggered', 0);
1028
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete item', 0); require 'lp_list.php'; }
1029
-        else {
1098
+        if ($debug > 0) {
1099
+            error_log('New LP - delete item action triggered', 0);
1100
+        }
1101
+        if (!$lp_found) { error_log('New LP - No learnpath given for delete item', 0); require 'lp_list.php'; } else {
1030 1102
             //$_SESSION['refresh'] = 1;
1031 1103
             if (!empty($_REQUEST['id'])) {
1032 1104
                 $_SESSION['oLP']->delete_item($_REQUEST['id']);
@@ -1041,9 +1113,10 @@  discard block
 block discarded – undo
1041 1113
         if (!$is_allowed_to_edit) {
1042 1114
             api_not_allowed(true);
1043 1115
         }
1044
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
1045
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
1046
-        else {
1116
+        if ($debug > 0) {
1117
+            error_log('New LP - edit item prereq action triggered', 0);
1118
+        }
1119
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
1047 1120
             if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
1048 1121
                 $_SESSION['refresh'] = 1;
1049 1122
                 $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
@@ -1052,64 +1125,80 @@  discard block
 block discarded – undo
1052 1125
         }
1053 1126
         break;
1054 1127
     case 'restart':
1055
-        if ($debug > 0) error_log('New LP - restart action triggered', 0);
1056
-        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; }
1057
-        else {
1128
+        if ($debug > 0) {
1129
+            error_log('New LP - restart action triggered', 0);
1130
+        }
1131
+        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; } else {
1058 1132
             $_SESSION['oLP']->restart();
1059 1133
             require 'lp_view.php';
1060 1134
         }
1061 1135
         break;
1062 1136
     case 'last':
1063
-        if ($debug > 0) error_log('New LP - last action triggered', 0);
1064
-        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; }
1065
-        else {
1137
+        if ($debug > 0) {
1138
+            error_log('New LP - last action triggered', 0);
1139
+        }
1140
+        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; } else {
1066 1141
             $_SESSION['oLP']->last();
1067 1142
             require 'lp_view.php';
1068 1143
         }
1069 1144
         break;
1070 1145
     case 'first':
1071
-        if ($debug > 0) error_log('New LP - first action triggered', 0);
1072
-        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; }
1073
-        else {
1146
+        if ($debug > 0) {
1147
+            error_log('New LP - first action triggered', 0);
1148
+        }
1149
+        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; } else {
1074 1150
             $_SESSION['oLP']->first();
1075 1151
             require 'lp_view.php';
1076 1152
         }
1077 1153
         break;
1078 1154
     case 'next':
1079
-        if ($debug > 0) error_log('New LP - next action triggered', 0);
1080
-        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; }
1081
-        else {
1155
+        if ($debug > 0) {
1156
+            error_log('New LP - next action triggered', 0);
1157
+        }
1158
+        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; } else {
1082 1159
             $_SESSION['oLP']->next();
1083 1160
             require 'lp_view.php';
1084 1161
         }
1085 1162
         break;
1086 1163
     case 'previous':
1087
-        if ($debug > 0) error_log('New LP - previous action triggered', 0);
1088
-        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; }
1089
-        else {
1164
+        if ($debug > 0) {
1165
+            error_log('New LP - previous action triggered', 0);
1166
+        }
1167
+        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; } else {
1090 1168
             $_SESSION['oLP']->previous();
1091 1169
             require 'lp_view.php';
1092 1170
         }
1093 1171
         break;
1094 1172
     case 'content':
1095
-        if ($debug > 0) error_log('New LP - content action triggered', 0);
1096
-        if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1173
+        if ($debug > 0) {
1174
+            error_log('New LP - content action triggered', 0);
1175
+        }
1176
+        if ($debug > 0) {
1177
+            error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1178
+        }
1097 1179
         if (!$lp_found) {
1098 1180
             error_log('New LP - No learnpath given for content', 0);
1099 1181
             require 'lp_list.php';
1100 1182
         } else {
1101
-            if ($debug > 0) error_log('New LP - save_last()', 0);
1183
+            if ($debug > 0) {
1184
+                error_log('New LP - save_last()', 0);
1185
+            }
1102 1186
             $_SESSION['oLP']->save_last();
1103
-            if ($debug > 0) error_log('New LP - set_current_item()', 0);
1187
+            if ($debug > 0) {
1188
+                error_log('New LP - set_current_item()', 0);
1189
+            }
1104 1190
             $_SESSION['oLP']->set_current_item($_GET['item_id']);
1105
-            if ($debug > 0) error_log('New LP - start_current_item()', 0);
1191
+            if ($debug > 0) {
1192
+                error_log('New LP - start_current_item()', 0);
1193
+            }
1106 1194
             $_SESSION['oLP']->start_current_item();
1107 1195
             require 'lp_content.php';
1108 1196
         }
1109 1197
         break;
1110 1198
     case 'view':
1111
-        if ($debug > 0)
1112
-            error_log('New LP - view action triggered', 0);
1199
+        if ($debug > 0) {
1200
+                    error_log('New LP - view action triggered', 0);
1201
+        }
1113 1202
         if (!$lp_found) {
1114 1203
             error_log('New LP - No learnpath given for view', 0);
1115 1204
             require 'lp_list.php';
@@ -1122,17 +1211,19 @@  discard block
 block discarded – undo
1122 1211
         }
1123 1212
         break;
1124 1213
     case 'save':
1125
-        if ($debug > 0) error_log('New LP - save action triggered', 0);
1126
-        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; }
1127
-        else {
1214
+        if ($debug > 0) {
1215
+            error_log('New LP - save action triggered', 0);
1216
+        }
1217
+        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; } else {
1128 1218
             $_SESSION['oLP']->save_item();
1129 1219
             require 'lp_save.php';
1130 1220
         }
1131 1221
         break;
1132 1222
     case 'stats':
1133
-        if ($debug > 0) error_log('New LP - stats action triggered', 0);
1134
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1135
-        else {
1223
+        if ($debug > 0) {
1224
+            error_log('New LP - stats action triggered', 0);
1225
+        }
1226
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1136 1227
             $_SESSION['oLP']->save_current();
1137 1228
             $_SESSION['oLP']->save_last();
1138 1229
             $output = require 'lp_stats.php';
@@ -1140,7 +1231,9 @@  discard block
 block discarded – undo
1140 1231
         }
1141 1232
         break;
1142 1233
     case 'list':
1143
-        if ($debug > 0) error_log('New LP - list action triggered', 0);
1234
+        if ($debug > 0) {
1235
+            error_log('New LP - list action triggered', 0);
1236
+        }
1144 1237
         if ($lp_found) {
1145 1238
             $_SESSION['refresh'] = 1;
1146 1239
             $_SESSION['oLP']->save_last();
@@ -1149,7 +1242,9 @@  discard block
 block discarded – undo
1149 1242
         break;
1150 1243
     case 'mode':
1151 1244
         // Switch between fullscreen and embedded mode.
1152
-        if ($debug > 0) error_log('New LP - mode change triggered', 0);
1245
+        if ($debug > 0) {
1246
+            error_log('New LP - mode change triggered', 0);
1247
+        }
1153 1248
         $mode = $_REQUEST['mode'];
1154 1249
         if ($mode == 'fullscreen') {
1155 1250
             $_SESSION['oLP']->mode = 'fullscreen';
@@ -1163,7 +1258,9 @@  discard block
 block discarded – undo
1163 1258
         require 'lp_view.php';
1164 1259
         break;
1165 1260
     case 'switch_view_mode':
1166
-        if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0);
1261
+        if ($debug > 0) {
1262
+            error_log('New LP - switch_view_mode action triggered', 0);
1263
+        }
1167 1264
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1168 1265
         if (Security::check_token('get')) {
1169 1266
             $_SESSION['refresh'] = 1;
@@ -1172,7 +1269,9 @@  discard block
 block discarded – undo
1172 1269
         require 'lp_list.php';
1173 1270
         break;
1174 1271
     case 'switch_force_commit':
1175
-        if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0);
1272
+        if ($debug > 0) {
1273
+            error_log('New LP - switch_force_commit action triggered', 0);
1274
+        }
1176 1275
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1177 1276
         $_SESSION['refresh'] = 1;
1178 1277
         $_SESSION['oLP']->update_default_scorm_commit();
@@ -1195,25 +1294,33 @@  discard block
 block discarded – undo
1195 1294
 		break;
1196 1295
      */
1197 1296
 	case 'switch_attempt_mode':
1198
-		if($debug>0) error_log('New LP - switch_reinit action triggered',0);
1297
+		if($debug>0) {
1298
+		    error_log('New LP - switch_reinit action triggered',0);
1299
+		}
1199 1300
 		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
1200 1301
 		$_SESSION['refresh'] = 1;
1201 1302
 		$_SESSION['oLP']->switch_attempt_mode();
1202 1303
         require 'lp_list.php';
1203 1304
         break;
1204 1305
     case 'switch_scorm_debug':
1205
-        if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0);
1306
+        if ($debug > 0) {
1307
+            error_log('New LP - switch_scorm_debug action triggered', 0);
1308
+        }
1206 1309
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1207 1310
         $_SESSION['refresh'] = 1;
1208 1311
         $_SESSION['oLP']->update_scorm_debug();
1209 1312
         require 'lp_list.php';
1210 1313
         break;
1211 1314
     case 'intro_cmdAdd':
1212
-        if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0);
1315
+        if ($debug > 0) {
1316
+            error_log('New LP - intro_cmdAdd action triggered', 0);
1317
+        }
1213 1318
         // Add introduction section page.
1214 1319
         break;
1215 1320
     case 'js_api_refresh':
1216
-        if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0);
1321
+        if ($debug > 0) {
1322
+            error_log('New LP - js_api_refresh action triggered', 0);
1323
+        }
1217 1324
         if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
1218 1325
         if (isset($_REQUEST['item_id'])) {
1219 1326
             $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
@@ -1221,8 +1328,7 @@  discard block
 block discarded – undo
1221 1328
         require 'lp_message.php';
1222 1329
         break;
1223 1330
     case 'return_to_course_homepage':
1224
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1225
-        else {
1331
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1226 1332
             $_SESSION['oLP']->save_current();
1227 1333
             $_SESSION['oLP']->save_last();
1228 1334
             $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
@@ -1240,8 +1346,9 @@  discard block
 block discarded – undo
1240 1346
         require 'lp_list_search.php';
1241 1347
         break;
1242 1348
     case 'impress':
1243
-        if ($debug > 0)
1244
-            error_log('New LP - view action triggered', 0);
1349
+        if ($debug > 0) {
1350
+                    error_log('New LP - view action triggered', 0);
1351
+        }
1245 1352
         if (!$lp_found) {
1246 1353
             error_log('New LP - No learnpath given for view', 0);
1247 1354
             require 'lp_list.php';
@@ -1413,15 +1520,19 @@  discard block
 block discarded – undo
1413 1520
         ]);
1414 1521
         break;
1415 1522
     default:
1416
-        if ($debug > 0) error_log('New LP - default action triggered', 0);
1523
+        if ($debug > 0) {
1524
+            error_log('New LP - default action triggered', 0);
1525
+        }
1417 1526
         require 'lp_list.php';
1418 1527
         break;
1419 1528
 }
1420 1529
 
1421 1530
 if (!empty($_SESSION['oLP'])) {
1422 1531
     $_SESSION['lpobject'] = serialize($_SESSION['oLP']);
1423
-    if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0);
1424
-}
1532
+    if ($debug > 0) {
1533
+        error_log('New LP - lpobject is serialized in session', 0);
1534
+    }
1535
+    }
1425 1536
 
1426 1537
 if (!empty($redirectTo)) {
1427 1538
     header("Location: $redirectTo");
Please login to merge, or discard this patch.
main/exercice/admin.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -362,9 +362,10 @@
 block discarded – undo
362 362
 
363 363
 if ($inATest) {
364 364
     echo '<div class="actions">';
365
-    if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid']))
366
-        echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'.
365
+    if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) {
366
+            echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'.
367 367
             Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
368
+    }
368 369
 
369 370
     if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) &&  !isset($_GET['editQuestion'])) {
370 371
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/exercise.php?'.api_get_cidreq().'">'.
Please login to merge, or discard this patch.
main/exercice/exercise_submit.php 1 patch
Braces   +32 added lines, -12 removed lines patch added patch discarded remove patch
@@ -269,7 +269,9 @@  discard block
 block discarded – undo
269 269
 $clock_expired_time = null;
270 270
 
271 271
 if (empty($exercise_stat_info)) {
272
-    if ($debug)  error_log('5  $exercise_stat_info is empty ');
272
+    if ($debug) {
273
+        error_log('5  $exercise_stat_info is empty ');
274
+    }
273 275
 	$total_weight = 0;
274 276
 	$questionList = $objExercise->get_validated_question_list();
275 277
 	foreach ($questionListUncompressed as $question_id) {
@@ -280,11 +282,17 @@  discard block
 block discarded – undo
280 282
 	if ($time_control) {
281 283
 		$expected_time = $current_timestamp + $total_seconds;
282 284
 
283
-		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
284
-		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
285
+		if ($debug) {
286
+		    error_log('5.1. $current_timestamp '.$current_timestamp);
287
+		}
288
+		if ($debug) {
289
+		    error_log('5.2. $expected_time '.$expected_time);
290
+		}
285 291
 
286 292
 		$clock_expired_time 	= api_get_utc_datetime($expected_time);
287
-		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
293
+		if ($debug) {
294
+		    error_log('5.3. $expected_time '.$clock_expired_time);
295
+		}
288 296
 
289 297
 		//Sessions  that contain the expired time
290 298
 		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
@@ -304,8 +312,10 @@  discard block
 block discarded – undo
304 312
         $learnpath_item_id,
305 313
         $learnpath_item_view_id
306 314
     );
307
-    if ($debug)  error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
308
-} else {
315
+    if ($debug) {
316
+        error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
317
+    }
318
+    } else {
309 319
 	$exe_id = $exercise_stat_info['exe_id'];
310 320
     // Remember last question id position.
311 321
     $isFirstTime = Session::read('firstTime');
@@ -327,8 +337,10 @@  discard block
 block discarded – undo
327 337
         }
328 338
     }
329 339
 
330
-    if ($debug)  error_log("5  exercise_stat_info[] exists getting exe_id $exe_id ");
331
-}
340
+    if ($debug) {
341
+        error_log("5  exercise_stat_info[] exists getting exe_id $exe_id ");
342
+    }
343
+    }
332 344
 
333 345
 $questionListInSession = Session::read('questionList');
334 346
 
@@ -384,9 +396,15 @@  discard block
 block discarded – undo
384 396
  * If the expired time is major that zero(0) then the expired time is compute on this time.
385 397
  */
386 398
 if ($time_control) {
387
-	if ($debug) error_log('7.1. Time control is enabled');
388
-	if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
389
-	if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
399
+	if ($debug) {
400
+	    error_log('7.1. Time control is enabled');
401
+	}
402
+	if ($debug) {
403
+	    error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
404
+	}
405
+	if ($debug) {
406
+	    error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
407
+	}
390 408
 
391 409
     if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
392 410
         //Timer - Get expired_time for a student
@@ -473,7 +491,9 @@  discard block
 block discarded – undo
473 491
 	}
474 492
 }
475 493
 
476
-if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
494
+if ($debug) {
495
+    error_log('8. Question list loaded '.print_r($questionList, 1));
496
+}
477 497
 
478 498
 //Real question count
479 499
 $question_count = 0;
Please login to merge, or discard this patch.