From 78c3b48f31c2613cc7bdb72a718d25b26b377dd7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 18 Mar 2021 14:06:52 +0100 Subject: [PATCH] Replace custom queries with entities --- public/main/admin/user_move_stats.php | 10 +-- public/main/announcements/announcements.php | 7 +- public/main/cron/check_lp_total_time.php | 41 ++++----- public/main/dropbox/dropbox_functions.inc.php | 4 +- public/main/group/member_settings.php | 6 +- public/main/group/tutor_settings.php | 14 ++-- public/main/inc/ajax/myspace.ajax.php | 4 +- public/main/inc/lib/certificate.lib.php | 23 +++-- public/main/inc/lib/course.lib.php | 54 ++++++------ public/main/inc/lib/groupmanager.lib.php | 71 +++++++--------- public/main/inc/lib/myspace.lib.php | 8 +- public/main/inc/lib/sortable_table.class.php | 7 +- public/main/inc/lib/tracking.lib.php | 62 +++++++------- public/main/lp/learnpath.class.php | 25 +++--- public/main/lp/lp_report.php | 4 +- public/main/lp/scorm.class.php | 7 +- public/main/mySpace/course.php | 4 +- public/main/mySpace/myStudents.php | 66 ++++++++------- public/main/tracking/lp_report.php | 5 +- public/main/tracking/total_time.php | 26 ++++-- public/main/webservices/lp.php | 12 +-- public/main/wiki/wiki.inc.php | 3 +- public/main/work/student_work.php | 84 +++++++++++-------- public/main/work/work.lib.php | 76 +++++------------ public/main/work/work_list.php | 14 ++-- public/main/work/work_list_all.php | 4 +- src/CourseBundle/Entity/CGlossary.php | 7 +- src/CourseBundle/Entity/CGroup.php | 10 ++- src/CourseBundle/Entity/CSurvey.php | 5 +- .../CStudentPublicationRepository.php | 21 ++++- 30 files changed, 344 insertions(+), 340 deletions(-) diff --git a/public/main/admin/user_move_stats.php b/public/main/admin/user_move_stats.php index 23f6ba5dc7..c693ce89ef 100644 --- a/public/main/admin/user_move_stats.php +++ b/public/main/admin/user_move_stats.php @@ -86,7 +86,6 @@ if (isset($_REQUEST['load_ajax'])) { } //} $user_id = (int) $_REQUEST['user_id']; - $new_course_list = SessionManager::get_course_list_by_session_id($new_session_id); $course_founded = false; @@ -123,6 +122,7 @@ if (isset($_REQUEST['load_ajax'])) { // Begin with the import process $course_info = api_get_course_info($origin_course_code); $course_id = $course_info['real_id']; + $course = api_get_course_entity($course_id); $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); @@ -288,15 +288,15 @@ if (isset($_REQUEST['load_ajax'])) { //Getting all information of that lp_item_id $score = Tracking::get_avg_student_score( $user_id, - $origin_course_code, + $course, [$data['lp_id']], - $origin_session_id + $session ); $progress = Tracking::get_avg_student_progress( $user_id, - $origin_course_code, + $course, [$data['lp_id']], - $origin_session_id + $session ); $result_message['LP_VIEW'][$data['lp_id']] = [ 'score' => $score, diff --git a/public/main/announcements/announcements.php b/public/main/announcements/announcements.php index 38c505f1c5..361d558197 100644 --- a/public/main/announcements/announcements.php +++ b/public/main/announcements/announcements.php @@ -51,14 +51,13 @@ $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $isTutor = false; if (!empty($group_id)) { $groupEntity = api_get_group_entity($group_id); - $groupProperties = GroupManager::get_group_properties($group_id); $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups'), ]; $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), - 'name' => get_lang('Group area').' '.$groupProperties['name'], + 'name' => get_lang('Group area').' '.$groupEntity->getName(), ]; if (false === $allowToEdit) { @@ -68,7 +67,7 @@ if (!empty($group_id)) { $allowToEdit = true; } // Last chance ... students can send announcements - if (GroupManager::TOOL_PRIVATE_BETWEEN_USERS == $groupProperties['announcements_state']) { + if (GroupManager::TOOL_PRIVATE_BETWEEN_USERS == $groupEntity->getAnnouncementsState()) { $allowStudentInGroupToSend = true; } } @@ -488,7 +487,7 @@ switch ($action) { } $element = CourseManager::addUserGroupMultiSelect($form, []); } else { - $element = CourseManager::addGroupMultiSelect($form, $groupProperties, []); + $element = CourseManager::addGroupMultiSelect($form, $groupEntity, []); } $form->addHtml(''); diff --git a/public/main/cron/check_lp_total_time.php b/public/main/cron/check_lp_total_time.php index ab1870e227..664250ebaa 100644 --- a/public/main/cron/check_lp_total_time.php +++ b/public/main/cron/check_lp_total_time.php @@ -1,12 +1,16 @@ getCode(); $users = CourseManager::get_user_list_from_course_code( $courseCode, @@ -48,9 +51,9 @@ foreach ($sessions as $session) { ); foreach ($users as $user) { - $result = compareLpTimeAndCourseTime($user, $courseInfo, $sessionId); + $result = compareLpTimeAndCourseTime($user, $course, $sessionId); if ($result) { - $counter++; + ++$counter; } if ($counter > $max) { @@ -73,22 +76,22 @@ foreach($courses as $courseInfo) { }*/ /** - * @param array $user - * @param array $courseInfo - * @param int $sessionId + * @param array $user + * @param Course $course + * @param int $sessionId * * @return bool */ -function compareLpTimeAndCourseTime($user, $courseInfo, $sessionId = 0) +function compareLpTimeAndCourseTime($user, Course $course, $sessionId = 0) { $userId = $user['user_id']; $defaultValue = 600; // 10 min - $courseCode = $courseInfo['code']; - $courseId = $courseInfo['real_id']; + $courseCode = $course->getCode(); + $courseId = $course->getId(); $totalLpTime = Tracking::get_time_spent_in_lp( $userId, - $courseCode, + $course, [], $sessionId ); @@ -108,8 +111,8 @@ function compareLpTimeAndCourseTime($user, $courseInfo, $sessionId = 0) $totalLpTimeFormatted = api_time_to_hms($totalLpTime); $diff = $totalLpTime - $totalCourseTime; - $content = PHP_EOL."User: ".$user['user_id']." - Total course: $totalCourseTimeFormatted / Total LP: $totalLpTimeFormatted".PHP_EOL; - $content .= PHP_EOL."Diff: ".api_time_to_hms($diff).PHP_EOL; + $content = PHP_EOL.'User: '.$user['user_id']." - Total course: $totalCourseTimeFormatted / Total LP: $totalLpTimeFormatted".PHP_EOL; + $content .= PHP_EOL.'Diff: '.api_time_to_hms($diff).PHP_EOL; $url = api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$userId.'&course='.$courseCode.'&id_session='.$sessionId; $content .= Display::url('Check', $url, ['target' => '_blank']); $content .= PHP_EOL; @@ -135,15 +138,15 @@ function compareLpTimeAndCourseTime($user, $courseInfo, $sessionId = 0) $lpId = $item['lp_id']; $link = api_get_path(WEB_CODE_PATH).'mySpace/lp_tracking.php?cidReq='.$courseCode. '&course='.$courseCode.'&origin=&lp_id='.$lpId.'&student_id='.$userId.'&id_session='.$sessionId; - $content .= "total_time to be reduced = ".api_time_to_hms($item['total_time']).PHP_EOL; + $content .= 'total_time to be reduced = '.api_time_to_hms($item['total_time']).PHP_EOL; $content .= Display::url('See report before update', $link, ['target' => '_blank']).PHP_EOL; - $content .= "SQL with possible fix:".PHP_EOL; + $content .= 'SQL with possible fix:'.PHP_EOL; if ($item['total_time'] < $defaultValue) { - $content .= "Skip because total_time is too short. total_time: ".$item['total_time'].' value to rest'.$defaultValue.PHP_EOL; + $content .= 'Skip because total_time is too short. total_time: '.$item['total_time'].' value to rest'.$defaultValue.PHP_EOL; continue; } - $content .= "UPDATE c_lp_item_view SET total_time = total_time - '$defaultValue' WHERE iid = ".$item['iid'].";".PHP_EOL.PHP_EOL; + $content .= "UPDATE c_lp_item_view SET total_time = total_time - '$defaultValue' WHERE iid = ".$item['iid'].';'.PHP_EOL.PHP_EOL; } } } diff --git a/public/main/dropbox/dropbox_functions.inc.php b/public/main/dropbox/dropbox_functions.inc.php index 2c1ed48511..8c02c905f7 100644 --- a/public/main/dropbox/dropbox_functions.inc.php +++ b/public/main/dropbox/dropbox_functions.inc.php @@ -1045,8 +1045,8 @@ function store_add_dropbox($file = [], $work = null) if (0 === strpos($rec, 'user_')) { $new_work_recipients[] = substr($rec, strlen('user_')); } elseif (0 === strpos($rec, 'group_')) { - $groupInfo = GroupManager::get_group_properties(substr($rec, strlen('group_'))); - $userList = GroupManager::get_subscribed_users($groupInfo); + $group = api_get_group_entity(substr($rec, strlen('group_'))); + $userList = GroupManager::get_subscribed_users($group); foreach ($userList as $usr) { if (!in_array($usr['user_id'], $new_work_recipients) && $usr['user_id'] != $_user['user_id']) { $new_work_recipients[] = $usr['user_id']; diff --git a/public/main/group/member_settings.php b/public/main/group/member_settings.php index 477f7016cd..b031408c4f 100644 --- a/public/main/group/member_settings.php +++ b/public/main/group/member_settings.php @@ -150,7 +150,7 @@ if (!empty($complete_user_list)) { } // Group members -$group_member_list = GroupManager::get_subscribed_users($current_group); +$group_member_list = GroupManager::get_subscribed_users($groupEntity); $selected_users = []; if (!empty($group_member_list)) { @@ -183,12 +183,12 @@ if ($form->validate()) { } // Returning to the group area (note: this is inconsistent with the rest of chamilo) - $cat = GroupManager::get_category_from_group($current_group['iid']); + $cat = GroupManager::get_category_from_group($group_id); $categoryId = 0; if ($cat) { $categoryId = $cat['iid']; } - $max_member = $current_group['max_student']; + $max_member = $groupEntity->getMaxStudent(); if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && diff --git a/public/main/group/tutor_settings.php b/public/main/group/tutor_settings.php index ed3b9f35f4..150762b7a8 100644 --- a/public/main/group/tutor_settings.php +++ b/public/main/group/tutor_settings.php @@ -2,6 +2,9 @@ /* For licensing terms, see /license.txt */ +use Chamilo\CoreBundle\Framework\Container; +use Chamilo\CourseBundle\Entity\CGroup; + require_once __DIR__.'/../inc/global.inc.php'; $this_section = SECTION_COURSES; $current_course_tool = TOOL_GROUP; @@ -10,9 +13,8 @@ $current_course_tool = TOOL_GROUP; api_protect_course_script(true); $group_id = api_get_group_id(); -$groupRepo = \Chamilo\CoreBundle\Framework\Container::getGroupRepository(); -/** @var \Chamilo\CourseBundle\Entity\CGroup $groupEntity */ -$groupEntity = $groupRepo->find($group_id); +$groupRepo = Container::getGroupRepository(); +$groupEntity = api_get_group_entity($group_id); $current_group = GroupManager::get_group_properties($group_id); $nameTools = get_lang('Edit this group'); @@ -101,7 +103,7 @@ $complete_user_list = CourseManager::get_user_list_from_course_code( $possible_users = []; $userGroup = new UserGroup(); -$subscribedUsers = GroupManager::get_subscribed_users($current_group); +$subscribedUsers = GroupManager::get_subscribed_users($groupEntity); if ($subscribedUsers) { $subscribedUsers = array_column($subscribedUsers, 'user_id'); } @@ -157,13 +159,13 @@ if ($form->validate()) { $values = $form->exportValues(); // Storing the tutors (we first remove all the tutors and then add only those who were selected) - GroupManager::unsubscribe_all_tutors($current_group['iid']); + GroupManager::unsubscribe_all_tutors($group_id); if (isset($_POST['group_tutors']) && count($_POST['group_tutors']) > 0) { GroupManager::subscribeTutors($values['group_tutors'], $groupEntity); } // Returning to the group area (note: this is inconsistent with the rest of chamilo) - $cat = GroupManager::get_category_from_group($current_group['iid']); + $cat = GroupManager::get_category_from_group($group_id); $categoryId = null; $max_member = null; if (!empty($cat)) { diff --git a/public/main/inc/ajax/myspace.ajax.php b/public/main/inc/ajax/myspace.ajax.php index e07a126251..394f3d2725 100644 --- a/public/main/inc/ajax/myspace.ajax.php +++ b/public/main/inc/ajax/myspace.ajax.php @@ -48,11 +48,13 @@ switch ($action) { foreach ($sessionList as $session) { $courses = $session['courses']; $sessionId = $session['session_id']; + $sessionEntity = api_get_session_entity($sessionId); $session['session_name']; $totalCourse = 0; $totalSessionAverage = 0; foreach ($courses as &$course) { - $average = Tracking::get_avg_student_progress($userId, $course['course_code'], [], $sessionId); + $courseEntity = api_get_course_entity($course['real_id']); + $average = Tracking::get_avg_student_progress($userId, $courseEntity, [], $sessionEntity); $totalSessionAverage += $average; $totalCourse++; if (false !== $average) { diff --git a/public/main/inc/lib/certificate.lib.php b/public/main/inc/lib/certificate.lib.php index 53c2409da5..4b9d39ec21 100644 --- a/public/main/inc/lib/certificate.lib.php +++ b/public/main/inc/lib/certificate.lib.php @@ -732,12 +732,9 @@ class Certificate extends Model foreach ($sessions as $session) { $allCoursesApproved = []; foreach ($session['courses'] as $course) { - $courseInfo = api_get_course_info_by_id($course['real_id']); - $courseCode = $courseInfo['code']; - - $category = $gradeBookRepo->findOneBy( - ['course' => $course['real_id'], 'session' => $session['session_id']] - ); + $course = api_get_course_entity($course['real_id']); + $courseId = $course->getId(); + $category = $gradeBookRepo->findOneBy(['course' => $course, 'session' => $session['session_id']]); /*$gradebookCategories = Category::load( null, @@ -758,25 +755,25 @@ class Certificate extends Model // Find time spent in LP $timeSpent = Tracking::get_time_spent_in_lp( $this->user_id, - $courseCode, + $course, [], $session['session_id'] ); - if (!isset($courseList[$course['real_id']])) { - $courseList[$course['real_id']]['approved'] = false; - $courseList[$course['real_id']]['time_spent'] = 0; + if (!isset($courseList[$courseId])) { + $courseList[$courseId]['approved'] = false; + $courseList[$courseId]['time_spent'] = 0; } if ($result) { - $courseList[$course['real_id']]['approved'] = true; - $coursesApproved[$course['real_id']] = $courseInfo['title']; + $courseList[$courseId]['approved'] = true; + $coursesApproved[$courseId] = $course->getTitle(); // Find time spent in LP //$totalTimeInLearningPaths += $timeSpent; $allCoursesApproved[] = true; } - $courseList[$course['real_id']]['time_spent'] += $timeSpent; + $courseList[$courseId]['time_spent'] += $timeSpent; } } diff --git a/public/main/inc/lib/course.lib.php b/public/main/inc/lib/course.lib.php index 612d945e07..45ab13ac8e 100644 --- a/public/main/inc/lib/course.lib.php +++ b/public/main/inc/lib/course.lib.php @@ -428,7 +428,8 @@ class CourseManager Database::query($sql); // Erase user student publications (works) in the course - by André Boivin - if (!empty($userList)) { + // @todo this should be handled by doctrine. + /*if (!empty($userList)) { foreach ($userList as $userId) { // Getting all work from user $workList = getWorkPerUser($userId); @@ -444,7 +445,7 @@ class CourseManager } } } - } + }*/ // Unsubscribe user from all blogs in the course. $sql = "DELETE FROM ".Database::get_course_table(TABLE_BLOGS_REL_USER)." @@ -1282,7 +1283,7 @@ class CourseManager * Return user info array of all users registered in a course * This only returns the users that are registered in this actual course, not linked courses. * - * @param string $course_code + * @param string $courseCode * @param int $sessionId * @param string $limit * @param string $order_by the field to order the users by. @@ -1303,7 +1304,7 @@ class CourseManager * @return array|int */ public static function get_user_list_from_course_code( - $course_code = null, + $courseCode, $sessionId = 0, $limit = null, $order_by = null, @@ -1323,13 +1324,17 @@ class CourseManager $sessionTable = Database::get_main_table(TABLE_MAIN_SESSION); $sessionId = (int) $sessionId; - $course_code = Database::escape_string($course_code); - $courseInfo = api_get_course_info($course_code); + $courseCode = Database::escape_string($courseCode); + $courseInfo = api_get_course_info($courseCode); $courseId = 0; if (!empty($courseInfo)) { $courseId = $courseInfo['real_id']; } - + $session = null; + if (!empty($sessionId)) { + $session = api_get_session_entity($sessionId); + } + $course = api_get_course_entity($courseId); $where = []; if (empty($order_by)) { $order_by = 'user.lastname, user.firstname'; @@ -1422,7 +1427,7 @@ class CourseManager if ($return_count) { $sql = " SELECT COUNT(*) as count"; } else { - if (empty($course_code)) { + if (empty($courseCode)) { $sql = 'SELECT DISTINCT course.title, course.code, @@ -1454,7 +1459,7 @@ class CourseManager $sqlInjectJoins "; - if (!empty($course_code)) { + if (!empty($courseId)) { $sql .= " AND course_rel_user.c_id = $courseId"; } $where[] = ' course_rel_user.c_id IS NOT NULL '; @@ -1568,7 +1573,6 @@ class CourseManager } $sessionId = isset($user['session_id']) ? $user['session_id'] : 0; - $course_code = isset($user['code']) ? $user['code'] : null; $sessionName = isset($user['session_name']) ? ' ('.$user['session_name'].') ' : ''; if ($add_reports) { @@ -1628,7 +1632,7 @@ class CourseManager $category = Category:: load( null, null, - $course_code, + $courseCode, null, null, $sessionId @@ -1643,7 +1647,7 @@ class CourseManager } foreach ($extra_fields as $extra) { - if ('ruc' == $extra['1']) { + if ('ruc' === $extra['1']) { continue; } @@ -1669,7 +1673,7 @@ class CourseManager $category = Category:: load( null, null, - $course_code, + $courseCode, null, null, $sessionId @@ -1680,18 +1684,15 @@ class CourseManager $report_info['certificate'] = Display::label(get_lang('Yes'), 'success'); } - $progress = intval( - Tracking::get_avg_student_progress( - $user['user_id'], - $course_code, - [], - $sessionId - ) + $progress = (int) Tracking::get_avg_student_progress( + $user['user_id'], + $course, + [], + $session ); $report_info['progress_100'] = 100 == $progress ? Display::label(get_lang('Yes'), 'success') : Display::label(get_lang('No')); $report_info['progress'] = $progress."%"; - 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']]; @@ -6080,17 +6081,12 @@ class CourseManager /** * Shows the form for sending a message to a specific group or user. * - * @param FormValidator $form - * @param array $groupInfo - * @param array $to - * * @return HTML_QuickForm_element */ - public static function addGroupMultiSelect($form, $groupInfo, $to = []) + public static function addGroupMultiSelect(FormValidator $form, CGroup $group, $to = []) { - $groupUsers = GroupManager::get_subscribed_users($groupInfo); - $groupEntity = api_get_group_entity($groupInfo['iid']); - $array = self::buildSelectOptions([$groupEntity], $groupUsers, $to); + $groupUsers = GroupManager::get_subscribed_users($group); + $array = self::buildSelectOptions([$group], $groupUsers, $to); $result = []; foreach ($array as $content) { diff --git a/public/main/inc/lib/groupmanager.lib.php b/public/main/inc/lib/groupmanager.lib.php index add9cda9ad..80c6f3ebf3 100644 --- a/public/main/inc/lib/groupmanager.lib.php +++ b/public/main/inc/lib/groupmanager.lib.php @@ -3,9 +3,12 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; +use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Framework\Container; use Chamilo\CourseBundle\Entity\CGroup; use Chamilo\CourseBundle\Entity\CGroupCategory; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Criteria; /** * This library contains some functions for group-management. @@ -549,9 +552,10 @@ class GroupManager $result['chat_state'] = $db_object->chat_state; $result['self_registration_allowed'] = $db_object->self_registration_allowed; $result['self_unregistration_allowed'] = $db_object->self_unregistration_allowed; - $result['count_users'] = count( + $result['count_users'] = 0; + /*$result['count_users'] = count( self::get_subscribed_users($result) - ); + );*/ /*$result['count_tutor'] = count( self::get_subscribed_tutors($result) );*/ @@ -1625,60 +1629,45 @@ class GroupManager /** * Get all subscribed users (members) from a group. * - * @param array $groupInfo - * * @return array An array with information of all users from the given group. * (user_id, firstname, lastname, email) */ - public static function get_subscribed_users($groupInfo) + public static function get_subscribed_users(CGroup $group) { - if (empty($groupInfo)) { - return []; + //$order = api_sort_by_first_name() ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname'; + $order = ['lastname'=> Criteria::DESC, 'firstname'=> Criteria::ASC]; + if (api_sort_by_first_name()) { + $order = ['firstname' => Criteria::ASC, 'lastname' => Criteria::ASC]; } - - $table_user = Database::get_main_table(TABLE_MAIN_USER); - $table_group_user = Database::get_course_table(TABLE_GROUP_USER); - $order_clause = api_sort_by_first_name() ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname'; $orderListByOfficialCode = api_get_setting('order_user_list_by_official_code'); if ('true' === $orderListByOfficialCode) { - $order_clause = ' ORDER BY u.official_code, u.firstname, u.lastname'; + //$order = ' ORDER BY u.official_code, u.firstname, u.lastname'; + $order = ['officialCode' => Criteria::ASC, 'firstname' => Criteria::ASC, 'lastname' => Criteria::ASC]; } - $group_id = (int) $groupInfo['iid']; - - if (empty($group_id)) { - return []; + $users = $group->getMembers(); + $userList = []; + foreach ($users as $groupRelUser) { + $userList[] = $groupRelUser->getUser(); } - $course_id = api_get_course_int_id(); + $criteria = Criteria::create(); + $criteria->orderBy($order); + $users = new ArrayCollection($userList); + $users = $users->matching($criteria); - $sql = "SELECT - ug.iid, - u.id as user_id, - u.lastname, - u.firstname, - u.email, - u.username - FROM $table_user u - INNER JOIN $table_group_user ug - ON (ug.user_id = u.id) - WHERE - ug.group_id = $group_id - $order_clause"; - - $db_result = Database::query($sql); - $users = []; - while ($user = Database::fetch_object($db_result)) { - $users[$user->user_id] = [ - 'user_id' => $user->user_id, - 'firstname' => $user->firstname, - 'lastname' => $user->lastname, - 'email' => $user->email, - 'username' => $user->username, + $list = []; + foreach ($users as $user) { + $list[$user->getId()] = [ + 'user_id' => $user->getId(), + 'firstname' => $user->getFirstname(), + 'lastname' => $user->getLastname(), + 'email' => $user->getEmail(), + 'username' => $user->getUsername(), ]; } - return $users; + return $list; } /** diff --git a/public/main/inc/lib/myspace.lib.php b/public/main/inc/lib/myspace.lib.php index 814d2b4819..816992995c 100644 --- a/public/main/inc/lib/myspace.lib.php +++ b/public/main/inc/lib/myspace.lib.php @@ -347,7 +347,7 @@ class MySpace //'image_small' => $courseInfo['course_image'], //'image_large' => $courseInfo['course_image_large'], 'time_spent' => api_time_to_hms(Tracking::get_time_spent_on_the_course($userId, $courseId)), - 'student_progress' => round(Tracking::get_avg_student_progress($userId, $courseCode)), + 'student_progress' => round(Tracking::get_avg_student_progress($userId, $course)), 'student_score' => $avg_score, 'student_message' => Container::getForumPostRepository()->countUserForumPosts($user, $course), 'student_assignments' => Container::getStudentPublicationRepository()->countUserPublications($user, $course), @@ -1574,7 +1574,7 @@ class MySpace $nb_progress_lp += $progress_tmp[1]; $score_tmp = Tracking::get_avg_student_score( $userId, - $courseCode, + $course, [], null, true @@ -1749,7 +1749,7 @@ class MySpace ); $progress_tmp = Tracking::get_avg_student_progress( $userId, - $courseCode, + $course, [], null, true @@ -1994,7 +1994,7 @@ class MySpace $time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id); $progress_tmp = Tracking::get_avg_student_progress( $row_user->user_id, - $courseCode, + $course, [], $session_id, true diff --git a/public/main/inc/lib/sortable_table.class.php b/public/main/inc/lib/sortable_table.class.php index a78124b720..cd82684c96 100644 --- a/public/main/inc/lib/sortable_table.class.php +++ b/public/main/inc/lib/sortable_table.class.php @@ -408,7 +408,12 @@ class SortableTable extends HTML_Table if (count($this->form_actions) > 0) { $params = $this->get_sortable_table_param_string().'&'.$this->get_additional_url_paramstring(); - $html .= '