Julio Montoya 12 jaren geleden
bovenliggende
commit
c0fc28caf2

+ 2 - 7
main/admin/course_list.php

@@ -26,7 +26,6 @@ function get_number_of_courses() {
     $course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
     $sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table";
 
-    global $_configuration;
     if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
         $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
         $sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)";
@@ -35,8 +34,7 @@ function get_number_of_courses() {
     if (isset ($_GET['keyword'])) {
         $keyword = Database::escape_string($_GET['keyword']);
         $sql .= " WHERE (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')";
-    }
-    elseif (isset ($_GET['keyword_code'])) {
+    } elseif (isset ($_GET['keyword_code'])) {
         $keyword_code = Database::escape_string($_GET['keyword_code']);
         $keyword_title = Database::escape_string($_GET['keyword_title']);
         $keyword_category = Database::escape_string($_GET['keyword_category']);
@@ -75,7 +73,6 @@ function get_course_data($from, $number_of_items, $column, $direction) {
                     directory as col9,
                     visual_code
     		FROM $course_table";
-    global $_configuration;
 
     if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
         $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -136,7 +133,6 @@ function modify_filter($code) {
  * Return an icon representing the visibility of the course
  */
 function get_course_visibility_icon($v) {
-    $path = api_get_path(REL_CODE_PATH);
     $style = 'margin-bottom:-5px;margin-right:5px;';
     switch($v) {
         case 0:
@@ -162,7 +158,7 @@ if (isset ($_POST['action'])) {
         case 'delete_courses' :
             $course_codes = $_POST['course'];
             if (count($course_codes) > 0) {
-                foreach ($course_codes as $index => $course_code) {
+                foreach ($course_codes as $course_code) {
                     CourseManager :: delete_course($course_code);
                     $obj_cat = new Category();
                     $obj_cat->update_category_delete($course_code);
@@ -177,7 +173,6 @@ $actions = '';
 
 if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
     // Get all course categories
-    $table_course_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
     $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
     $interbreadcrumb[] = array('url' => 'course_list.php', 'name' => get_lang('CourseList'));
     $tool_name = get_lang('SearchACourse');

+ 1 - 3
main/admin/index.php

@@ -150,6 +150,7 @@ if (api_is_platform_admin()) {
     $items[] = array('url'=>'configure_homepage.php', 		'label' => get_lang('ConfigureHomePage'));
     $items[] = array('url'=>'configure_inscription.php', 	'label' => get_lang('ConfigureInscription'));
     $items[] = array('url'=>'statistics/index.php', 		'label' => get_lang('Statistics'));
+    $items[] = array('url'=> api_get_path(WEB_CODE_PATH).'mySpace/company_reports.php',          'label' => get_lang('Reports'));
 
     /* Event settings */
     
@@ -222,12 +223,9 @@ if (api_is_platform_admin()) {
 	if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
 		$items[] = array('url'=>'filler.php', 	'label' => get_lang('DataFiller'));
 	}
-	//if (api_is_global_platform_admin()) {
 		$items[] = array('url'=>'archive_cleanup.php', 	'label' => get_lang('ArchiveDirCleanup'));
-	//}
     
 	$items[] = array('url'=>'system_management.php', 'label' => get_lang('SystemManagement'));
-    //$items[] = array('url'=>'statistics/index.php?action=activities', 	'label' => get_lang('ImportantActivities'));
     
 	$blocks['settings']['items'] = $items;
     $blocks['settings']['extra'] = null;

+ 17 - 18
main/announcements/announcements.inc.php

@@ -14,7 +14,7 @@
 class AnnouncementManager {
 
     public function __construct() {
-        
+
     }
 
     public static function get_tags() {
@@ -241,17 +241,17 @@ class AnnouncementManager {
             return false;
         }
     }
-    
+
     public static function get_last_announcement_order() {
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
         $course_id = api_get_course_int_id();
         $sql_max = "SELECT MAX(display_order) FROM $tbl_announcement WHERE c_id = $course_id ";
         $res_max = Database::query($sql_max);
-        
+
         $order = 0;
         if (Database::num_rows($res_max)) {
             $row_max = Database::fetch_array($res_max);
-            $order   = intval($row_max[0])+1;  
+            $order   = intval($row_max[0])+1;
         }
         return $order;
     }
@@ -273,22 +273,22 @@ class AnnouncementManager {
         // filter data
         $emailTitle = Database::escape_string($emailTitle);
         $newContent = Database::escape_string($newContent);
-        
+
         if (empty($end_date)) {
             $end_date = api_get_utc_datetime();
         } else {
             $end_date = Database::escape_string($end_date);
         }
-        
+
         $course_id = api_get_course_int_id();
-        
+
         $order = self::get_last_announcement_order();
 
         // store in the table announcement
         $sql = "INSERT INTO $tbl_announcement SET
 				c_id 			= '$course_id',
 				content 		= '$newContent',
-				title 			= '$emailTitle', 
+				title 			= '$emailTitle',
                 end_date        = '$end_date',
 				display_order 	= '$order',
 				session_id		= " . api_get_session_id();
@@ -301,7 +301,7 @@ class AnnouncementManager {
             if (!empty($file)) {
                 self::add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']);
             }
-            
+
             // store in item_property (first the groups, then the users
             if (!is_null($sent_to)) {
                 // !is_null($sent_to): when no user is selected we send it to everyone
@@ -336,7 +336,7 @@ class AnnouncementManager {
 
         // database definitions
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
-        
+
         $emailTitle = Database::escape_string($emailTitle);
         $newContent = Database::escape_string($newContent);
         $order = self::get_last_announcement_order();
@@ -719,13 +719,13 @@ class AnnouncementManager {
 
         $sql = "SELECT DISTINCT announcement.id, announcement.title, announcement.content
                            FROM $tbl_announcement announcement INNER JOIN $tbl_item_property toolitemproperties
-                           ON   announcement.id = toolitemproperties.ref AND 
+                           ON   announcement.id = toolitemproperties.ref AND
                                 announcement.c_id = $course_id AND
-                                toolitemproperties.c_id = $course_id 
-                           WHERE toolitemproperties.tool='announcement' AND                                 
+                                toolitemproperties.c_id = $course_id
+                           WHERE toolitemproperties.tool='announcement' AND
                                  announcement.id = $annoucement_id";
         $result = Database::query($sql);
-        if (Database::num_rows($result)) {            
+        if (Database::num_rows($result)) {
             return Database::fetch_array($result);
         }
         return array();
@@ -734,12 +734,11 @@ class AnnouncementManager {
     /**
      * this function gets all the users of the course,
      * including users from linked courses
+     * @todo deprecate this function, use CourseManager class
      */
     public static function get_course_users() {
         //this would return only the users from real courses:
-        //$user_list = CourseManager::get_user_list_from_course_code(api_get_course_id());
         $session_id = api_get_session_id();
-
         if ($session_id != 0) {
             $user_list = CourseManager::get_real_and_linked_user_list(api_get_course_id(), true, $session_id);
         } else {
@@ -836,8 +835,8 @@ class AnnouncementManager {
             $src = $www . 'main/announcements/resources/js/main.js';
         } else {
             $src = $www . 'main/announcements/resources/js/main.min.js';
-        }*/        
-        $src = $www . 'main/announcements/resources/js/main.js';        
+        }*/
+        $src = $www . 'main/announcements/resources/js/main.js';
         $result = Javascript::tag($src);
         $root = Chamilo::url();
         $code = "var www = '$root';\n";

+ 0 - 1
main/calendar/agenda_js.php

@@ -181,7 +181,6 @@ if ((api_is_allowed_to_edit() || $is_group_tutor) && $course_code != '-1' && $ty
         $group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id());
     }
 
-
     $agenda = new Agenda();
     //This will fill the select called #users_to_send_id
     $select = $agenda->construct_not_selected_select_form($group_list, $user_list);

+ 21 - 3
main/inc/ajax/model.ajax.php

@@ -3,7 +3,7 @@
 
 //@todo this could be integrated in the inc/lib/model.lib.php + try to clean this file
 
-$language_file = array('admin','exercice');
+$language_file = array('admin', 'exercice', 'gradebook', 'tracking');
 
 require_once '../global.inc.php';
 
@@ -76,6 +76,8 @@ function get_where_clause($col, $oper, $val) {
 }
 
 $where_condition = ""; //if there is no search request sent by jqgrid, $where should be empty
+$operation    = isset($_REQUEST['oper'])  ? $_REQUEST['oper']  : false;
+$export_format    = isset($_REQUEST['export_format'])  ? $_REQUEST['export_format']  : 'csv';
 
 $search_field    = isset($_REQUEST['searchField'])  ? $_REQUEST['searchField']  : false;
 $search_oper     = isset($_REQUEST['searchOper'])   ? $_REQUEST['searchOper']   : false;
@@ -176,6 +178,9 @@ if (!$sidx) $sidx = 1;
 //@todo rework this
 
 switch ($action) {
+    case 'get_user_course_report':
+        $count = CourseManager::get_count_user_list_from_course_code();
+        break;
     case 'get_course_exercise_medias':
         $course_id = api_get_course_int_id();
         $count = Question::get_count_course_medias($course_id);
@@ -300,7 +305,19 @@ switch ($action) {
     case 'get_course_exercise_medias':
         $columns = array('question');
         $result = Question::get_course_medias($course_id, $start, $limit, $sidx, $sord, $where_condition);        
-        break;  
+        break;
+    case 'get_user_course_report':
+        $columns = array('course', 'user', 'time', 'certificate', 'score');
+        $column_names = array(get_lang('Course'), get_lang('User'), get_lang('TimeSpentInTheCourse'), get_lang('Certificate'), get_lang('Score'));
+        $extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
+        if (!empty($extra_fields)) {
+            foreach($extra_fields as $extra) {
+                $columns[] = $extra['1'];
+                $column_names[] = $extra['3'];
+            }
+        }
+    $result = CourseManager::get_user_list_from_course_code(null, null, "LIMIT $start, $limit", " $sidx $sord", null, null, true);
+    break;
 	case 'get_user_skill_ranking':	
         $columns = array('photo', 'firstname', 'lastname', 'skills_acquired', 'currently_learning', 'rank');
 	    $result = $skill->get_user_list_skill_ranking($start, $limit, $sidx, $sord, $where_condition);
@@ -339,7 +356,7 @@ switch ($action) {
         //used inside get_exam_results_data()
 		$documentPath				= api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document"; 		
 		if ($is_allowedToEdit) {
-			$columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'actions');
+			$columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'lp', 'actions');
 		} else {
 			//$columns = array('exe_duration', 'start_date', 'exe_date', 'score', 'status', 'actions');
 		}       
@@ -597,6 +614,7 @@ $allowed_actions = array('get_careers',
                          'get_extra_fields',
                          'get_extra_field_options',
                          'get_course_exercise_medias',
+                         'get_user_course_report',
 );
                          	
 //5. Creating an obj to return a json

+ 77 - 41
main/inc/lib/course.lib.php

@@ -1246,16 +1246,17 @@ class CourseManager {
      * @param int       if using the session_id: 0 or 2 (student, coach), if using session_id = 0 STUDENT or COURSEMANAGER
      * @return array
      */
-    public static function get_user_list_from_course_code($course_code, $session_id = 0, $limit = null, $order_by =null, $filter_by_status = null, $keyword = null) {
+    public static function get_user_list_from_course_code($course_code = null, $session_id = 0, $limit = null, $order_by = null, $filter_by_status = null, $return_count = null, $add_reports = false) {
+        // variable initialisation
         $session_id     = intval($session_id);
         $course_code    = Database::escape_string($course_code);
-        $keyword        = Database::escape_string($keyword);
         $where          = array();
 
         // if the $order_by does not contain 'ORDER BY' we have to check if it is a valid field that can be sorted on
         if (!strstr($order_by,'ORDER BY')) {
-            if (!empty($order_by) AND in_array($order_by, array('lastname', 'firstname', 'username', 'email', 'official_code'))) {
-                $order_by = 'ORDER BY user.'.$order_by;
+            //if (!empty($order_by) AND in_array($order_by, array('lastname', 'firstname', 'username', 'email', 'official_code'))) {
+            if (!empty($order_by)) {
+                $order_by = 'ORDER BY '.$order_by;
             } else {
                 $order_by = '';
             }
@@ -1269,32 +1270,40 @@ class CourseManager {
             $sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' as session_course_user
                       ON user.user_id = session_course_user.id_user
                       AND session_course_user.course_code="'.$course_code.'"
-                      AND session_course_user.id_session = '.$session_id.'
-                      INNER JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_USER).' as su
-                      ON (  su.id_session = session_course_user.id_session AND
-                            user.user_id = su.id_user AND
-                            su.moved_to = 0 AND
-                            su.moved_status <> '.SessionManager::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION.'
-                      ) ';
-            $where[] = ' AND session_course_user.course_code IS NOT NULL ';
+                      AND session_course_user.id_session = '.$session_id;
+            $where[] = ' session_course_user.course_code IS NOT NULL ';
 
             // 2 = coach
             // 0 = student
             if (isset($filter_by_status)) {
                 $filter_by_status = intval($filter_by_status);
-                $filter_by_status_condition = " AND session_course_user.status = $filter_by_status AND ";
+                $filter_by_status_condition = " session_course_user.status = $filter_by_status AND ";
             }
+        } else {
+            if ($return_count) {
+                $sql = " SELECT COUNT(*) as count";
+            } else {
+                if (empty($course_code)) {
+                    $sql = 'SELECT DISTINCT course.title, course.code, course_rel_user.status as status_rel, user.user_id, course_rel_user.role, course_rel_user.tutor_id, user.*  ';
         } else {
             $sql = 'SELECT DISTINCT course_rel_user.status as status_rel, user.user_id, course_rel_user.role, course_rel_user.tutor_id, user.*  ';
+                }
+            }
             $sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user ';
             $sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_COURSE_USER).' as course_rel_user
-                        ON user.user_id = course_rel_user.user_id AND course_rel_user.relation_type<>'.COURSE_RELATION_TYPE_RRHH.'
-                        AND course_rel_user.course_code="'.$course_code.'"';
-            $where[] = ' AND course_rel_user.course_code IS NOT NULL ';
+                        ON user.user_id = course_rel_user.user_id AND
+                        course_rel_user.relation_type <> '.COURSE_RELATION_TYPE_RRHH.'  ';
+            if (!empty($course_code)) {
+                $sql .= ' AND course_rel_user.course_code="'.$course_code.'"';
+            } else {
+                $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
+                $sql .= " INNER JOIN  $course_table course ON course_rel_user.course_code = course.code ";
+            }
+            $where[] = ' course_rel_user.course_code IS NOT NULL ';
 
             if (isset($filter_by_status) && $filter_by_status != '') {
                 $filter_by_status = intval($filter_by_status);
-                $filter_by_status_condition = " AND course_rel_user.status = $filter_by_status AND ";
+                $filter_by_status_condition = " course_rel_user.status = $filter_by_status AND ";
             }
         }
 
@@ -1303,39 +1312,27 @@ class CourseManager {
             $sql  .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).'  au ON (au.user_id = user.user_id) ';
         }
 
-        $keyword_condition = null;
-        if (!empty($keyword)) {
-            $where_keyword = array();
-            $where_keyword[] = "firstname LIKE '%$keyword%'";
-            $where_keyword[] = "lastname LIKE '%$keyword%'";
-            $where_keyword[] = "username LIKE '%$keyword%'";
-            $where_keyword[] = "official_code LIKE '%$keyword%'";
-            $keyword_condition = ' AND ('.implode(' OR ', $where_keyword).') ';
-        }
-
-        $where_condition = null;
-        if (!empty($where)) {
-            $where_condition = implode(' OR ', $where);
-        }
-
-        $sql .= " WHERE 1=1 $filter_by_status_condition $where_condition $keyword_condition";
+        $sql .= ' WHERE '.$filter_by_status_condition.' '.implode(' OR ', $where);
 
         if ($multiple_access_url) {
             $current_access_url_id = api_get_current_access_url_id();
             $sql .= " AND (access_url_id =  $current_access_url_id ) ";
         }
+        $sql .= ' '.$order_by.' '.$limit;
 
-        $sql .= ' '.$order_by;
-
-        if (!empty($keyword)) {
-            $sql .= ' '.$limit;
-        }
+        //echo $sql;
 
         $rs = Database::query($sql);
         $users = array();
+        if ($add_reports) {
+            $extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
+        }
 
         if (Database::num_rows($rs)) {
             while ($user = Database::fetch_array($rs)) {
+                if ($return_count) {
+                    return $user['count'];
+                }
                 $user_info = $user;
                 $user_info['status'] = $user['status'];
 
@@ -1348,12 +1345,37 @@ class CourseManager {
                 if (!empty($session_id)) {
                     $user_info['status_session'] = $user['status_session'];
                 }
+                if ($add_reports) {
+                    $course_code = $user['code'];
+                    $report_info['course'] = $user['title'];
+                    $report_info['user'] = api_get_person_name($user['firstname'], $user['lastname']);
+                    $report_info['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $course_code, 0));
+
+
+                    $category = Category :: load (null, null, $course_code);
+                    $report_info['certificate'] = Display::label(get_lang('No'));
+                    if (isset($category[0]) && $category[0]->is_certificate_available($user['user_id'])) {
+                        $report_info['certificate'] = Display::label(get_lang('Yes'), 'success');
+                    }
+                    $report_info['score'] = Tracking::get_avg_student_score($user['user_id'], $course_code, array(), 0);
+
+                    foreach ($extra_fields as $extra) {
+                        $user_data = UserManager::get_extra_user_data_by_field($user['user_id'], $extra['1']);
+                        $report_info[$extra['1']] = $user_data[$extra['1']];
+                    }
+                    //var_dump($report_info);
+                    $users[] = $report_info;
+                } else {
                 $users[$user['user_id']] = $user_info;
             }
         }
+        }
         return $users;
     }
 
+    static function get_count_user_list_from_course_code() {
+        return self::get_user_list_from_course_code(null, 0, null, null, null, true);
+    }
     /**
      * Gets subscribed users in a course or in a course/session
      *
@@ -1362,6 +1384,7 @@ class CourseManager {
      * @return  int
      */
     public static function get_users_count_in_course($course_code, $session_id = 0) {
+        // variable initialisation
         $session_id     = intval($session_id);
         $course_code    = Database::escape_string($course_code);
 
@@ -1675,20 +1698,31 @@ class CourseManager {
      * Get the list of groups from the course
      * @param   string  Course code
      * @param   int     Session ID (optional)
+     * @param   boolean get empty groups (optional)
      * @return  array   List of groups info
      */
-    public static function get_group_list_of_course($course_code, $session_id = 0) {
+    public static function get_group_list_of_course($course_code, $session_id = 0, $in_get_empty_group = 0) {
         $course_info = Database::get_course_info($course_code);
         $course_id = $course_info['real_id'];
         $group_list = array();
         $session_id != 0 ? $session_condition = ' WHERE g.session_id IN(1,'.intval($session_id).')' : $session_condition = ' WHERE g.session_id = 0';
 
-        $sql = "SELECT g.id, g.name
+        if ($in_get_empty_group == 0) {
+            // get only groups that are not empty
+            $sql = "SELECT DISTINCT g.id, g.name
                 FROM ".Database::get_course_table(TABLE_GROUP)." AS g
                 INNER JOIN ".Database::get_course_table(TABLE_GROUP_USER)." gu
                 ON (g.id = gu.group_id AND g.c_id = $course_id AND gu.c_id = $course_id)
                 $session_condition
                 ORDER BY g.name";
+                }
+        else {
+            // get all groups even if they are empty
+            $sql = "SELECT g.id, g.name
+                    FROM ".Database::get_course_table(TABLE_GROUP)." AS g
+                    $session_condition
+                    AND c_id = $course_id";
+        }
         $result = Database::query($sql);
 
         while ($group_data = Database::fetch_array($result)) {
@@ -3498,6 +3532,7 @@ class CourseManager {
         //Course catalog stats modifications see #4191
         $table_course_ranking       = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
 
+        $now = api_get_utc_datetime();
         $course_id  = empty($course_id)     ? api_get_course_int_id() : intval($course_id);
         $session_id = !isset($session_id)   ? api_get_session_id() : intval($session_id);
         $url_id     = empty($url_id)        ? api_get_current_access_url_id() : intval($url_id);
@@ -3505,7 +3540,8 @@ class CourseManager {
         $params = array(
             'c_id'          => $course_id,
             'session_id'    => $session_id,
-            'url_id'        => $url_id
+            'url_id'        => $url_id,
+            'creation_date' => $now,
         );
 
         $result = Database::select('id, accesses, total_score, users', $table_course_ranking, array('where' => array('c_id = ? AND session_id = ? AND url_id = ?' => $params)), 'first');

+ 1 - 1
main/inc/lib/usermanager.lib.php

@@ -2015,8 +2015,8 @@ class UserManager {
 		$t_uf = Database::get_main_table(TABLE_MAIN_USER_FIELD);
 		$t_ufv = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
 		$user_id = Database::escape_string($user_id);
-		$sql = "SELECT f.id as id, f.field_variable as fvar, f.field_type as type FROM $t_uf f ";
 
+		$sql = "SELECT f.id as id, f.field_variable as fvar, f.field_type as type FROM $t_uf f ";
 		$sql .= " WHERE f.field_variable = '$field_variable' ";
 
 		if (!$all_visibility) {

+ 83 - 0
main/mySpace/company_reports.php

@@ -0,0 +1,83 @@
+<?php
+
+$language_file = array('admin', 'gradebook', 'tracking');
+
+$cidReset = true;
+require_once '../inc/global.inc.php';
+
+api_protect_admin_script();
+
+$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace'));
+//$interbreadcrumb[] = array ("url" => 'user_list.php', "name" => get_lang('Report'));
+$tool_name = get_lang('Report');
+
+$this_section = SECTION_TRACKING;
+
+$htmlHeadXtra[] = api_get_jqgrid_js();
+
+
+//jqgrid will use this URL to do the selects
+$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report';
+
+$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
+
+
+//The order is important you need to check the the $column variable in the model.ajax.php file
+$columns        = array(get_lang('Course'), get_lang('User'), get_lang('TimeSpentInTheCourse'), get_lang('Certificate'), get_lang('Score'));
+
+//Column config
+$column_model   = array(
+                        array('name'=>'course',         'index'=>'title',   'width'=>'200', 'align'=>'left'),
+                        array('name'=>'user',           'index'=>'user',    'width'=>'120', 'align'=>'left','sortable'=>'false'),
+                        array('name'=>'time',           'index'=>'time',    'width'=>'50',  'align'=>'left','sortable'=>'false'),
+                        array('name'=>'certificate',    'index'=>'certificate',  'width'=>'50',  'align'=>'left','sortable'=>'false'),
+                        array('name'=>'score',          'index'=>'score',   'width'=>'50',  'align'=>'left','sortable'=>'false'),
+);
+
+if (!empty($extra_fields)) {
+    foreach($extra_fields as $extra) {
+        $col = array(
+            'name' => $extra['1'],
+            'index'=> $extra['1'],
+            'width'=>'120',
+            'sortable'=>'false'
+        );
+        $column_model[] = $col;
+
+        $columns[] = $extra['3'];
+    }
+}
+
+//Autowidth
+$extra_params['autowidth'] = 'true';
+//height auto
+$extra_params['height'] = 'auto';
+
+
+//With this function we can add actions to the jgrid (edit, delete, etc)
+$action_links = 'function action_formatter(cellvalue, options, rowObject) {
+                         return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
+                         '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;"  href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png',get_lang('Copy'),'',ICON_SIZE_SMALL).'</a>'.
+                         '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;"  href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
+                         '\';
+                 }';
+
+$htmlHeadXtra[] = '<script>
+$(function() {
+    '.Display::grid_js('user_course_report',  $url,$columns,$column_model,$extra_params, array(), $action_links, true).'
+
+    jQuery("#user_course_report").jqGrid("navGrid","#user_course_report_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
+    jQuery("#user_course_report").jqGrid("navButtonAdd","#user_course_report_pager",{
+           caption:"",
+           onClickButton : function () {
+               jQuery("#user_course_report").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
+           }
+    });
+});
+</script>';
+$content = Display::grid_html('user_course_report');
+
+$tpl = new Template($tool_name);
+$tpl->assign('message', $message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 30 - 29
main/newscorm/lp_add_item.php

@@ -26,7 +26,7 @@ $language_file = 'learnpath';
 
 $htmlHeadXtra[] = '
 <script>
-var temp    = false;
+var temp = false;
 var load_default_template = '. ((isset($_POST['submit']) || empty($_SERVER['QUERY_STRING'])) ? 'false' : 'true' ) .';
 
 function FCKeditor_OnComplete( editorInstance ) {
@@ -35,9 +35,9 @@ function FCKeditor_OnComplete( editorInstance ) {
     loaded = true;
 }
 
-function check_for_title() {   
-    if (temp) {  
-    
+function check_for_title() {
+    if (temp) {
+
         // This functions shows that you can interact directly with the editor area
         // DOM. In this way you have the freedom to do anything you want with it.
 
@@ -119,17 +119,18 @@ $(function() {
         }
     }
     //Loads LP item tabs
-    
+
     $("#resource_tab").tabs();
     $(\'.lp_resource_element\').click(function() {
         window.location.href = $(\'a\', this).attr(\'href\');
-    });        
+    });
 });
 </script>';
 
 /* Constants and variables */
 
-$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
+//Already set in lp_controller.php
+//$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
 
 $isStudentView  = (int) $_REQUEST['isStudentView'];
 $learnpath_id   = (int) $_REQUEST['lp_id'];
@@ -156,9 +157,9 @@ if (isset($_SESSION['gradebook'])) {
 
 if (!empty($gradebook) && $gradebook == 'view') {
     $interbreadcrumb[] = array (
-            'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
-            'name' => get_lang('ToolGradebook')
-        );
+        'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
+        'name' => get_lang('ToolGradebook')
+    );
 }
 
 $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
@@ -196,13 +197,13 @@ $suredel = trim(get_lang('AreYouSureToDelete'));
     #resExercise .ui-selected { background: #F39814; color: white; }
     #resExercise { list-style-type: none; margin: 0; padding: 0; width: 60%; }
     #resExercise li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
-    
+
     /* Fixes LP toolbar */
     #resource_tab li a {
         padding: 5px 4px;
     }
 </style>
-    
+
 <script>
 function stripslashes(str) {
     str=str.replace(/\\'/g,'\'');
@@ -220,21 +221,21 @@ function confirmation(name) {
     }
 }
 
-$(document).ready(function() {    
+$(document).ready(function() {
     $("#hide_bar_template").toggle(
-        function() { 
-            $("#lp_sidebar").hide(); 
+        function() {
+            $("#lp_sidebar").hide();
             $(this).css({'background-image' : 'url("../img/hide2.png")'})
-            $("#doc_form").removeClass("span8"); 
-            $("#doc_form").addClass("span11");   
+            $("#doc_form").removeClass("span8");
+            $("#doc_form").addClass("span11");
         },
-        function() { 
+        function() {
             $("#lp_sidebar").show();
-            $("#doc_form").removeClass("span11"); 
-            $("#doc_form").addClass("span8"); 
-            $(this).css('background-image', 'url("../img/hide0.png")'); 
-        }            
-    );    
+            $("#doc_form").removeClass("span11");
+            $("#doc_form").addClass("span8");
+            $(this).css('background-image', 'url("../img/hide0.png")');
+        }
+    );
 });
 </script>
 <?php
@@ -246,22 +247,22 @@ echo $_SESSION['oLP']->build_action_menu();
 echo '<div class="row-fluid" style="overflow:hidden">';
 echo '<div id="lp_sidebar" class="span4">';
 
-echo $_SESSION['oLP']->return_new_tree(null, true); 
+echo $_SESSION['oLP']->return_new_tree(null, true);
 
 // Show the template list.
-if ($type == 'document' && !isset($_GET['file'])) {    
-    // Show the template list.        
+if ($type == 'document' && !isset($_GET['file'])) {
+    // Show the template list.
     echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';}
 echo '</div>';
 
 //hide bar div
-if ($action == 'add_item' && $type == 'document' && !isset($_GET['file'])) {    
-    echo '<div id="hide_bar_template"></div>';    
+if ($action == 'add_item' && $type == 'document' && !isset($_GET['file'])) {
+    echo '<div id="hide_bar_template"></div>';
 }
 
 echo '<div id="doc_form" class="span8">';
 
-if (isset($new_item_id) && is_numeric($new_item_id)) {        
+if (isset($new_item_id) && is_numeric($new_item_id)) {
     switch ($type) {
         case 'chapter':
             echo $_SESSION['oLP']->display_manipulate($new_item_id, $_POST['type']);

+ 1 - 1
main/newscorm/lp_controller.php

@@ -197,7 +197,7 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
 }
 if ($debug > 0) error_log('New LP - Passed oLP creation check', 0);
 
-$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
+$is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
 
 
 /**

+ 4 - 4
main/newscorm/lp_view.php

@@ -40,17 +40,17 @@ $lp_id = intval($_GET['lp_id']);
 
 // Check if the learning path is visible for student - (LP requisites)
 if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) {
-    api_not_allowed();
+    api_not_allowed(true);
 }
 
 //Checking visibility (eye icon)
 $visibility = api_get_item_visibility(api_get_course_info(), TOOL_LEARNPATH, $lp_id, $action, api_get_user_id(), api_get_session_id());
-if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0 ) {
-     api_not_allowed();
+if (!api_is_allowed_to_edit(false, true, false, false) && intval($visibility) == 0) {
+    api_not_allowed(true);
 }
 
 if (empty($_SESSION['oLP'])) {
-    api_not_allowed();
+    api_not_allowed(true);
 }
 
 $debug = 0;

+ 72 - 33
main/webservices/client_soap.php

@@ -1,15 +1,15 @@
 <?php
 /* For licensing terms, see /license.txt */
 
-/* 
- * 
- * 1. This script creates users everytime the page is executed using the Chamilo Webservices 
+/*
+ *
+ * 1. This script creates users everytime the page is executed using the Chamilo Webservices
  * 2. The username is generated everytime with a random value from 0 to 1000
- * 3. The default user extra field (profile) is "uid" is created when calling the WSCreateUserPasswordCrypted for the first time, you can change this value. 
+ * 3. The default user extra field (profile) is "uid" is created when calling the WSCreateUserPasswordCrypted for the first time, you can change this value.
  *    In this field your third party user_id will be registered. See the main/admin/user_fields.php to view the current user fields.
  * 4. You need to create manually a course called Test(with code TEST) After the user was created the new user will be added to this course via webservices.
- 
- * 
+
+ *
  */
 
 exit; //Uncomment this in order to execute the page
@@ -60,23 +60,27 @@ $params = array(    'firstname'                 => 'Jon',
                     'expiration_date'           => '0000-00-00',
                     'original_user_id_name'     => $user_field, // the extra user field that will be automatically created in the user profile see: main/admin/user_fields.php
                     'original_user_id_value'    => $random_user_id, // third party user id
-                    'secret_key'                => $secret_key
+                    'secret_key'                => $secret_key,
+                    'extra' => array(
+                        array('field_name' => 'ruc', 'field_value' => '123'),
+                        array('field_name' => 'DNI', 'field_value' => '4200000')
+                    ),
 );
 
 $user_id = $client->call('WSCreateUserPasswordCrypted', array('createUserPasswordCrypted' => $params));
 
 if (!empty($user_id) && is_numeric($user_id)) {
-    
+
     // 2. Get user info of the user
     echo '<h2>Trying to create an user via webservices</h2>';
     $original_params = $params;
-    
+
     $params = array('original_user_id_value'    => $random_user_id, // third party user id
                     'original_user_id_name'     => $user_field, // the system field in the user profile (See Profiling)
                     'secret_key'                => $secret_key);
 
     $result = $client->call('WSGetUser', array('GetUser' => $params));
-    
+
     if ($result) {
         echo "Random user was created user_id: $user_id <br /><br />";
         echo 'User info: <br />';
@@ -85,14 +89,49 @@ if (!empty($user_id) && is_numeric($user_id)) {
     } else {
         echo $result;
     }
-        
-    //3.Adding user to the course TEST. The course TEST must be created manually in Chamilo
-    
+
+    //3. Updating user info
+
+    $params = array(
+                    'firstname'                 => 'Jon edited',
+                    'lastname'                  => 'Brion edited',
+                    'status'                    => '5', // STUDENT
+                    'email'                     => 'jon@example.com',
+                    'username'                  => $generate_user_name,
+                    'password'                  => $generate_password, // encrypted using sha1
+                    'encrypt_method'            => 'sha1',
+                    'phone'                     => '00000000',
+                    'expiration_date'           => '0000-00-00',
+                    'original_user_id_name'     => $user_field, // the extra user field that will be automatically created in the user profile see: main/admin/user_fields.php
+                    'original_user_id_value'    => $random_user_id, // third party user id
+                    'secret_key'                => $secret_key,
+                    'extra' => array(
+                            array('field_name' => 'ruc', 'field_value' => '666 edited'),
+                            array('field_name' => 'DNI', 'field_value' => '888 edited')
+                    ),
+    );
+    $result = $client->call('WSEditUserPasswordCrypted', array('editUserPasswordCrypted' => $params));
+
+    if ($result) {
+        echo "Random user was update user_id: $user_id <br /><br />";
+        echo 'User info: <br />';
+        print_r($params);
+        echo '<br /><br />';
+    } else {
+        $err = $client->getError();
+        var_dump($result);
+        var_dump($err);
+    }
+    exit;
+
+
+    //4 .Adding user to the course TEST. The course TEST must be created manually in Chamilo
+
     echo '<h2>Trying to add user to a course called TEST via webservices</h2>';
-    
+
     $course_info = api_get_course_info('TEST');
-    
-    if (!empty($course_info)) {    
+
+    if (!empty($course_info)) {
         $params = array('course'        => 'TEST', //Chamilo string course code
                         'user_id'       => $user_id,
                         'secret_key'    => $secret_key);
@@ -100,55 +139,55 @@ if (!empty($user_id) && is_numeric($user_id)) {
     } else {
         echo 'Course TEST does not exists please create one course with code "TEST"';
     }
-    
+
     if ($result == 1) {
         echo "User $user_id was added to course TEST";
     } else {
         echo $result;
-    }  
-    
+    }
+
     //4. Adding course Test to the Session Session1
-       
+
     $course_id_list = array (
-                            array('course_code' => 'TEST1'), 
+                            array('course_code' => 'TEST1'),
                             array('course_code' => 'TEST2')
                         );
     $params = array('coursessessions' => array(
                                                 array('original_course_id_values'   => $course_id_list,
                                                       'original_course_id_name'     => 'course_id_name',
                                                       'original_session_id_value'   => '1',
-                                                      'original_session_id_name'    => 'session_id_value')      
-                                                ),    
+                                                      'original_session_id_name'    => 'session_id_value')
+                                                ),
                     'secret_key' => $secret_key);
-    
+
     //$result = $client->call('WSSuscribeCoursesToSession', array('subscribeCoursesToSession' => $params));
-        
-    
-    
+
+
+
     // ------------------------
     //Calling the WSSubscribeUserToCourse
     /*
     $course_array = array(   'original_course_id_name' => 'TEST',
                              'original_course_id_value' => 'TEST'
                             );
-    
-    $user_array     = array('original_user_id_value' =>  $user_id, 
+
+    $user_array     = array('original_user_id_value' =>  $user_id,
                             'original_user_id_name' => 'name');
     $user_courses   = array();
-    
+
     $user_courses[] = array (   'course_id' => $course_array,
                                 'user_id'   => $user_array,
                                 'status'    => '1'
                             );
-    
+
     $params = array (
                     'userscourses'       => $user_courses,
                     'secret_key'         => $secret_key);
 
     $result = $client->call('WSSubscribeUserToCourse', array('subscribeUserToCourse' => $params));
     var_dump($result);*/
-    
-      
+
+
 } else {
     echo 'User was not created, activate the debug=true in the registration.soap.php file and see the error logs';
 }

+ 0 - 0
vendor/autoload.php