MDL-4655 course: Number of courses with summaries to display is configurable

This commit is contained in:
Frederic Massart 2012-10-04 17:07:58 +08:00
parent ecfe814e0f
commit 3b7bfbb5b8
5 changed files with 22 additions and 8 deletions

View File

@ -178,6 +178,8 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$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'));

View File

@ -49,8 +49,6 @@ if (!during_initial_install()) { //do not use during installation
'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;

View File

@ -284,23 +284,28 @@ if ($subcategorieswereshown) {
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 '<form id="movecourses" action="category.php" method="post"><div>';

View File

@ -33,7 +33,14 @@ require_once($CFG->dirroot.'/course/format/lib.php');
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');

View File

@ -151,7 +151,8 @@ $string['configcookiesecure'] = 'If server is accepting only https connections i
$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:<pre>
http://site.example.com/admin/cron.php?password=opensesame
@ -364,6 +365,7 @@ $string['courserequests'] = 'Course requests';
$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';