Browse Source

Merge branch '1.10.x' of https://github.com/chamilo/chamilo-lms into 1.10.x

Angel Fernando Quiroz Campos 9 years ago
parent
commit
43c1b755be

+ 6 - 7
main/document/create_document.php

@@ -22,12 +22,11 @@ var hide_bar = function() {
 }
 
 $(document).ready(function() {
-    $(".scrollbar-macosx").scrollbar();
+    $(".scrollbar-light").scrollbar();
 
     if ($(window).width() <= 785 ) {
         hide_bar();
-    }
-    
+    }    
 
     $("#hide_bar_template").click(function() {
         
@@ -445,7 +444,7 @@ if ($form->validate()) {
 	$values = $form->exportValues();
 	$readonly = isset($values['readonly']) ? 1 : 0;
 	$values['title'] = trim($values['title']);
-    
+
     if (!empty($values['dirValue'])) {
         $dir = $values['dirValue'];
     }
@@ -617,9 +616,9 @@ if ($form->validate()) {
 		$actionsLeft = '<a href="document.php?curdirpath='.Security::remove_XSS($dir).'">'.
             Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
         }
-        
+
         echo $toolbar = Display::toolbarAction('actions-documents', array(0 => $actionsLeft, 1 => ''));
-                
+
 
 	if ($is_certificate_mode) {
 		$all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id());
@@ -636,7 +635,7 @@ if ($form->validate()) {
             <div id="template_col" class="col-md-2">
                 <div class="panel panel-default">
                 <div class="panel-body">
-                    <div id="frmModel" class="items-templates scrollbar-macosx"></div>
+                    <div id="frmModel" class="items-templates scrollbar-light"></div>
                 </div>
                 </div>
             </div>

+ 2 - 2
main/document/edit_document.php

@@ -38,7 +38,7 @@ var hide_bar = function() {
 }
 
 $(document).ready(function() {
-    $(".scrollbar-macosx").scrollbar();
+    $(".scrollbar-light").scrollbar();
 
     if ($(window).width() <= 785 ) {
         hide_bar();
@@ -537,7 +537,7 @@ if ($owner_id == api_get_user_id() ||
             <div id="template_col" class="col-md-2">
                 <div class="panel panel-default">
                 <div class="panel-body">
-                    <div id="frmModel" class="items-templates scrollbar-macosx"></div>
+                    <div id="frmModel" class="items-templates scrollbar-light"></div>
                 </div>
                 </div>
             </div>

+ 3 - 2
main/exercice/exercise.class.php

@@ -132,6 +132,7 @@ class Exercise
 
         $id  = intval($id);
         if (empty($this->course_id)) {
+
             return false;
         }
         $sql = "SELECT * FROM $TBL_EXERCISES WHERE c_id = ".$this->course_id." AND id = ".$id;
@@ -5797,10 +5798,10 @@ class Exercise
      */
     private function setMediaList($questionList)
     {
-        $mediaList= array();
+        $mediaList = array();
         if (!empty($questionList)) {
             foreach ($questionList as $questionId) {
-                $objQuestionTmp = Question::read($questionId);
+                $objQuestionTmp = Question::read($questionId, $this->course_id);
 
                 // If a media question exists
                 if (isset($objQuestionTmp->parent_id) && $objQuestionTmp->parent_id != 0) {

+ 8 - 6
main/gradebook/lib/GradebookUtils.php

@@ -369,11 +369,12 @@ class GradebookUtils
 
     /**
      * Checks if a resource is in the unique gradebook of a given course
-     * @param    string  Course code
-     * @param    int     Resource type (use constants defined in linkfactory.class.php)
-     * @param    int     Resource ID in the corresponding tool
-     * @param    int     Session ID (optional -  0 if not defined)
-     * @return   int     false on error or array of resource
+     * @param    string  $course_code Course code
+     * @param    int     $resource_type Resource type (use constants defined in linkfactory.class.php)
+     * @param    int     $resource_id Resource ID in the corresponding tool
+     * @param    int     $session_id Session ID (optional -  0 if not defined)
+     *
+     * @return   array     false on error or array of resource
      */
     public static function is_resource_in_course_gradebook($course_code, $resource_type, $resource_id, $session_id = 0)
     {
@@ -390,6 +391,7 @@ class GradebookUtils
             return false;
         }
         $row = Database::fetch_array($res, 'ASSOC');
+        
         return $row;
     }
 
@@ -769,7 +771,7 @@ class GradebookUtils
                 $row = Database::fetch_array($res);
                 $category_id = $row['id'];
             }
-            
+
             return $category_id;
         }
 

+ 2 - 1
main/gradebook/lib/be/category.class.php

@@ -897,6 +897,8 @@ class Category implements GradebookItem
             if (!empty($cats)) {
                 /** @var Category $cat */
                 foreach ($cats as $cat) {
+                    $cat->set_session_id($session_id);
+                    $cat->set_course_code($course_code);
                     $cat->setStudentList($this->getStudentList());
                     $score = $cat->calc_score(
                         $stud_id,
@@ -2299,5 +2301,4 @@ class Category implements GradebookItem
     {
         $this->studentList = $list;
     }
-
 }

+ 7 - 6
main/gradebook/lib/be/exerciselink.class.php

@@ -173,7 +173,8 @@ class ExerciseLink extends AbstractLink
                     exe_exo_id   = ".(int)$this->get_ref_id();
         $result = Database::query($sql);
         $number=Database::fetch_row($result);
-        return ($number[0] != 0);
+
+        return $number[0] != 0;
     }
 
     /**
@@ -192,7 +193,7 @@ class ExerciseLink extends AbstractLink
 
         /* the following query should be similar (in conditions) to the one used
         in exercice/exercice.php, look for note-query-exe-results marker*/
-        $session_id = api_get_session_id();
+        $session_id = $this->get_session_id();
         $courseId = $this->getCourseId();
 	    $exercise = new Exercise($courseId);
         $exercise->read($this->get_ref_id());
@@ -207,8 +208,8 @@ class ExerciseLink extends AbstractLink
 			            orig_lp_item_id = 0 AND
 			            status <> 'incomplete' AND
 			            session_id = $session_id AND
-                                    c_id = $courseId 
-                                ";
+                        c_id = $courseId 
+                    ";
 		    } else {
 		        $lpId = null;
 		        if (!empty($exercise->lpList)) {
@@ -223,8 +224,8 @@ class ExerciseLink extends AbstractLink
 		                    orig_lp_id = $lpId AND
 		                    status <> 'incomplete' AND
 		                    session_id = $session_id AND
-                                    c_id = $courseId 
-                                ";
+                            c_id = $courseId 
+                        ";
 		    }
 
             if (!empty($stud_id) && $type != 'ranking') {

+ 1 - 1
main/gradebook/lib/fe/resulttable.class.php

@@ -166,7 +166,7 @@ class ResultTable extends SortableTable
 
 			if ($doc_url != null) {
 				$edit_column .= '&nbsp;<a href="'. $doc_url . '" target="_blank">';
-				$edit_column .= Display::return_icon('link.gif', get_lang('OpenDocument').'</a>';
+				$edit_column .= Display::return_icon('link.gif', get_lang('OpenDocument')).'</a>';
 			}
 		}
 

+ 9 - 0
main/inc/lib/api.lib.php

@@ -8046,6 +8046,15 @@ function api_mail_html(
     // Send the mail message.
     if (!$mail->Send()) {
         error_log('ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />');
+        if ($mail->SMTPDebug) {
+            error_log(
+                "Connection details :: " .
+                "Protocol: " . $mail->Mailer . ' :: ' .
+                "Host/Port: " . $mail->Host . ':' . $mail->Port . ' :: ' .
+                "Authent/Open: " . ($mail->SMTPAuth?'Authent':'Open') . ' :: ' .
+                ($mail->SMTPAuth?"  User/Pass: " . $mail->Username . ':' . $mail->Password:'')
+            );
+        }
         return 0;
     }
 

+ 1 - 3
main/inc/lib/pear/Pager/Sliding.php

@@ -49,8 +49,6 @@
  */
 class Pager_Sliding extends Pager_Common
 {
-    // {{{ Pager_Sliding()
-
     /**
      * Constructor
      *
@@ -58,7 +56,7 @@ class Pager_Sliding extends Pager_Common
      *
      * @access public
      */
-    function Pager_Sliding($options = array())
+    public function __construct($options = array())
     {
         //set default Pager_Sliding options
         $this->_delta                 = 2;

+ 1 - 3
main/inc/lib/sessionmanager.lib.php

@@ -1255,9 +1255,7 @@ class SessionManager
             $result = Database::query($sql);
             $session = Database::fetch_assoc($result);
 
-            //We are not using this becaouse the range its to small and no other date match the condition of this function
-            //$clicks = Tracking::get_total_clicks($info['user_id'], $courseId, $sessionId, $info['login_course_date'], $info['logout_course_date']);
-            #building array to display
+            // building array to display
             $return[] = array(
                 'user_id' => $info['user_id'],
                 'logindate' => $info['login_course_date'],

+ 1 - 2
main/inc/lib/tracking.lib.php

@@ -1419,7 +1419,6 @@ class Tracking
         }
 
         $sql .= $condition_user;
-
         $rs = Database::query($sql);
     	$row = Database::fetch_array($rs);
 
@@ -2761,7 +2760,7 @@ class Tracking
      */
     public static function get_time_spent_in_lp($student_id, $course_code, $lp_ids = array(), $session_id = null)
     {
-        $course = CourseManager :: get_course_information($course_code);
+        $course = api_get_course_info($course_code);
         $student_id = intval($student_id);
         $total_time = 0;
 

+ 2 - 1
main/inc/lib/usergroup.lib.php

@@ -971,7 +971,8 @@ class UserGroup extends Model
                 if ($picture) {
                     $params = array(
                         'id' => $id,
-                        'picture' => $picture
+                        'picture' => $picture,
+                        'group_type' => $params['group_type']
                     );
                     $this->update($params);
                 }

+ 68 - 67
main/inc/local.inc.php

@@ -839,8 +839,69 @@ if (isset($uidReset) && $uidReset) {
     $is_allowedCreateCourse = isset($_SESSION['is_allowedCreateCourse']) ? $_SESSION['is_allowedCreateCourse'] : false;
 }
 
-/*  COURSE INIT */
 
+if (!isset($_SESSION['login_as'])) {
+    $save_course_access = true;
+    $_course = Session::read('_course');
+    if ($_course && isset($_course['real_id'])) {
+        // The value  $_dont_save_user_course_access should be added before the call of global.inc.php see the main/inc/chat.ajax.php file
+        // Disables the updates in the TRACK_E_COURSE_ACCESS table
+        if (isset($_dont_save_user_course_access) && $_dont_save_user_course_access == true) {
+            $save_course_access = false;
+        }
+
+        if ($save_course_access) {
+            $course_tracking_table = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
+
+            /*
+            * When $_configuration['session_lifetime'] is too big 100 hours (in order to let users take exercises with no problems)
+            * the function Tracking::get_time_spent_on_the_course() returns big values (200h) due the condition:
+            * login_course_date > now() - INTERVAL $session_lifetime SECOND
+            *
+            */
+            /*
+            if (isset($_configuration['session_lifetime'])) {
+                $session_lifetime    = $_configuration['session_lifetime'];
+            } else {
+                $session_lifetime    = 3600; // 1 hour
+            }*/
+
+            $session_lifetime = 3600; // 1 hour
+            $time = api_get_utc_datetime();
+            if (isset($_user['user_id']) && !empty($_user['user_id'])) {
+
+                //We select the last record for the current course in the course tracking table
+                //But only if the login date is < than now + max_life_time
+                $sql = "SELECT course_access_id
+                        FROM $course_tracking_table
+                        WHERE
+                            user_id = ".intval($_user['user_id'])." AND
+                            c_id = ".$_course['real_id']."  AND
+                            session_id  = ".api_get_session_id()." AND
+                            login_course_date > '$time' - INTERVAL $session_lifetime SECOND
+                        ORDER BY login_course_date DESC LIMIT 0,1";
+                $result = Database::query($sql);
+                if (Database::num_rows($result) > 0) {
+                    $i_course_access_id = Database::result($result, 0, 0);
+                    // We update the course tracking table
+                    $sql = "UPDATE $course_tracking_table  
+                            SET logout_course_date = '$time', counter = counter+1
+                            WHERE 
+                                course_access_id = ".intval($i_course_access_id)." AND 
+                                session_id = ".api_get_session_id();
+                    Database::query($sql);
+                } else {
+                    $ip = api_get_real_ip();
+                    $sql = "INSERT INTO $course_tracking_table (c_id, user_ip, user_id, login_course_date, logout_course_date, counter, session_id)
+                            VALUES('".$_course['real_id']."', '".$ip."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')";
+                    Database::query($sql);
+                }
+            }
+        }
+    }
+}
+
+/*  COURSE INIT */
 if (isset($cidReset) && $cidReset) {
     // Course session data refresh requested or empty data
     if ($cidReq) {
@@ -948,7 +1009,6 @@ if (isset($cidReset) && $cidReset) {
         $_cid = -1; // Set default values
         $_course = -1;
     } else {
-
         $_cid = $_SESSION['_cid'];
         $_course = $_SESSION['_course'];
 
@@ -979,65 +1039,6 @@ if (isset($cidReset) && $cidReset) {
                 Session::write('_gid', $_gid);
             }
         }
-
-        if (!isset($_SESSION['login_as'])) {
-            $save_course_access = true;
-
-            //The value  $_dont_save_user_course_access should be added before the call of global.inc.php see the main/inc/chat.ajax.php file
-            //Disables the updates in the TRACK_E_COURSE_ACCESS table
-            if (isset($_dont_save_user_course_access) && $_dont_save_user_course_access == true) {
-                $save_course_access = false;
-            }
-
-            if ($save_course_access) {
-                $course_tracking_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
-
-                /*
-                * When $_configuration['session_lifetime'] is too big 100 hours (in order to let users take exercises with no problems)
-                * the function Tracking::get_time_spent_on_the_course() returns big values (200h) due the condition:
-                * login_course_date > now() - INTERVAL $session_lifetime SECOND
-                *
-                */
-                /*
-                if (isset($_configuration['session_lifetime'])) {
-                    $session_lifetime    = $_configuration['session_lifetime'];
-                } else {
-                    $session_lifetime    = 3600; // 1 hour
-                }*/
-
-                $session_lifetime    = 3600; // 1 hour
-
-                $course_code = $_course['sysCode'];
-                $time = api_get_utc_datetime();
-
-                if (isset($_user['user_id']) && !empty($_user['user_id'])) {
-
-                    //We select the last record for the current course in the course tracking table
-                    //But only if the login date is < than now + max_life_time
-                    $sql = "SELECT course_access_id
-                            FROM $course_tracking_table
-                            WHERE
-                                user_id = ".intval($_user['user_id'])." AND
-                                c_id = ".$_course['real_id']."  AND
-                                session_id  = ".api_get_session_id()." AND
-                                login_course_date > '$time' - INTERVAL $session_lifetime SECOND
-                            ORDER BY login_course_date DESC LIMIT 0,1";
-                    $result = Database::query($sql);
-                    if (Database::num_rows($result) > 0) {
-                        $i_course_access_id = Database::result($result, 0, 0);
-                        //We update the course tracking table
-                        $sql = "UPDATE $course_tracking_table  SET logout_course_date = '$time', counter = counter+1
-                                WHERE course_access_id = ".intval($i_course_access_id)." AND session_id = ".api_get_session_id();
-                        Database::query($sql);
-                    } else {
-                        $ip = api_get_real_ip();
-                        $sql="INSERT INTO $course_tracking_table (c_id, user_ip, user_id, login_course_date, logout_course_date, counter, session_id)" .
-                            "VALUES('".$_course['real_id']."', '".$ip."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')";
-                        Database::query($sql);
-                    }
-                }
-            }
-        }
     }
 }
 
@@ -1053,12 +1054,12 @@ $is_courseTutor     = false; //course teacher - some rights
 $is_courseMember    = false; //course student
 $is_courseCoach     = false; //course coach
 */
-//Course - User permissions
-$is_sessionAdmin    = false;
-$is_courseCoach     = false; //course coach
-$is_courseAdmin     = false;
-$is_courseTutor     = false;
-$is_courseMember    = false;
+// Course - User permissions
+$is_sessionAdmin = false;
+$is_courseCoach = false; //course coach
+$is_courseAdmin = false;
+$is_courseTutor = false;
+$is_courseMember = false;
 
 if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) {
     if (isset($_cid) && $_cid) {

+ 184 - 131
main/mySpace/myStudents.php

@@ -35,6 +35,10 @@ function show_image(image,width,height) {
 $export = isset($_GET['export']) ? $_GET['export'] : false;
 $sessionId = isset($_GET['id_session']) ? intval($_GET['id_session']) : 0;
 $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
+$course_code = isset($_GET['course']) ? Security :: remove_XSS($_GET['course']) : null;
+
+// time spent on the course
+$courseInfo = api_get_course_info($course_code);
 
 if (empty($sessionId)) {
     $sessionId = api_get_session_id();
@@ -54,29 +58,24 @@ if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
 }
 
 $nameTools = get_lang('StudentDetails');
-
-$get_course_code = isset($_GET['course']) ? Security :: remove_XSS($_GET['course']) : '';
-
 $em = Database::getManager();
 
 if (isset($_GET['details'])) {
     if ($origin == 'user_course') {
-        $course_info = CourseManager :: get_course_information($get_course_code);
         if (empty ($cidReq)) {
             $interbreadcrumb[] = array (
-                "url" => api_get_path(WEB_COURSE_PATH) . $course_info['directory'],
-                'name' => $course_info['title']
+                "url" => api_get_path(WEB_COURSE_PATH) . $courseInfo['directory'],
+                'name' => $courseInfo['title']
             );
         }
         $interbreadcrumb[] = array (
-            "url" => "../user/user.php?cidReq=" . $get_course_code,
+            "url" => "../user/user.php?cidReq=" . $course_code,
             "name" => get_lang("Users")
         );
     } else
         if ($origin == 'tracking_course') {
-            $course_info = CourseManager :: get_course_information($get_course_code);
             $interbreadcrumb[] = array (
-                "url" => "../tracking/courseLog.php?cidReq=".$get_course_code.'&id_session=' . api_get_session_id(),
+                "url" => "../tracking/courseLog.php?cidReq=".$course_code.'&id_session=' . api_get_session_id(),
                 "name" => get_lang("Tracking")
             );
         } else
@@ -171,19 +170,16 @@ $check = Security::check_token('get');
 if ($check) {
     switch ($_GET['action']) {
         case 'reset_lp':
-            $course = isset($_GET['course']) ? $_GET['course'] : "";
             $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : "";
 
             if (api_is_allowed_to_edit() &&
-                !empty($course) &&
                 !empty($lp_id) &&
                 !empty($student_id)
             ) {
-                $course_info = api_get_course_info($course);
                 Event::delete_student_lp_events(
                     $student_id,
                     $lp_id,
-                    $course_info,
+                    $courseInfo,
                     $sessionId
                 );
 
@@ -256,13 +252,14 @@ while ($row = Database :: fetch_array($rs)) {
     }
 }
 
+
 // Get the list of sessions where the user is subscribed as student
 $sql = 'SELECT session_id, c_id
         FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).'
         WHERE user_id=' . intval($user_info['user_id']);
 $rs = Database::query($sql);
 $tmp_sessions = array();
-while ($row = Database :: fetch_array($rs)) {
+while ($row = Database :: fetch_array($rs, 'ASSOC')) {
     $tmp_sessions[] = $row['session_id'];
     if ($drh_can_access_all_courses) {
         if (in_array($row['session_id'], $tmp_sessions)) {
@@ -276,6 +273,8 @@ while ($row = Database :: fetch_array($rs)) {
         }
     }
 }
+
+
 $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
     api_get_user_id(),
     api_get_course_info()
@@ -355,7 +354,6 @@ if (!empty($student_id)) {
 
     // get average of score and average of progress by student
     $avg_student_progress = $avg_student_score = 0;
-    $course_code = isset($_GET['course']) ? Security :: remove_XSS($_GET['course']) : null;
 
     if (CourseManager :: is_user_subscribed_in_course($user_info['user_id'], $course_code, true)) {
 
@@ -377,9 +375,6 @@ if (!empty($student_id)) {
 
     $avg_student_progress = round($avg_student_progress, 2);
 
-    // time spent on the course
-    $courseInfo = api_get_course_info($course_code);
-
     $time_spent_on_the_course = 0;
     if (!empty($courseInfo)) {
         $time_spent_on_the_course = api_time_to_hms(
@@ -438,39 +433,35 @@ if (!empty($student_id)) {
         $avg_student_score
     );
 
-    //Show title
-    $info_course = CourseManager :: get_course_information($course_code);
     $coachs_name  = '';
     $session_name = '';
-    $nb_login = Tracking :: count_login_per_student($user_info['user_id'], $info_course['real_id']);
+    //$nb_login = Tracking :: count_login_per_student($user_info['user_id'], $courseInfo['real_id']);
     //get coach and session_name if there is one and if session_mode is activated
-    if ($sessionId > 0) {
+    /*if ($sessionId > 0) {
         $session_info  = api_get_session_info($sessionId);
         $session_coach_id = $session_info['session_admin_id'];
-        $course_coachs = api_get_coachs_from_course($sessionId, $info_course['real_id']);
-        $nb_login = '';
+        $course_coachs = api_get_coachs_from_course($sessionId, $courseInfo['real_id']);
+      //  $nb_login = '';
         if (!empty($course_coachs)) {
             $info_tutor_name = array();
             foreach ($course_coachs as $course_coach) {
                 $info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
             }
-            $info_course['tutor_name'] = implode(",",$info_tutor_name);
+            $courseInfo['tutor_name'] = implode(",", $info_tutor_name);
         } elseif ($session_coach_id != 0) {
             $session_coach_id = intval($session_info['id_coach']);
             $coach_info = api_get_user_info($session_coach_id);
-            $info_course['tutor_name'] = $coach_info['complete_name'];
+            $courseInfo['tutor_name'] = $coach_info['complete_name'];
         }
-        $coachs_name  = $info_course['tutor_name'];
+        $coachs_name  = $courseInfo['tutor_name'];
         $session_name = $session_info['name'];
-    } // end
+    } // end*/
 
-    $info_course  = CourseManager :: get_course_information($get_course_code);
     $table_title = Display::return_icon('user.png', get_lang('User'), array(), ICON_SIZE_SMALL).$user_info['complete_name'];
 
     echo Display::page_subheader($table_title);
 
     $userPicture = UserManager::getUserPicture($user_info['user_id']);
-
     $userGroupManager = new UserGroup();
     $userGroups = $userGroupManager->getUserGroupListByUser($user_info['user_id'], UserGroup::NORMAL_CLASS);
     ?>
@@ -573,14 +564,21 @@ if (!empty($student_id)) {
                         echo get_lang('Score').' ';
                         Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?>
                     </td>
-                    <td align="left"><?php if (is_numeric($avg_student_score)) { echo $avg_student_score.'%';} else { echo $avg_student_score ;}  ?></td>
+                    <td align="left"><?php
+                        if (is_numeric($avg_student_score)) {
+                            echo $avg_student_score.'%';
+                        } else {
+                            echo $avg_student_score;
+                        }
+                        ?>
+                    </td>
                 </tr>
                 <?php
-                if (!empty($nb_login)) {
+                /*if (!empty($nb_login)) {
                     echo '<tr><td align="right">'.get_lang('CountToolAccess').'</td>';
                     echo '<td align="left"> '.$nb_login.'</td>';
                     echo '</tr>';
-                }
+                }*/
             } ?>
             </tbody>
         </table>
@@ -604,56 +602,51 @@ if (!empty($student_id)) {
     </div>
     <?php
 
-    $table_title = '';
+    /*$table_title = '';
     if (!empty($sessionId)) {
         $session_name = api_get_session_name($sessionId);
-        $table_title  = $session_name ? Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.' ':'';
+        $table_title = $session_name ? Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.' ':'';
     }
-    if (!empty($info_course['title'])) {
-        $table_title .= $info_course ? Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$info_course['title'].'  ':'';
+    if (!empty($courseInfo['title'])) {
+        $table_title .= $courseInfo ? Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$courseInfo['title'].'  ':'';
     }
 
-    echo Display::page_subheader($table_title);
+    echo Display::page_subheader($table_title);*/
 
     if (empty($_GET['details'])) {
         $csv_content[] = array();
         $csv_content[] = array(
-            get_lang('Session', ''),
-            get_lang('Course', ''),
-            get_lang('Time', ''),
-            get_lang('Progress', ''),
-            get_lang('Score', ''),
-            get_lang('AttendancesFaults', ''),
+            get_lang('Session'),
+            get_lang('Course'),
+            get_lang('Time'),
+            get_lang('Progress'),
+            get_lang('Score'),
+            get_lang('AttendancesFaults'),
             get_lang('Evaluations')
         );
 
         $attendance = new Attendance();
+        foreach ($courses_in_session as $sessionId => $courses) {
+            $session_name = '';
+            $access_start_date = '';
+            $access_end_date = '';
+            $date_session = '';
+            $title = Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_SMALL).' '.get_lang('Courses');
 
-        foreach ($courses_in_session as $key => $courses) {
-            $sessionId = $key;
             $session_info = api_get_session_info($sessionId);
-            $session_name = '';
             if ($session_info) {
                 $session_name = $session_info['name'];
-            }
-            $access_start_date = '';
+                if (!empty($session_info['access_start_date']) && $session_info['access_start_date'] != '0000-00-00') {
+                    $access_start_date = api_format_date($session_info['access_start_date'], DATE_FORMAT_SHORT);
+                }
 
-            if (!empty($session_info['access_start_date']) && $session_info['access_start_date'] != '0000-00-00') {
-                $access_start_date = api_format_date($session_info['access_start_date'], DATE_FORMAT_SHORT);
-            }
+                if (!empty($session_info['access_end_date']) && $session_info['access_end_date'] != '0000-00-00') {
+                    $access_end_date = api_format_date($session_info['access_end_date'], DATE_FORMAT_SHORT);
+                }
 
-            $access_end_date = '';
-            if (!empty($session_info['access_end_date']) && $session_info['access_end_date'] != '0000-00-00') {
-                $access_end_date = api_format_date($session_info['access_end_date'], DATE_FORMAT_SHORT);
-            }
-            $date_session = '';
-            if (!empty($access_start_date) && !empty($access_end_date)) {
-                $date_session = get_lang('From') . ' ' . $access_start_date . ' ' . get_lang('Until') . ' ' . $access_end_date;
-            }
-            $title = '';
-            if (empty($sessionId)) {
-                $title = Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_SMALL).' '.get_lang('Courses');
-            } else {
+                if (!empty($access_start_date) && !empty($access_end_date)) {
+                    $date_session = get_lang('From') . ' ' . $access_start_date . ' ' . get_lang('Until') . ' ' . $access_end_date;
+                }
                 $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session?' ('.$date_session.')':'');
             }
 
@@ -676,62 +669,61 @@ if (!empty($student_id)) {
 
             if (!empty($courses)) {
                 foreach ($courses as $courseId) {
-                    $courseInfo = api_get_course_info_by_id($courseId);
-                    $courseId = $courseInfo['real_id'];
-                    $course_code = $courseInfo['code'];
-
-                    if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
-                        $course_info = CourseManager :: get_course_information($course_code);
+                    $courseInfoItem = api_get_course_info_by_id($courseId);
+                    $courseId = $courseInfoItem['real_id'];
+                    $courseCodeItem = $courseInfoItem['code'];
 
+                    if (CourseManager :: is_user_subscribed_in_course($student_id, $courseCodeItem, true)) {
                         $time_spent_on_course = api_time_to_hms(
                             Tracking :: get_time_spent_on_the_course($user_info['user_id'], $courseId, $sessionId)
                         );
 
                         // get average of faults in attendances by student
-                        $results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code, $sessionId);
+                        $results_faults_avg = $attendance->get_faults_average_by_course($student_id, $courseCodeItem, $sessionId);
                         if (!empty($results_faults_avg['total'])) {
                             if (api_is_drh()) {
-                                $attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&id_session='.$sessionId.'&student_id='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
+                                $attendances_faults_avg =
+                                    '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sessionId.'&student_id='.$student_id.'">'.
+                                    $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
                             } else {
-                                $attendances_faults_avg = $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)';
+                                $attendances_faults_avg =
+                                    $results_faults_avg['faults'].'/'.
+                                    $results_faults_avg['total'].
+                                    ' ('.$results_faults_avg['porcent'].'%)'
+                                ;
                             }
                         } else {
                             $attendances_faults_avg = '0/0 (0%)';
                         }
 
                         // Get evaluations by student
-                        $cats = Category::load(null, null, $course_code, null, null, $sessionId);
+                        $cats = Category::load(null, null, $courseCodeItem, null, null, $sessionId);
 
                         $scoretotal = array();
                         if (isset($cats) && isset($cats[0])) {
                             if (!empty($sessionId)) {
-                                $scoretotal= $cats[0]->calc_score($student_id, null, $course_code, $sessionId);
+                                $scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem, $sessionId);
                             } else {
-                                $scoretotal= $cats[0]->calc_score($student_id, null, $course_code);
+                                $scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem);
                             }
                         }
 
                         $scoretotal_display = '0/0 (0%)';
                         if (!empty($scoretotal)) {
-                            $scoretotal_display = round(
-                                    $scoretotal[0],
-                                    1
-                                ).'/'.
-                                round(
-                                    $scoretotal[1],
-                                    1
-                                ).' ('.
-                                round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)';
+                            $scoretotal_display =
+                                round($scoretotal[0], 1 ).'/'.
+                                round($scoretotal[1], 1).
+                                ' ('.round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)';
                         }
 
-                        $progress = Tracking::get_avg_student_progress($user_info['user_id'], $course_code, null, $sessionId);
-                        $score = Tracking :: get_avg_student_score($user_info['user_id'], $course_code, null, $sessionId);
+                        $progress = Tracking::get_avg_student_progress($user_info['user_id'], $courseCodeItem, null, $sessionId);
+                        $score = Tracking :: get_avg_student_score($user_info['user_id'], $courseCodeItem, null, $sessionId);
                         $progress = empty($progress) ? '0%' : $progress.'%';
                         $score = empty($score) ? '0%' : $score.'%';
 
                         $csv_content[] = array(
                             $session_name,
-                            $course_info['title'],
+                            $courseInfoItem['title'],
                             $time_spent_on_course,
                             $progress,
                             $score,
@@ -740,7 +732,8 @@ if (!empty($student_id)) {
                         );
 
                         echo '<tr>
-                        <td ><a href="' . api_get_path(WEB_COURSE_PATH) . $course_info['directory'] .'/?id_session=' . $sessionId . '">'.$course_info['title'].'</a></td>
+                        <td ><a href="' .$courseInfoItem['course_public_url'] .'?id_session=' . $sessionId . '">'.
+                            $courseInfoItem['title'].'</a></td>
                         <td >'.$time_spent_on_course .'</td>
                         <td >'.$progress.'</td>
                         <td >'.$score.'</td>
@@ -748,10 +741,10 @@ if (!empty($student_id)) {
                         <td >'.$scoretotal_display.'</td>';
 
                         if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
-                            echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$course_info['code'].'&id_coach='.Security::remove_XSS($_GET['id_coach']).'&origin='.$origin.'&id_session='.$sessionId.'#infosStudent">
+                            echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&id_coach='.Security::remove_XSS($_GET['id_coach']).'&origin='.$origin.'&id_session='.$sessionId.'#infosStudent">
                             '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
                         } else {
-                            echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$course_info['code'].'&origin='.$origin.'&id_session='.$sessionId.'#infosStudent">
+                            echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&origin='.$origin.'&id_session='.$sessionId.'#infosStudent">
                             '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
                         }
                         echo '</tr>';
@@ -781,25 +774,29 @@ if (!empty($student_id)) {
                 get_lang('LastConnexion')
             );
 
-            $query = $em
-                ->createQuery('
+            if (empty($sessionId)) {
+                $query = $em->createQuery('
                     SELECT lp FROM ChamiloCourseBundle:CLp lp
-                    WHERE lp.sessionId = :session AND lp.cId = :course
+                    WHERE lp.sessionId = 0 AND lp.cId = :course
                     ORDER BY lp.displayOrder ASC
                 ');
 
-            if (empty($sessionId)) {
                 $query->setParameters([
-                    'session' => 0,
-                    'course' => $info_course['real_id']
+                    'course' => $courseInfo['real_id']
                 ]);
             } else {
+                $query = $em->createQuery('
+                    SELECT lp FROM ChamiloCourseBundle:CLp lp
+                    WHERE lp.cId = :course
+                    ORDER BY lp.displayOrder ASC
+                ');
                 $query->setParameters([
-                    'session' => $sessionId,
-                    'course' => $info_course['real_id']
+                    'course' => $courseInfo['real_id']
                 ]);
             }
+
             $rs_lp = $query->getResult();
+
             if (count($rs_lp) > 0) {
                 ?>
                 <!-- LPs-->
@@ -807,22 +804,54 @@ if (!empty($student_id)) {
                 <table class="table table-striped table-hover">
                 <thead>
                 <tr>
-                    <th><?php echo get_lang('Learnpaths');?></th>
-                    <th><?php
+                    <th><?php echo get_lang('LearningPath');?></th>
+                    <th>
+                        <?php
                         echo get_lang('Time').' ';
-                        Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?></th>
-                    <th><?php
+                        Display:: display_icon(
+                            'info3.gif',
+                            get_lang('TotalTimeByCourse'),
+                            array('align' => 'absmiddle', 'hspace' => '3px')
+                        );
+                    ?>
+                    </th>
+                    <th>
+                        <?php
                         echo get_lang('AverageScore').' ';
-                        Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInAllAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
+                        Display:: display_icon(
+                            'info3.gif',
+                            get_lang('AverageIsCalculatedBasedInAllAttempts'),
+                            array('align' => 'absmiddle', 'hspace' => '3px')
+                        );
+                        ?>
+                    </th>
                     <th><?php
                         echo get_lang('LatestAttemptAverageScore').' ';
-                        Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInTheLatestAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
+                        Display::display_icon(
+                            'info3.gif',
+                            get_lang('AverageIsCalculatedBasedInTheLatestAttempts'),
+                            array('align' => 'absmiddle', 'hspace' => '3px')
+                        );
+                        ?>
+                    </th>
                     <th><?php
                         echo get_lang('Progress').' ';
-                        Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
+                        Display:: display_icon(
+                            'info3.gif',
+                            get_lang('LPProgressScore'),
+                            array('align' => 'absmiddle', 'hspace' => '3px')
+                        );
+                        ?>
+                    </th>
                     <th><?php
                         echo get_lang('LastConnexion').' ';
-                        Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
+                        Display:: display_icon(
+                            'info3.gif',
+                            get_lang('LastTimeTheCourseWasUsed'),
+                            array('align' => 'absmiddle', 'hspace' => '3px')
+                        );
+                        ?>
+                    </th>
                     <?php
                     echo '<th>'.get_lang('Details').'</th>';
                     if (api_is_allowed_to_edit()) {
@@ -900,8 +929,11 @@ if (!empty($student_id)) {
                         true
                     );
 
-                    if ($i % 2 == 0) $css_class = "row_even";
-                    else $css_class = "row_odd";
+                    if ($i % 2 == 0) {
+                        $css_class = "row_even";
+                    } else {
+                        $css_class = "row_odd";
+                    }
 
                     $i++;
 
@@ -925,6 +957,7 @@ if (!empty($student_id)) {
                             $score = $score.'%';
                         }
                     }
+
                     echo Display::tag('td', $score);
 
                     if (!is_null($score_latest)) {
@@ -951,7 +984,7 @@ if (!empty($student_id)) {
                             $from ='&from=myspace';
                         }
                         $link = Display::url(
-                            Display::return_icon('2rightarrow.png'),
+                            Display::return_icon('2rightarrow.png', get_lang('Details')),
                             'lp_tracking.php?cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).$from.'&origin='.$origin.'&lp_id='.$learnpath->getId().'&student_id='.$user_info['user_id'].'&id_session='.$sessionId
                         );
                         echo Display::tag('td', $link);
@@ -961,7 +994,7 @@ if (!empty($student_id)) {
                         echo '<td>';
                         if ($any_result === true) {
                             echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS($_GET['details']).'&origin='.$origin.'&lp_id='.$learnpath->getId().'&student='.$user_info['user_id'].'&details=true&id_session='.$sessionId.'">';
-                            echo Display::return_icon('clean.png',get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
+                            echo Display::return_icon('clean.png', get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
                             echo '</a>';
                         }
                         echo '</td>';
@@ -970,8 +1003,6 @@ if (!empty($student_id)) {
                     $data_learnpath[$i][] = $lp_name;
                     $data_learnpath[$i][] = $progress . '%';
                 }
-            } else {
-                //echo '<tr><td colspan="6">'.get_lang('NoLearnpath').'</td></tr>';
             }
             ?>
             </tbody>
@@ -1006,7 +1037,7 @@ if (!empty($student_id)) {
         $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST);
         $sql = "SELECT quiz.title, id FROM " . $t_quiz . " AS quiz
                 WHERE
-                    quiz.c_id =  ".$info_course['real_id']." AND
+                    quiz.c_id =  ".$courseInfo['real_id']." AND
                     (quiz.session_id = $sessionId OR quiz.session_id = 0) AND
                     active IN (0, 1)
                 ORDER BY quiz.title ASC ";
@@ -1016,11 +1047,33 @@ if (!empty($student_id)) {
         if (Database :: num_rows($result_exercices) > 0) {
             while ($exercices = Database :: fetch_array($result_exercices)) {
                 $exercise_id = intval($exercices['id']);
-                $count_attempts   = Tracking::count_student_exercise_attempts($student_id, $courseInfo['real_id'], $exercise_id, 0, 0, $sessionId, 2);
-                $score_percentage = Tracking::get_avg_student_exercise_score($student_id, $course_code, $exercise_id, $sessionId, 1, 0);
+                $count_attempts = Tracking::count_student_exercise_attempts(
+                    $student_id,
+                    $courseInfo['real_id'],
+                    $exercise_id,
+                    0,
+                    0,
+                    $sessionId,
+                    2
+                );
+                $score_percentage = Tracking::get_avg_student_exercise_score(
+                    $student_id,
+                    $course_code,
+                    $exercise_id,
+                    $sessionId,
+                    1,
+                    0
+                );
 
                 if (!isset($score_percentage) && $count_attempts > 0) {
-                    $scores_lp = Tracking::get_avg_student_exercise_score($student_id, $course_code, $exercise_id, $sessionId, 2, 1);
+                    $scores_lp = Tracking::get_avg_student_exercise_score(
+                        $student_id,
+                        $course_code,
+                        $exercise_id,
+                        $sessionId,
+                        2,
+                        1
+                    );
                     $score_percentage = $scores_lp[0];
                     $lp_name = $scores_lp[1];
                 } else {
@@ -1059,11 +1112,11 @@ if (!empty($student_id)) {
 
                 $sql = 'SELECT exe_id FROM ' . $tbl_stats_exercices . '
                          WHERE
-                            exe_exo_id      ="'.$exercise_id.'" AND
-                            exe_user_id     ="'.$student_id.'" AND
-                            c_id            = '.$courseInfo['real_id'].' AND
-                            session_id      ="'.$sessionId.'" AND
-                            status          = ""
+                            exe_exo_id = "'.$exercise_id.'" AND
+                            exe_user_id ="'.$student_id.'" AND
+                            c_id = '.$courseInfo['real_id'].' AND
+                            session_id ="'.$sessionId.'" AND
+                            status = ""
                         ORDER BY exe_date DESC
                         LIMIT 1';
                 $result_last_attempt = Database::query($sql);
@@ -1105,13 +1158,13 @@ if (!empty($student_id)) {
         <?php
         }
 
-        //@when using sessions we do not show the survey list
+        // @when using sessions we do not show the survey list
         if (empty($sessionId)) {
             $survey_list = SurveyManager::get_surveys($course_code, $sessionId);
 
             $survey_data = array();
             foreach($survey_list as $survey) {
-                $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $info_course['real_id']);
+                $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $courseInfo['real_id']);
                 $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL);
                 if (in_array($student_id, $user_list)) {
                     $survey_done = Display::return_icon("accept.png", get_lang('Answered'), array(), ICON_SIZE_SMALL);
@@ -1158,13 +1211,13 @@ if (!empty($student_id)) {
             </thead>
             <tbody>
         <?php
-        $csv_content[] = array ();
-        $nb_assignments 		= Tracking::count_student_assignments($student_id, $course_code, $sessionId);
-        $messages 				= Tracking::count_student_messages($student_id, $course_code, $sessionId);
-        $links 					= Tracking::count_student_visited_links($student_id, $info_course['real_id'], $sessionId);
-        $chat_last_connection 	= Tracking::chat_last_connection($student_id, $info_course['real_id'], $sessionId);
-        $documents				= Tracking::count_student_downloaded_documents($student_id, $info_course['real_id'], $sessionId);
-        $uploaded_documents		= Tracking::count_student_uploaded_documents($student_id, $course_code, $sessionId);
+        $csv_content[] = array();
+        $nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $sessionId);
+        $messages = Tracking::count_student_messages($student_id, $course_code, $sessionId);
+        $links = Tracking::count_student_visited_links($student_id, $courseInfo['real_id'], $sessionId);
+        $chat_last_connection = Tracking::chat_last_connection($student_id, $courseInfo['real_id'], $sessionId);
+        $documents = Tracking::count_student_downloaded_documents($student_id, $courseInfo['real_id'], $sessionId);
+        $uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $sessionId);
 
         $csv_content[] = array(
             get_lang('OtherTools')

+ 2 - 1
main/newscorm/resourcelinker.inc.php

@@ -1709,7 +1709,8 @@ function rl_get_resource_link_for_learnpath($course_id, $learnpath_id, $id_in_pa
             );
             $documentPathInfo = pathinfo($documentInfo['absolute_path']);
             $jplayer_supported_files = ['mp4', 'ogv', 'flv', 'm4v'];
-            $showDirectUrl = !in_array($documentPathInfo['extension'], $jplayer_supported_files);
+            $extension = isset($documentPathInfo['extension']) ? $documentPathInfo['extension'] : '';
+            $showDirectUrl = !in_array($extension, $jplayer_supported_files);
 
             if ($showDirectUrl) {
                 $link = $documentInfo['direct_url'] . '?';

+ 18 - 38
main/survey/survey.lib.php

@@ -161,7 +161,7 @@ class SurveyManager
             $return['survey_type'] = $return['survey_type'];
             $return['one_question_per_page'] = $return['one_question_per_page'];
             $return['show_form_profile'] = $return['show_form_profile'];
-            $return['input_name_list']		= isset($return['input_name_list']) ? $return['input_name_list'] : null;
+            $return['input_name_list'] = isset($return['input_name_list']) ? $return['input_name_list'] : null;
             $return['shuffle'] = $return['shuffle'];
             $return['parent_id'] = $return['parent_id'];
             $return['survey_version'] = $return['survey_version'];
@@ -368,7 +368,7 @@ class SurveyManager
             }
 
             if (!isset($values['anonymous']) ||
-                isset($values['anonymous']) && $values['anonymous'] == ''
+                (isset($values['anonymous']) && $values['anonymous'] == '')
             ) {
                 $values['anonymous'] = 0;
             }
@@ -387,7 +387,7 @@ class SurveyManager
                 if ($values['show_form_profile'] == 1) {
                     $fields = explode(',',$values['input_name_list']);
                     $field_values = '';
-                    foreach ($fields as & $field) {
+                    foreach ($fields as &$field) {
                         if ($field != '') {
                             if (!isset($values[$field]) ||
                                 (isset($values[$field]) && $values[$field] == '')
@@ -835,25 +835,6 @@ class SurveyManager
         Database::query($sql);
     }
 
-    /**
-     * Gets a complete structure of a survey
-     * (all survey information, all question information  of all the questions
-     * and all the options of all the questions.
-     *
-     * @param integer $survey_id the id of the survey
-     * @param boolean $shared this parameter determines if we have to get the
-     * information of a survey from the central (shared) database or from the
-     * course database
-     *
-     * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-     * @version February 2007
-     */
-    public static function get_complete_survey_structure($survey_id, $shared = 0)
-    {
-        $structure = SurveyManager::get_survey($survey_id, $shared);
-        $structure['questions'] = SurveyManager::get_questions($survey_id);
-    }
-
     /***
      * SURVEY QUESTION FUNCTIONS
      */
@@ -1073,7 +1054,6 @@ class SurveyManager
                 }
             }
             $additional = array();
-
             $course_id = api_get_course_int_id();
 
             if (!$empty_answer) {
@@ -1633,17 +1613,17 @@ class SurveyManager
      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
      * @version February 2007
      */
-    static function get_people_who_filled_survey($survey_id, $all_user_info = false, $course_id = null)
+    public static function get_people_who_filled_survey($survey_id, $all_user_info = false, $course_id = null)
     {
         // Database table definition
-        $table_survey_answer 		= Database :: get_course_table(TABLE_SURVEY_ANSWER);
-        $table_user					= Database :: get_main_table(TABLE_MAIN_USER);
+        $table_survey_answer = Database:: get_course_table(TABLE_SURVEY_ANSWER);
+        $table_user = Database:: get_main_table(TABLE_MAIN_USER);
 
         // Variable initialisation
         $return = array();
 
         if (empty($course_id)) {
-            $course_id  = api_get_course_int_id();
+            $course_id = api_get_course_int_id();
         } else {
             $course_id = intval($course_id);
         }
@@ -1675,7 +1655,7 @@ class SurveyManager
         return $return;
     }
 
-    static function survey_generation_hash_available()
+    public static function survey_generation_hash_available()
     {
         if (extension_loaded('mcrypt')) {
             return true;
@@ -1683,13 +1663,13 @@ class SurveyManager
         return false;
     }
 
-    static function generate_survey_hash($survey_id, $course_id, $session_id, $group_id)
+    public static function generate_survey_hash($survey_id, $course_id, $session_id, $group_id)
     {
         $hash = hash('sha512', api_get_security_key().'_'.$course_id.'_'.$session_id.'_'.$group_id.'_'.$survey_id);
         return $hash;
     }
 
-    static function validate_survey_hash($survey_id, $course_id, $session_id, $group_id, $hash)
+    public static function validate_survey_hash($survey_id, $course_id, $session_id, $group_id, $hash)
     {
         $survey_generated_hash = self::generate_survey_hash($survey_id, $course_id, $session_id, $group_id);
         if ($survey_generated_hash == $hash) {
@@ -1698,7 +1678,7 @@ class SurveyManager
         return false;
     }
 
-    static function generate_survey_link($survey_id, $course_id, $session_id, $group_id)
+    public static function generate_survey_link($survey_id, $course_id, $session_id, $group_id)
     {
         $code = self::generate_survey_hash($survey_id, $course_id, $session_id, $group_id);
         return api_get_path(WEB_CODE_PATH).'survey/link.php?h='.$code.'&i='.$survey_id.'&c='.intval($course_id).'&s='.intval($session_id).'&g='.$group_id;
@@ -3230,7 +3210,7 @@ class SurveyUtil
      * @param	boolean	Whether to display user fields or not
      * @return	string	One line of the csv file
      */
-    static function export_complete_report_row_xls(
+    public static function export_complete_report_row_xls(
         $survey_data,
         $possible_options,
         $answers_of_user,
@@ -3301,7 +3281,7 @@ class SurveyUtil
      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
      * @version February 2007
      */
-    static function display_comparative_report()
+    public static function display_comparative_report()
     {
         // Allowed question types for comparative report
         $allowed_question_types = array(
@@ -3351,7 +3331,7 @@ class SurveyUtil
         echo get_lang('SelectYAxis').': ';
         echo '<select name="yaxis">';
         echo '<option value="">---</option>';
-        foreach ($questions as $key => & $question) {
+        foreach ($questions as $key => &$question) {
             if (in_array($question['type'], $allowed_question_types)) {
                 echo '<option value="'.$question['question_id'].'"';
                 if (isset($_GET['yaxis']) && $_GET['yaxis'] == $question['question_id']) {
@@ -3534,7 +3514,7 @@ class SurveyUtil
      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
      * @version February 2007 - Updated March 2008
      */
-    static function get_answers_of_question_by_user($survey_id, $question_id)
+    public static function get_answers_of_question_by_user($survey_id, $question_id)
     {
         $course_id = api_get_course_int_id();
         $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
@@ -3566,7 +3546,7 @@ class SurveyUtil
      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
      * @version February 2007
      */
-    static function comparative_check($answers_x, $answers_y, $option_x, $option_y, $value_x = 0, $value_y = 0)
+    public static function comparative_check($answers_x, $answers_y, $option_x, $option_y, $value_x = 0, $value_y = 0)
     {
         if ($value_x == 0) {
             $check_x = $option_x;
@@ -3605,7 +3585,7 @@ class SurveyUtil
      *
      * @todo use survey_id parameter instead of $_GET
      */
-    static function get_survey_invitations_data()
+    public static function get_survey_invitations_data()
     {
         $course_id = api_get_course_int_id();
         // Database table definition
@@ -3642,7 +3622,7 @@ class SurveyUtil
      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
      * @version January 2007
      */
-    static function get_number_of_survey_invitations()
+    public static function get_number_of_survey_invitations()
     {
         $course_id = api_get_course_int_id();
 

+ 1 - 1
main/webservices/lp.php

@@ -45,7 +45,7 @@ function WSHelperVerifyKey($params)
     // if we are behind a reverse proxy, assume it will send the
     // HTTP_X_FORWARDED_FOR header and use this IP instead
     if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
-        list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
+        list($ip1) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
         $ip = trim($ip1);
     }
     if ($debug)

+ 6 - 3
main/webservices/registration.soap.php

@@ -5860,6 +5860,7 @@ $server->register('WSListCourses',
 // define the method WSListCourses
 function WSListCourses($params)
 {
+    global $debug;
     if (!WSHelperVerifyKey($params)) {
         return returnError(WS_ERROR_SECRET_KEY);
     }
@@ -5872,9 +5873,11 @@ function WSListCourses($params)
     $from = isset($params['from']) ? $params['from'] : null;
     $to = isset($params['to']) ? $params['to'] : null;
 
-    error_log(print_r($params,1));
-    error_log($from);
-    error_log($to);
+    if ($debug) {
+        error_log(print_r($params, 1));
+        error_log($from);
+        error_log($to);
+    }
 
     $courses = CourseManager::get_courses_list($from, $to);
 

+ 1 - 0
main/work/downloadfolder.inc.php

@@ -182,6 +182,7 @@ if (!empty($files)) {
 
     //start download of created file
     $name = $fileName .'.zip';
+    
     if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) {
         DocumentManager::file_send_for_download($temp_zip_file, true, $name);
         @unlink($temp_zip_file);

+ 0 - 10
tests/main/survey/survey.lib.test.php

@@ -182,16 +182,6 @@ class TestSurvey extends UnitTestCase {
 
 	}
 
-
-	public function testGetCompleteSurveyStructure() {
-		$survey_id='';
-		$shared=0;
-		$res = $this->smanager->get_complete_survey_structure($survey_id, $shared);
-		$this->assertNull($res);
-		$this->assertTrue($res=== null);
-		//var_dump($res);
-	}
-
 	public function testIconQuestion() {
 		$type='open';
 		$res = $this->smanager->icon_question($type);