Browse Source

Format code, adding api_get_cidreq + fix documentation

jmontoyaa 8 years ago
parent
commit
ef23e1d28f

+ 1 - 0
main/exercise/export/exercise_import.inc.php

@@ -5,6 +5,7 @@
  * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE
  *
  * @package chamilo.exercise
+ * @deprecated
  *
  * @author claro team <cvs@claroline.net>
  * @author Guillaume Lederer <guillaume@claroline.net>

+ 5 - 12
main/exercise/export/exercise_import.php

@@ -4,6 +4,7 @@
  * @copyright (c) 2001-2006 Universite catholique de Louvain (UCL)
  * @package chamilo.exercise
  * @author claro team <cvs@claroline.net>
+ * @deprecated
  */
 require '../../inc/global.inc.php';
 
@@ -32,8 +33,8 @@ $interbredcrump[] = array('url' => '../exercise.php', 'name' => get_lang('Exerci
 $cmd = (isset($_REQUEST['cmd'])? $_REQUEST['cmd'] : 'show_import');
 
 switch ($cmd) {
-    case 'show_import' :
-    {
+    case 'show_import':
+
         $display = '<p>'
         .            get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.') . '<br>'
         .            '</p>'
@@ -46,22 +47,16 @@ switch ($cmd) {
         .            '<br><br>'
         .            '<small>' . get_lang('Max file size') . ' :  2&nbsp;MB</small>'
         .            '</form>';
-    }
-    break;
 
-    case 'import': {
+        break;
+    case 'import':
         //include needed librabries for treatment
-
         $result_log = import_exercise($_FILES['uploadedExercise']['name']);
-
         //display the result message (fail or success)
         $dialogBox = '';
-
         foreach ($result_log as $log) {
             $dialogBox .= $log.'<br>';
         }
-
-    }
         break;
 }
 
@@ -85,8 +80,6 @@ if (isset($dialogBox)) {
     echo Display::display_normal_message($dialogBox, false);
 }
 
-//display content
-
 if (isset($display)) {
     echo $display;
 }

+ 21 - 12
main/exercise/upload_exercise.php

@@ -1,13 +1,14 @@
 <?php
 /* For licensing terms, see /license.txt */
 
+use \ChamiloSession as Session;
+
 /**
  * 	Upload quiz: This script shows the upload quiz feature
  *  Initial work by Isaac flores on Nov 4 of 2010
  *  Encoding fixes Julio Montoya
  * 	@package chamilo.exercise
  */
-use \ChamiloSession as Session;
 
 // setting the help
 $help_content = 'exercise_upload';
@@ -70,8 +71,8 @@ function lp_upload_quiz_secondary_actions()
     return $return;
 }
 
-function lp_upload_quiz_main() {
-
+function lp_upload_quiz_main()
+{
     // variable initialisation
     $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : null;
 
@@ -112,9 +113,13 @@ function lp_upload_quiz_main() {
     $table = $table->toHtml();
 
     $form->addElement('label', get_lang('QuestionType'), $table);
-
-
-    $form->addElement('checkbox', 'user_custom_score', null, get_lang('UseCustomScoreForAllQuestions'), array('id'=> 'user_custom_score'));
+    $form->addElement(
+        'checkbox',
+        'user_custom_score',
+        null,
+        get_lang('UseCustomScoreForAllQuestions'),
+        array('id' => 'user_custom_score')
+    );
     $form->addElement('html', '<div id="options" style="display:none">');
     $form->addElement('text', 'correct_score', get_lang('CorrectScore'));
     $form->addElement('text', 'incorrect_score', get_lang('IncorrectScore'));
@@ -132,7 +137,8 @@ function lp_upload_quiz_main() {
 /**
  * Handles a given Excel spreadsheets as in the template provided
  */
-function lp_upload_quiz_action_handling() {
+function lp_upload_quiz_action_handling()
+{
     global $debug;
     $_course = api_get_course_info();
     $courseId = $_course['real_id'];
@@ -618,7 +624,7 @@ function lp_upload_quiz_action_handling() {
             // Add a Quiz as Lp Item
             $_SESSION['oLP']->add_item($parent, $previous, TOOL_QUIZ, $quiz_id, $quiz_title, '');
             // Redirect to home page for add more content
-            header('location: ../lp/lp_controller.php?'.api_get_cidreq().'&action=add_item&type=step&lp_id='.Security::remove_XSS($_GET['lp_id']));
+            header('location: ../lp/lp_controller.php?'.api_get_cidreq().'&action=add_item&type=step&lp_id='.intval($_GET['lp_id']));
             exit;
         } else {
             //  header('location: exercise.php?' . api_get_cidreq());
@@ -631,7 +637,8 @@ function lp_upload_quiz_action_handling() {
  * @param array $answers_data
  * @return int
  */
-function detectQuestionType($answers_data) {
+function detectQuestionType($answers_data)
+{
     $correct = 0;
     $isNumeric = false;
 
@@ -650,10 +657,12 @@ function detectQuestionType($answers_data) {
 
     if ($correct == 1) {
         $type = UNIQUE_ANSWER;
-    } else if ($correct > 1) {
-        $type = MULTIPLE_ANSWER;
     } else {
-        $type = FREE_ANSWER;
+        if ($correct > 1) {
+            $type = MULTIPLE_ANSWER;
+        } else {
+            $type = FREE_ANSWER;
+        }
     }
 
     if ($type == MULTIPLE_ANSWER) {

+ 6 - 6
main/lp/learnpath.class.php

@@ -84,10 +84,10 @@ class learnpath
      * Constructor.
      * Needs a database handler, a course code and a learnpath id from the database.
      * Also builds the list of items into $this->items.
-     * @param	string	$course Course code
-     * @param	integer	$lp_id
-     * @param	integer	$user_id
-     * @return mixed True on success, false on error
+     * @param   string $course Course code
+     * @param   integer $lp_id
+     * @param   integer $user_id
+     * @return  mixed True on success, false on error
      */
     public function __construct($course, $lp_id, $user_id)
     {
@@ -11029,7 +11029,7 @@ EOD;
     /**
      * Get the LP Final Item Template
      *
-     * @return html
+     * @return string
      */
     private function getFinalItemTemplate()
     {
@@ -11039,7 +11039,7 @@ EOD;
     /**
      * Get the LP Final Item Url
      *
-     * @return String
+     * @return string
      */
     private function getSavedFinalItem()
     {

+ 94 - 108
main/lp/lp_controller.php

@@ -17,7 +17,7 @@ if ($debug > 0) error_log('New LP -+- Entered lp_controller.php -+- (action: '.$
 
 // Language files that needs to be included.
 if (isset($_GET['action'])) {
-    if ($_GET['action'] == 'export') {
+    if ($_GET['action'] === 'export') {
         // Only needed on export.
         $language_file[] = 'hotspot';
     }
@@ -226,10 +226,10 @@ if (isset($_SESSION['lpobject'])) {
     $oLP = unserialize($_SESSION['lpobject']);
     if (isset($oLP) && is_object($oLP)) {
         if ($debug > 0) error_log('New LP - oLP is object', 0);
-        if ($myrefresh == 1 OR
-            empty($oLP->cc) OR
-            $oLP->cc != api_get_course_id() OR
-            $oLP->lp_view_session_id != $session_id OR
+        if ($myrefresh == 1 ||
+            empty($oLP->cc) ||
+            $oLP->cc != api_get_course_id() ||
+            $oLP->lp_view_session_id != $session_id ||
             $oLP->scorm_debug == '1'
         ) {
             if ($debug > 0) error_log('New LP - Course has changed, discard lp object', 0);
@@ -358,15 +358,14 @@ if (isset($_POST['title'])) {
     }
 }
 
-$redirectTo = null;
+$redirectTo = '';
+if ($debug > 0) error_log('New LP - action "'.$action.'" triggered');
 
 switch ($action) {
     case 'add_item':
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - add item action triggered', 0);
-
         if (!$lp_found) {
             //check if the learnpath ID was defined, otherwise send back to list
             if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
@@ -387,7 +386,7 @@ switch ($action) {
 
                     $_SESSION['post_time'] = $_POST['post_time'];
                     $directoryParentId = isset($_POST['directory_parent_id']) ? $_POST['directory_parent_id'] : 0;
-
+                    $courseInfo = api_get_course_info();
                     if (empty($directoryParentId)) {
                         $_SESSION['oLP']->generate_lp_folder($courseInfo);
                     }
@@ -457,9 +456,6 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-
-        if ($debug > 0) error_log('New LP - add audio action triggered', 0);
-
         if (!$lp_found) {
             //check if the learnpath ID was defined, otherwise send back to list
             if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0);
@@ -536,7 +532,6 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - add_lp action triggered', 0);
         if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
             $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
             $_SESSION['refresh'] = 1;
@@ -585,7 +580,6 @@ switch ($action) {
                     $accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true';
                     $_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime);
 
-                    //require 'lp_build.php';
                     $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq();
                     header("Location: $url&isStudentView=false");
                     exit;
@@ -599,7 +593,6 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - admin_view action triggered', 0);
         if (!$lp_found) {
             error_log('New LP - No learnpath given for admin_view', 0);
             require 'lp_list.php';
@@ -613,7 +606,6 @@ switch ($action) {
             if (!$is_allowed_to_edit) {
                 api_not_allowed(true);
             }
-            if ($debug > 0) error_log('New LP - auto_launch action triggered', 0);
             if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; }
             else {
                 $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
@@ -626,10 +618,10 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - build action triggered', 0);
-
-        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for build', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['refresh'] = 1;
             //require 'lp_build.php';
             $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
@@ -641,8 +633,6 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - edit item action triggered', 0);
-
         if (!$lp_found) {
             error_log('New LP - No learnpath given for edit item', 0);
             require 'lp_list.php';
@@ -698,7 +688,6 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
         if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
         else {
             if (isset($_POST['submit_button'])) {
@@ -728,9 +717,11 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - move item action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; }
-        else {
+
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for move item', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['refresh'] = 1;
             if (isset($_POST['submit_button'])) {
                 //Updating the lp.modified_on
@@ -763,7 +754,6 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - view_item action triggered', 0);
         if (!$lp_found) {
             error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
         } else {
@@ -775,7 +765,6 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - upload action triggered', 0);
         $cwdir = getcwd();
         require 'lp_upload.php';
         // Reinit current working directory as many functions in upload change it.
@@ -792,9 +781,10 @@ switch ($action) {
             api_not_allowed(true);
         }
 
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for copy', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['oLP']->copy();
         }
         require 'lp_list.php';
@@ -807,9 +797,6 @@ switch ($action) {
         if ($hideScormExportLink === 'true') {
             api_not_allowed(true);
         }
-        if ($debug > 0) {
-            error_log('New LP - export action triggered', 0);
-        }
         if (!$lp_found) {
             error_log('New LP - No learnpath given for export', 0);
             require 'lp_list.php';
@@ -827,8 +814,9 @@ switch ($action) {
             api_not_allowed(true);
         }
 
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php';
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for export_to_pdf', 0);
+            require 'lp_list.php';
         } else {
             $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
             if (!$result) {
@@ -841,11 +829,13 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - delete action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for delete', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['refresh'] = 1;
             $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
+            Display::addFlash(Display::return_message(get_lang('Deleted')));
             Session::erase('oLP');
             require 'lp_list.php';
         }
@@ -855,9 +845,11 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - visibility action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; }
-        else {
+
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for visibility', 0);
+            require 'lp_list.php';
+        } else {
             learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
             require 'lp_list.php';
         }
@@ -867,9 +859,10 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for publish', 0);
+            require 'lp_list.php';
+        } else {
             learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
             require 'lp_list.php';
         }
@@ -879,7 +872,6 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
         if (!$lp_found) {
             error_log('New LP - No learnpath given for publish', 0);
             require 'lp_list.php';
@@ -893,7 +885,6 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
         if (!$lp_found) {
             error_log('New LP - No learnpath given for publish', 0);
             require 'lp_list.php';
@@ -906,9 +897,11 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - edit action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
-        else {
+
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for edit', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['refresh'] = 1;
             require 'lp_edit.php';
         }
@@ -917,9 +910,10 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - update_lp action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for edit', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['refresh'] = 1;
             $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
             $_SESSION['oLP']->set_name($lp_name);
@@ -936,8 +930,6 @@ switch ($action) {
             }
 
             $author_fixed = substr($author, $auth_init, $len);
-            //$author_fixed = $author;
-
             $_SESSION['oLP']->set_author($author_fixed);
             // TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed.
             $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
@@ -1032,13 +1024,14 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - add sub item action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for add sub item', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['refresh'] = 1;
             if (!empty($_REQUEST['parent_item_id'])) {
-                $_SESSION['from_learnpath']='yes';
-                $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.Security::remove_XSS($_REQUEST['lp_id']);
+                $_SESSION['from_learnpath'] = 'yes';
+                $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.intval($_REQUEST['lp_id']);
                 require 'resourcelinker.php';
             } else {
                 require 'lp_admin_view.php';
@@ -1050,12 +1043,10 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - delete item action triggered', 0);
         if (!$lp_found) {
             error_log('New LP - No learnpath given for delete item', 0);
             require 'lp_list.php';
         } else {
-            //$_SESSION['refresh'] = 1;
             if (!empty($_REQUEST['id'])) {
                 $_SESSION['oLP']->delete_item($_REQUEST['id']);
             }
@@ -1069,9 +1060,10 @@ switch ($action) {
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for edit item prereq', 0);
+            require 'lp_list.php';
+        } else {
             if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
                 $_SESSION['refresh'] = 1;
                 $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
@@ -1080,47 +1072,51 @@ switch ($action) {
         }
         break;
     case 'restart':
-        if ($debug > 0) error_log('New LP - restart action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for restart', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['oLP']->restart();
             require 'lp_view.php';
         }
         break;
     case 'last':
-        if ($debug > 0) error_log('New LP - last action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for last', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['oLP']->last();
             require 'lp_view.php';
         }
         break;
     case 'first':
-        if ($debug > 0) error_log('New LP - first action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for first', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['oLP']->first();
             require 'lp_view.php';
         }
         break;
     case 'next':
-        if ($debug > 0) error_log('New LP - next action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for next', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['oLP']->next();
             require 'lp_view.php';
         }
         break;
     case 'previous':
-        if ($debug > 0) error_log('New LP - previous action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for previous', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['oLP']->previous();
             require 'lp_view.php';
         }
         break;
     case 'content':
-        if ($debug > 0) error_log('New LP - content action triggered', 0);
         if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
         if (!$lp_found) {
             error_log('New LP - No learnpath given for content', 0);
@@ -1136,8 +1132,6 @@ switch ($action) {
         }
         break;
     case 'view':
-        if ($debug > 0)
-            error_log('New LP - view action triggered', 0);
         if (!$lp_found) {
             error_log('New LP - No learnpath given for view', 0);
             require 'lp_list.php';
@@ -1150,17 +1144,19 @@ switch ($action) {
         }
         break;
     case 'save':
-        if ($debug > 0) error_log('New LP - save action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for save', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['oLP']->save_item();
             require 'lp_save.php';
         }
         break;
     case 'stats':
-        if ($debug > 0) error_log('New LP - stats action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
-        else {
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for stats', 0);
+            require 'lp_list.php';
+        } else {
             $_SESSION['oLP']->save_current();
             $_SESSION['oLP']->save_last();
             $output = require 'lp_stats.php';
@@ -1168,7 +1164,6 @@ switch ($action) {
         }
         break;
     case 'list':
-        if ($debug > 0) error_log('New LP - list action triggered', 0);
         if ($lp_found) {
             $_SESSION['refresh'] = 1;
             $_SESSION['oLP']->save_last();
@@ -1177,7 +1172,6 @@ switch ($action) {
         break;
     case 'mode':
         // Switch between fullscreen and embedded mode.
-        if ($debug > 0) error_log('New LP - mode change triggered', 0);
         $mode = $_REQUEST['mode'];
         if ($mode == 'fullscreen') {
             $_SESSION['oLP']->mode = 'fullscreen';
@@ -1191,8 +1185,11 @@ switch ($action) {
         require 'lp_view.php';
         break;
     case 'switch_view_mode':
-        if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
+
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for switch', 0);
+            require 'lp_list.php';
+        }
         if (Security::check_token('get')) {
             $_SESSION['refresh'] = 1;
             $_SESSION['oLP']->update_default_view_mode();
@@ -1200,22 +1197,22 @@ switch ($action) {
         require 'lp_list.php';
         break;
     case 'switch_force_commit':
-        if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0);
-        if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for switch', 0);
+            require 'lp_list.php';
+        }
         $_SESSION['refresh'] = 1;
         $_SESSION['oLP']->update_default_scorm_commit();
         require 'lp_list.php';
         break;
     /* Those 2 switches have been replaced by switc_attempt_mode switch
     case 'switch_reinit':
-        if ($debug > 0) error_log('New LP - switch_reinit action triggered', 0);
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
         $_SESSION['refresh'] = 1;
         $_SESSION['oLP']->update_reinit();
 		require 'lp_list.php';
 		break;
 	case 'switch_seriousgame_mode':
-		if($debug>0) error_log('New LP - switch_seriousgame_mode action triggered',0);
 		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
 		$_SESSION['refresh'] = 1;
 		$_SESSION['oLP']->set_seriousgame_mode();
@@ -1223,25 +1220,21 @@ switch ($action) {
 		break;
      */
 	case 'switch_attempt_mode':
-		if($debug>0) error_log('New LP - switch_reinit action triggered',0);
 		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
 		$_SESSION['refresh'] = 1;
 		$_SESSION['oLP']->switch_attempt_mode();
         require 'lp_list.php';
         break;
     case 'switch_scorm_debug':
-        if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0);
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
         $_SESSION['refresh'] = 1;
         $_SESSION['oLP']->update_scorm_debug();
         require 'lp_list.php';
         break;
     case 'intro_cmdAdd':
-        if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0);
         // Add introduction section page.
         break;
     case 'js_api_refresh':
-        if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0);
         if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
         if (isset($_REQUEST['item_id'])) {
             $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
@@ -1268,8 +1261,6 @@ switch ($action) {
         require 'lp_list_search.php';
         break;
     case 'impress':
-        if ($debug > 0)
-            error_log('New LP - view action triggered', 0);
         if (!$lp_found) {
             error_log('New LP - No learnpath given for view', 0);
             require 'lp_list.php';
@@ -1298,10 +1289,6 @@ switch ($action) {
             api_not_allowed(true);
         }
 
-        if ($debug > 0) {
-            error_log('New LP - seriousgame_mode action triggered');
-        }
-
         if (!$lp_found) {
             error_log('New LP - No learnpath given for visibility');
 
@@ -1443,7 +1430,6 @@ switch ($action) {
         ]);
         break;
     default:
-        if ($debug > 0) error_log('New LP - default action triggered', 0);
         require 'lp_list.php';
         break;
 }

+ 19 - 22
main/lp/lp_edit.php

@@ -27,8 +27,11 @@ if (!empty($gradebook) && $gradebook == 'view') {
         'name' => get_lang('ToolGradebook')
     );
 }
-$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
-$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=".$_SESSION['oLP']->get_id(), 'name' => $_SESSION['oLP']->get_name());
+$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list?'.api_get_cidreq(), 'name' => get_lang('LearningPaths'));
+$interbreadcrumb[] = array(
+    'url' => api_get_self()."?action=build&lp_id=".$_SESSION['oLP']->get_id().'&'.api_get_cidreq(),
+    'name' => $_SESSION['oLP']->get_name()
+);
 
 $htmlHeadXtra[] = '<script>
 function activate_start_date() {
@@ -52,7 +55,7 @@ function activate_end_date() {
 $gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : null;
 
 $defaults = array();
-$form = new FormValidator('form1', 'post', 'lp_controller.php');
+$form = new FormValidator('form1', 'post', 'lp_controller.php?'.api_get_cidreq());
 
 // Form title
 $form->addElement('header', get_lang('EditLPSettings'));
@@ -61,9 +64,7 @@ $form->addElement('header', get_lang('EditLPSettings'));
 $form->addElement('text', 'lp_name', api_ucfirst(get_lang('LearnpathTitle')), array('size' => 43));
 $form->applyFilter('lp_name', 'html_filter');
 $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required');
-
 $form->addElement('hidden', 'lp_encoding');
-
 $items = learnpath::getCategoryFromCourseIntoSelect(api_get_course_int_id(), true);
 $form->addElement('select', 'category_id', get_lang('Category'), $items);
 
@@ -75,7 +76,7 @@ $hide_toc_frame = $form->addElement(
     get_lang('HideTocFrame'),
     array('onclick' => '$("#lp_layout_column").toggle()')
 );
-if (api_get_setting('allow_course_theme') == 'true') {
+if (api_get_setting('allow_course_theme') === 'true') {
     $mycourselptheme = api_get_course_setting('allow_learning_path_theme');
     if (!empty($mycourselptheme) && $mycourselptheme!=-1 && $mycourselptheme== 1) {
         //LP theme picker
@@ -83,7 +84,7 @@ if (api_get_setting('allow_course_theme') == 'true') {
         $form->applyFilter('lp_theme', 'trim');
 
         $s_theme = $_SESSION['oLP']->get_theme();
-        $theme_select ->setSelected($s_theme); //default
+        $theme_select->setSelected($s_theme); //default
     }
 }
 
@@ -98,7 +99,6 @@ $form->addElement(
 $form->applyFilter('lp_author', 'html_filter');
 
 // LP image
-$form->add_progress_bar();
 if (strlen($_SESSION['oLP']->get_preview_image()) > 0) {
     $show_preview_image = '<img src='.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image().'>';
     $form->addElement('label', get_lang('ImagePreview'), $show_preview_image);
@@ -113,7 +113,7 @@ $form->addRule('lp_preview_image', get_lang('OnlyImagesAllowed'), 'filetype', ar
 if (api_get_setting('search_enabled') === 'true') {
     $specific_fields = get_specific_field_list();
     foreach ($specific_fields as $specific_field) {
-        $form -> addElement ('text', $specific_field['code'], $specific_field['name']);
+        $form->addElement('text', $specific_field['code'], $specific_field['name']);
         $filter = array(
             'c_id' => "'".api_get_course_int_id()."'",
             'field_id' => $specific_field['id'],
@@ -142,11 +142,11 @@ $expired_on = $_SESSION['oLP']->expired_on;
 $publicated_on = $_SESSION['oLP']->publicated_on;
 
 // Prerequisites
-$form->addElement('html','<div class="form-group">');
+$form->addElement('html', '<div class="form-group">');
 $items = $_SESSION['oLP']->display_lp_prerequisites_list();
-$form->addElement('html','<label class="col-md-2">'.get_lang('LearnpathPrerequisites').'</label>');
-$form->addElement('html','<div class="col-md-10">');
-$form->addElement('html',$items);
+$form->addElement('html', '<label class="col-md-2">'.get_lang('LearnpathPrerequisites').'</label>');
+$form->addElement('html', '<div class="col-md-10">');
+$form->addElement('html', $items);
 $form->addElement('html', '<div class="help-block">'.get_lang('LpPrerequisiteDescription').'</div></div></div>');
 
 //Start date
@@ -160,13 +160,13 @@ $form->addElement(
 
 $display_date = 'none';
 if (!empty($publicated_on)) {
-	$display_date = 'block';
-	$defaults['activate_start_date_check'] = 1;
+    $display_date = 'block';
+    $defaults['activate_start_date_check'] = 1;
 }
 
-$form->addElement('html','<div id="start_date_div" style="display:'.$display_date.';">');
+$form->addElement('html', '<div id="start_date_div" style="display:'.$display_date.';">');
 $form->addDatePicker('publicated_on', get_lang('PublicationDate'));
-$form->addElement('html','</div>');
+$form->addElement('html', '</div>');
 
 //End date
 $form->addElement(
@@ -182,9 +182,9 @@ if (!empty($expired_on)) {
 	$defaults['activate_end_date_check'] = 1;
 }
 
-$form->addElement('html','<div id="end_date_div" style="display:'.$display_date.';">');
+$form->addElement('html', '<div id="end_date_div" style="display:'.$display_date.';">');
 $form->addDatePicker('expired_on', get_lang('ExpirationDate'));
-$form->addElement('html','</div>');
+$form->addElement('html', '</div>');
 
 if (api_is_platform_admin()) {
     $form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100'));
@@ -201,7 +201,6 @@ $form->addElement(
 );
 
 $enableLpExtraFields = false;
-
 if ($enableLpExtraFields) {
     $extraField = new ExtraField('lp');
     $extra = $extraField->addElements($form, $_SESSION['oLP']->get_id());
@@ -231,9 +230,7 @@ $form->setDefaults($defaults);
 Display::display_header(get_lang('CourseSettings'), 'Path');
 
 echo $_SESSION['oLP']->build_action_menu(false, false, true, false);
-
 echo '<div class="row">';
-
 if ($_SESSION['oLP']->get_hide_toc_frame() == 1) {
     echo '<div class="col-md-12">';
     $form -> display();

+ 1 - 2
main/upload/upload.scorm.php

@@ -36,7 +36,6 @@ if (api_get_setting('search_enabled') === 'true') {
         }
     }
 }
-//Display::addFlash(Display::return_message(get_lang('UplUploadSucceeded')));
 
-header('location: ../lp/lp_controller.php?action=list');
+header('location: ../lp/lp_controller.php?action=list?'.api_get_cidreq());
 exit;