Skip to content

Commit

Permalink
Merge branch 'MDL-42779-34' of https://github.com/lucaboesch/moodle i…
Browse files Browse the repository at this point in the history
…nto MOODLE_34_STABLE
  • Loading branch information
David Monllao committed May 28, 2018
2 parents 3753139 + 000e6f4 commit 2bb95d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions course/classes/management_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,11 @@ public function category_bulk_actions(coursecat $category = null) {
* @param course_in_list $course The currently selected course.
* @param int $page The page being displayed.
* @param int $perpage The number of courses to display per page.
* @param string|null $viewmode The view mode the page is in, one out of 'default', 'combined', 'courses' or 'categories'.
* @return string
*/
public function course_listing(coursecat $category = null, course_in_list $course = null, $page = 0, $perpage = 20) {
public function course_listing(coursecat $category = null, course_in_list $course = null, $page = 0, $perpage = 20,
$viewmode = 'default') {

if ($category === null) {
$html = html_writer::start_div('select-a-category');
Expand Down Expand Up @@ -527,13 +529,13 @@ public function course_listing(coursecat $category = null, course_in_list $cours
$html .= html_writer::tag('h3', $category->get_formatted_name(),
array('id' => 'course-listing-title', 'tabindex' => '0'));
$html .= $this->course_listing_actions($category, $course, $perpage);
$html .= $this->listing_pagination($category, $page, $perpage);
$html .= $this->listing_pagination($category, $page, $perpage, false, $viewmode);
$html .= html_writer::start_tag('ul', array('class' => 'ml', 'role' => 'group'));
foreach ($category->get_courses($options) as $listitem) {
$html .= $this->course_listitem($category, $listitem, $courseid);
}
$html .= html_writer::end_tag('ul');
$html .= $this->listing_pagination($category, $page, $perpage, true);
$html .= $this->listing_pagination($category, $page, $perpage, true, $viewmode);
$html .= $this->course_bulk_actions($category);
$html .= html_writer::end_div();
return $html;
Expand All @@ -546,9 +548,10 @@ public function course_listing(coursecat $category = null, course_in_list $cours
* @param int $page The current page.
* @param int $perpage The number of courses to display per page.
* @param bool $showtotals Set to true to show the total number of courses and what is being displayed.
* @param string|null $viewmode The view mode the page is in, one out of 'default', 'combined', 'courses' or 'categories'.
* @return string
*/
protected function listing_pagination(coursecat $category, $page, $perpage, $showtotals = false) {
protected function listing_pagination(coursecat $category, $page, $perpage, $showtotals = false, $viewmode = 'default') {
$html = '';
$totalcourses = $category->get_courses_count();
$totalpages = ceil($totalcourses / $perpage);
Expand Down Expand Up @@ -582,7 +585,12 @@ protected function listing_pagination(coursecat $category, $page, $perpage, $sho
}
}
$items = array();
$baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id));
if ($viewmode !== 'default') {
$baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id,
'view' => $viewmode));
} else {
$baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id));
}
if ($page > 0) {
$items[] = $this->action_button(new moodle_url($baseurl, array('page' => 0)), get_string('first'));
$items[] = $this->action_button(new moodle_url($baseurl, array('page' => $page - 1)), get_string('prev'));
Expand Down
2 changes: 1 addition & 1 deletion course/management.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@
if ($displaycourselisting) {
echo $renderer->grid_column_start($coursesize, 'course-listing');
if (!$issearching) {
echo $renderer->course_listing($category, $course, $page, $perpage);
echo $renderer->course_listing($category, $course, $page, $perpage, $viewmode);
} else {
list($courses, $coursescount, $coursestotal) =
\core_course\management\helper::search_courses($search, $blocklist, $modulelist, $page, $perpage);
Expand Down

0 comments on commit 2bb95d9

Please sign in to comment.