From ec1bf0f23db75178728489b51c09d7e94371a529 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Fri, 20 Apr 2012 15:48:28 +0200 Subject: [PATCH] MDL-27508 workshop manual allocator supports configurable page size for items pagination --- mod/workshop/allocation/manual/lib.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mod/workshop/allocation/manual/lib.php b/mod/workshop/allocation/manual/lib.php index f9b3eb22da4..d574cfa57b7 100644 --- a/mod/workshop/allocation/manual/lib.php +++ b/mod/workshop/allocation/manual/lib.php @@ -61,6 +61,13 @@ class workshop_manual_allocator implements workshop_allocator { global $PAGE; $mode = optional_param('mode', 'display', PARAM_ALPHA); + $perpage = optional_param('perpage', null, PARAM_INT); + + if ($perpage and $perpage > 0 and $perpage <= 1000) { + require_sesskey(); + set_user_preference('workshopallocation_manual_perpage', $perpage); + redirect($PAGE->url); + } $result = new workshop_allocation_result($this); @@ -141,9 +148,8 @@ class workshop_manual_allocator implements workshop_allocator { $output = $PAGE->get_renderer('workshopallocation_manual'); - $pagingvar = 'page'; - $page = optional_param($pagingvar, 0, PARAM_INT); - $perpage = 10; // todo let the user modify this + $page = optional_param('page', 0, PARAM_INT); + $perpage = get_user_preferences('workshopallocation_manual_perpage', 10); $hlauthorid = -1; // highlight this author $hlreviewerid = -1; // highlight this reviewer @@ -324,10 +330,11 @@ class workshop_manual_allocator implements workshop_allocator { $data->selfassessment = $this->workshop->useselfassessment; // prepare paging bar - $pagingbar = new paging_bar($numofparticipants, $page, $perpage, $PAGE->url, $pagingvar); + $pagingbar = new paging_bar($numofparticipants, $page, $perpage, $PAGE->url, 'page'); $pagingbarout = $output->render($pagingbar); + $perpageselector = $output->perpage_selector($perpage); - return $pagingbarout . $output->render($message) . $output->render($data) . $button . $pagingbarout; + return $pagingbarout . $output->render($message) . $output->render($data) . $button . $pagingbarout . $perpageselector; } /**