Skip to content

Commit

Permalink
MDL-4655 course: Number of courses with summaries to display is confi…
Browse files Browse the repository at this point in the history
…gurable
  • Loading branch information
Frederic Massart committed Oct 18, 2012
1 parent ecfe814 commit 3b7bfbb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions admin/settings/appearance.php
Expand Up @@ -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'));
Expand Down
2 changes: 0 additions & 2 deletions admin/settings/frontpage.php
Expand Up @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions course/category.php
Expand Up @@ -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 '<form id="movecourses" action="category.php" method="post"><div>';
Expand Down
9 changes: 8 additions & 1 deletion course/lib.php
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion lang/en/admin.php
Expand Up @@ -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:<pre>
http://site.example.com/admin/cron.php?password=opensesame
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 3b7bfbb

Please sign in to comment.