diff --git a/mod/quiz/category.php b/mod/quiz/category.php
index 5b5ccf90b4c..6ed4b861004 100644
--- a/mod/quiz/category.php
+++ b/mod/quiz/category.php
@@ -28,6 +28,7 @@
$param->addcategory = optional_param('addcategory','',PARAM_ALPHA);
$param->edit = optional_param('edit',0,PARAM_INT);
$param->updateid = optional_param('updateid',0,PARAM_INT);
+ $param->page = optional_param('page',1,PARAM_INT);
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
@@ -113,7 +114,7 @@
}
// display the user interface
- $qcobject->display_user_interface();
+ $qcobject->display_user_interface($param->page);
print_footer($course);
diff --git a/mod/quiz/category_class.php b/mod/quiz/category_class.php
index 62c4a23a90f..e7998209374 100644
--- a/mod/quiz/category_class.php
+++ b/mod/quiz/category_class.php
@@ -5,6 +5,10 @@
* Used for handling changes to the quiz categories
*
*/
+
+// number of categories to display on page
+define( "PAGE_LENGTH",25 );
+
class quiz_category_object {
var $str;
@@ -17,6 +21,7 @@ class quiz_category_object {
var $categorystrings;
var $defaultcategory;
var $course;
+ var $topcount;
/**
* Constructor
@@ -49,6 +54,7 @@ class quiz_category_object {
$this->str->editcategory = get_string('editcategory', 'quiz');
$this->str->cancel = get_string('cancel');
$this->str->editcategories = get_string('editcategories', 'quiz');
+ $this->str->page = get_string('page');
$this->pixpath = $CFG->pixpath;
}
@@ -66,8 +72,9 @@ class quiz_category_object {
* Displays the user interface
*
* @param object modform
+* @param int $page page number to display (0=don't paginate)
*/
- function display_user_interface() {
+ function display_user_interface($page=10) {
$this->initialize();
/// Interface for adding a new category:
@@ -77,7 +84,10 @@ class quiz_category_object {
/// Interface for editing existing categories
print_heading_with_help($this->str->editcategories, 'categories', 'quiz');
- $this->output_edit_table();
+ $this->output_edit_table($page);
+ if ($this->topcount>PAGE_LENGTH) {
+ $this->display_page_numbers($page);
+ }
echo '
';
}
@@ -100,9 +110,36 @@ class quiz_category_object {
// create the array of id=>full_name strings
$this->categorystrings = $this->expanded_category_strings($this->categories);
+
+ // for pagination calculate number of 'top' categories and hence number of pages
+ // (pagination only based on top categories)
+ $count = 0;
+ foreach( $this->categories as $category ) {
+ if ($category->parent==0) {
+ ++$count;
+ }
+ }
+ $this->topcount = $count;
+ $this->pagecount = (integer) ceil( $count / PAGE_LENGTH );
}
+/**
+ * display list of page numbers for navigation
+ */
+ function display_page_numbers( $page=0 ) {
+ echo "