diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index acd62dfb1afc2..7ea3454264804 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -178,6 +178,8 @@ $temp->add(new admin_setting_configcheckbox('courselistshortnames', new lang_string('courselistshortnames', 'admin'), new lang_string('courselistshortnames_desc', 'admin'), 0)); + $temp->add(new admin_setting_configtext('coursesperpage', new lang_string('coursesperpage', 'admin'), new lang_string('configcoursesperpage', 'admin'), 20, PARAM_INT)); + $temp->add(new admin_setting_configtext('courseswithsummarieslimit', new lang_string('courseswithsummarieslimit', 'admin'), new lang_string('configcourseswithsummarieslimit', 'admin'), 10, PARAM_INT)); $ADMIN->add('appearance', $temp); $temp = new admin_settingpage('ajax', new lang_string('ajaxuse')); diff --git a/admin/settings/frontpage.php b/admin/settings/frontpage.php index 5a060a101bb7a..f4ecb5bbcfbf4 100644 --- a/admin/settings/frontpage.php +++ b/admin/settings/frontpage.php @@ -49,8 +49,6 @@ '10' => '10'))); $temp->add(new admin_setting_configtext('commentsperpage', new lang_string('commentsperpage', 'admin'), '', 15, PARAM_INT)); - $temp->add(new admin_setting_configtext('coursesperpage', new lang_string('coursesperpage', 'admin'), new lang_string('configcoursesperpage', 'admin'), 20, PARAM_INT)); - // front page default role $options = array(0=>new lang_string('none')); // roles to choose from $defaultfrontpageroleid = 0; diff --git a/course/category.php b/course/category.php index 1b822cc33a945..3ae02e7bb1c94 100644 --- a/course/category.php +++ b/course/category.php @@ -284,23 +284,28 @@ echo html_writer::table($table); } -// Print out all the courses +// Print out all the courses. $courses = get_courses_page($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.shortname,c.fullname,c.summary,c.visible', $totalcount, $page*$perpage, $perpage); $numcourses = count($courses); +// We can consider that we are using pagination when the total count of courses is different than the one returned. +$pagingmode = $totalcount != $numcourses; + if (!$courses) { + // There is no course to display. if (empty($subcategorieswereshown)) { echo $OUTPUT->heading(get_string("nocoursesyet")); } - -} else if ($numcourses <= COURSE_MAX_SUMMARIES_PER_PAGE and !$page and !$editingon) { +} else if ($numcourses <= $CFG->courseswithsummarieslimit and !$pagingmode and !$editingon) { + // We display courses with their summaries as we have not reached the limit, also we are not + // in paging mode and not allowed to edit either. echo $OUTPUT->box_start('courseboxes'); print_courses($category); echo $OUTPUT->box_end(); - } else { + // The conditions above have failed, we display a basic list of courses with paging/editing options. echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "/course/category.php?id=$category->id&perpage=$perpage"); echo '
'; diff --git a/course/lib.php b/course/lib.php index 72d94e910e21d..00bbf0df45b5d 100644 --- a/course/lib.php +++ b/course/lib.php @@ -33,7 +33,14 @@ define('COURSE_MAX_LOGS_PER_PAGE', 1000); // records define('COURSE_MAX_RECENT_PERIOD', 172800); // Two days, in seconds -define('COURSE_MAX_SUMMARIES_PER_PAGE', 10); // courses + +/** + * Number of courses to display when summaries are included. + * @var int + * @deprecated since 2.4, use $CFG->courseswithsummarieslimit instead. + */ +define('COURSE_MAX_SUMMARIES_PER_PAGE', 10); + define('COURSE_MAX_COURSES_PER_DROPDOWN',1000); // max courses in log dropdown before switching to optional define('COURSE_MAX_USERS_PER_DROPDOWN',1000); // max users in log dropdown before switching to optional define('FRONTPAGENEWS', '0'); diff --git a/lang/en/admin.php b/lang/en/admin.php index 6a2c0c84e4005..840cc95ebbb42 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -151,7 +151,8 @@ $string['configcountry'] = 'If you set a country here, then this country will be selected by default on new user accounts. To force users to choose a country, just leave this unset.'; $string['configcourserequestnotify'] = 'Type username of user to be notified when new course requested.'; $string['configcourserequestnotify2'] = 'Users who will be notified when a course is requested. Only users who can approve course requests are listed here.'; -$string['configcoursesperpage'] = 'Enter the number of courses to be display per page in a course listing.'; +$string['configcoursesperpage'] = 'Enter the number of courses to be displayed per page in a course listing.'; +$string['configcourseswithsummarieslimit'] = 'The maximum number of courses to display in a course listing including summaries before falling back to a simpler listing.'; $string['configcronclionly'] = 'If this is set, then the cron script can only be run from the command line instead of via the web. This overrides the cron password setting below.'; $string['configcronremotepassword'] = 'This means that the cron.php script cannot be run from a web browser without supplying the password using the following form of URL:
     http://site.example.com/admin/cron.php?password=opensesame
@@ -364,6 +365,7 @@
 $string['courserequestspending'] = 'Pending course requests';
 $string['courses'] = 'Courses';
 $string['coursesperpage'] = 'Courses per page';
+$string['courseswithsummarieslimit'] = 'Courses with summaries limit';
 $string['creatornewroleid'] = 'Creators\' role in new courses';
 $string['creatornewroleid_help'] = 'If the user does not already have the permission to manage the new course, the user is automatically enrolled using this role.';
 $string['cron'] = 'Cron';