MDL-13678 "Change default number of rows per page on quiz reports" Made a new constan...
authorjamiesensei <jamiesensei>
Thu, 1 May 2008 07:08:28 +0000 (07:08 +0000)
committerjamiesensei <jamiesensei>
Thu, 1 May 2008 07:08:28 +0000 (07:08 +0000)
mod/quiz/report.php
mod/quiz/report/analysis/report.php
mod/quiz/report/grading/report.php
mod/quiz/report/overview/report.php
mod/quiz/report/reportlib.php [new file with mode: 0644]

index 4b24e6c..5f244bf 100644 (file)
@@ -2,8 +2,9 @@
 
 // This script uses installed report plugins to print quiz reports
 
-    require_once("../../config.php");
-    require_once("locallib.php");
+    require_once('../../config.php');
+    require_once($CFG->dirroot.'/mod/quiz/locallib.php');
+    require_once($CFG->dirroot.'/mod/quiz/report/reportlib.php');
 
     $id = optional_param('id',0,PARAM_INT);    // Course Module ID, or
     $q = optional_param('q',0,PARAM_INT);     // quiz ID
index dac42cf..67fc709 100644 (file)
@@ -32,18 +32,21 @@ class quiz_report extends quiz_default_report {
 
         // set Table and Analysis stats options
         if(!isset($SESSION->quiz_analysis_table)) {
-            $SESSION->quiz_analysis_table = array('attemptselection' => 0, 'lowmarklimit' => 0, 'pagesize' => 10);
+            $SESSION->quiz_analysis_table = array('attemptselection' => 0, 'lowmarklimit' => 0, 'pagesize' => QUIZ_REPORT_DEFAULT_PAGE_SIZE);
         }
 
         foreach($SESSION->quiz_analysis_table as $option => $value) {
-            $urlparam = optional_param($option, NULL);
+            $urlparam = optional_param($option, NULL, PARAM_INT);
             if($urlparam === NULL) {
                 $$option = $value;
-            }
-            else {
+            } else {
                 $$option = $SESSION->quiz_analysis_table[$option] = $urlparam;
             }
         }
+        if (!isset($pagesize) || ((int)$pagesize < 1) ){
+            $pagesize = QUIZ_REPORT_DEFAULT_PAGE_SIZE;
+        }
+
 
         $scorelimit = $quiz->sumgrades * $lowmarklimit/ 100;
 
@@ -323,9 +326,6 @@ class quiz_report extends quiz_default_report {
         $format_options->newlines = false;
 
         // Now it is time to page the data, simply slice the keys in the array
-        if (!isset($pagesize) || ((int)$pagesize < 1) ){
-            $pagesize = 10;
-        }
         $table->pagesize($pagesize, count($questions));
         $start = $table->get_page_start();
         $pagequestions = array_slice(array_keys($questions), $start, $pagesize);
@@ -381,7 +381,7 @@ class quiz_report extends quiz_default_report {
     }
 
 
-    function print_options_form($quiz, $cm, $attempts, $lowlimit=0, $pagesize=10) {
+    function print_options_form($quiz, $cm, $attempts, $lowlimit=0, $pagesize=QUIZ_REPORT_DEFAULT_PAGE_SIZE) {
         global $CFG, $USER;
         echo '<div class="controls">';
         echo '<form id="options" action="report.php" method="post">';
index de08bf6..af40baf 100644 (file)
@@ -254,7 +254,7 @@ class quiz_report extends quiz_default_report {
 
         // set up the pagesize
         $total  = count_records_sql('SELECT COUNT(DISTINCT('.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where);
-        $table->pagesize(10, $total);
+        $table->pagesize(QUIZ_REPORT_DEFAULT_PAGE_SIZE, $total);
 
         // get the attempts and process them
         if ($attempts = get_records_sql($select.$from.$where.$sort,$table->get_page_start(), $table->get_page_size())) {
index 650b58e..f2868d7 100644 (file)
@@ -68,10 +68,10 @@ class quiz_report extends quiz_default_report {
         // Set table options
         $noattempts = optional_param('noattempts', 0, PARAM_INT);
         $detailedmarks = optional_param('detailedmarks', 0, PARAM_INT);
-        $pagesize = optional_param('pagesize', 10, PARAM_INT);
+        $pagesize = optional_param('pagesize', 0, PARAM_INT);
         $reporturl = $CFG->wwwroot.'/mod/quiz/report.php?mode=overview';
         if ($pagesize < 1) {
-            $pagesize = 10;
+            $pagesize = QUIZ_REPORT_DEFAULT_PAGE_SIZE;
         }
         if (!$reviewoptions->scores) {
             $detailedmarks = 0;
diff --git a/mod/quiz/report/reportlib.php b/mod/quiz/report/reportlib.php
new file mode 100644 (file)
index 0000000..f08f332
--- /dev/null
@@ -0,0 +1,3 @@
+<?php
+define('QUIZ_REPORT_DEFAULT_PAGE_SIZE', 30);
+?>
\ No newline at end of file