MDL-46499 navigation: better enrolled course limit
We now user $CFG->navcourselimit to limit the number of courses shown in the navigation when browsing another users full profile. Previously it showed all courses which caused some slowdown.
This commit is contained in:
@@ -2277,7 +2277,14 @@ class global_navigation extends navigation_node {
|
||||
$userscourses = enrol_get_users_courses($user->id);
|
||||
$userscoursesnode = $usernode->add(get_string('courses'));
|
||||
|
||||
$count = 0;
|
||||
foreach ($userscourses as $usercourse) {
|
||||
if ($count === (int)$CFG->navcourselimit) {
|
||||
$url = new moodle_url('/user/profile.php', array('id' => $user->id, 'showallcourses' => 1));
|
||||
$userscoursesnode->add(get_string('showallcourses'), $url);
|
||||
break;
|
||||
}
|
||||
$count++;
|
||||
$usercoursecontext = context_course::instance($usercourse->id);
|
||||
$usercourseshortname = format_string($usercourse->shortname, true, array('context' => $usercoursecontext));
|
||||
$usercoursenode = $userscoursesnode->add($usercourseshortname, new moodle_url('/user/view.php', array('id'=>$user->id, 'course'=>$usercourse->id)), self::TYPE_CONTAINER);
|
||||
|
||||
+1
-1
@@ -386,7 +386,7 @@ if (!isset($hiddenfields['mycourses'])) {
|
||||
$courselisting .= ', ';
|
||||
}
|
||||
$shown++;
|
||||
if(!$showallcourses && $shown==20) {
|
||||
if (!$showallcourses && $shown == $CFG->navcourselimit) {
|
||||
$url = new moodle_url('/user/profile.php', array('id' => $user->id, 'showallcourses' => 1));
|
||||
$courselisting .= html_writer::link($url, '...', array('title' => get_string('viewmore')));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user