Merge branch 'MDL-86869_500-single-view-overload' of https://github.com/alexkeel/moodle into MOODLE_500_STABLE
This commit is contained in:
@@ -88,7 +88,7 @@ abstract class screen {
|
||||
protected $items;
|
||||
|
||||
/** @var int Maximum number of students that can be shown on one page */
|
||||
protected static $maxperpage = 5000;
|
||||
protected static $maxperpage = 1000;
|
||||
|
||||
/**
|
||||
* List of allowed values for 'perpage' setting
|
||||
@@ -129,7 +129,7 @@ abstract class screen {
|
||||
|
||||
$cache = \cache::make_from_params(\cache_store::MODE_SESSION, 'gradereport_singleview', 'perpage');
|
||||
$perpage = optional_param('perpage', null, PARAM_INT);
|
||||
if (!in_array($perpage, self::$validperpage) && ($perpage !== 0)) {
|
||||
if ((!in_array($perpage, self::$validperpage) && $perpage != self::$maxperpage) && ($perpage !== 0)) {
|
||||
// Get from cache.
|
||||
$perpage = $cache->get(get_class($this));
|
||||
} else {
|
||||
@@ -441,7 +441,7 @@ abstract class screen {
|
||||
sort($pagingoptions);
|
||||
$pagingoptions = array_combine($pagingoptions, $pagingoptions);
|
||||
if ($numusers > self::$maxperpage) {
|
||||
$pagingoptions['0'] = self::$maxperpage;
|
||||
$pagingoptions[self::$maxperpage] = self::$maxperpage;
|
||||
} else {
|
||||
$pagingoptions['0'] = get_string('all');
|
||||
}
|
||||
@@ -461,6 +461,6 @@ abstract class screen {
|
||||
// The number of students per page is always limited even if it is claimed to be unlimited.
|
||||
$this->perpage = $this->perpage ?: self::$maxperpage;
|
||||
$perpagedata['pagingbar'] = $this->pager();
|
||||
return $OUTPUT->render_from_template('gradereport_singleview/perpage', $perpagedata);;
|
||||
return $OUTPUT->render_from_template('gradereport_singleview/perpage', $perpagedata);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ require_once($CFG->dirroot.'/lib/gradelib.php');
|
||||
require_once($CFG->dirroot.'/grade/lib.php');
|
||||
require_once($CFG->dirroot.'/grade/report/lib.php');
|
||||
|
||||
// This report may require a lot of memory and time on large courses.
|
||||
raise_memory_limit(MEMORY_HUGE);
|
||||
set_time_limit(120);
|
||||
|
||||
$courseid = required_param('id', PARAM_INT);
|
||||
$groupid = optional_param('group', null, PARAM_INT);
|
||||
$reset = optional_param('reset', 0, PARAM_BOOL);
|
||||
|
||||
@@ -75,6 +75,61 @@ Feature: Singleview report pagination
|
||||
And I should see "2" in the ".stickyfooter .pagination" "css_element"
|
||||
And I should not see "3" in the ".stickyfooter .pagination" "css_element"
|
||||
|
||||
Scenario: Teachers can view all students on singleview report
|
||||
Given "150" "users" exist with the following data:
|
||||
| username | student[count] |
|
||||
| firstname | Student |
|
||||
| lastname | [count] |
|
||||
| email | student[count]@example.com |
|
||||
And "150" "course enrolments" exist with the following data:
|
||||
| user | student[count] |
|
||||
| course | C1 |
|
||||
| role |student |
|
||||
When I am on the "Course 1" "grades > Grader report > View" page logged in as "teacher1"
|
||||
And I click on grade item menu "Test assignment one" of type "gradeitem" on "grader" page
|
||||
And I choose "Single view for this item" in the open action menu
|
||||
And I set the field "perpage" to "All"
|
||||
# There is also 1 header row.
|
||||
Then I should see "151" node occurrences of type "tr" in the "singleview-grades" "table"
|
||||
And ".stickyfooter .pagination" "css_element" should not exist
|
||||
|
||||
Scenario: Max perpage is 1000 and All is not available
|
||||
Given "1100" "users" exist with the following data:
|
||||
| username | student[count] |
|
||||
| firstname | Student |
|
||||
| lastname | [count] |
|
||||
| email | student[count]@example.com |
|
||||
And "1100" "course enrolments" exist with the following data:
|
||||
| user | student[count] |
|
||||
| course | C1 |
|
||||
| role | student |
|
||||
When I am on the "Course 1" "grades > Grader report > View" page logged in as "teacher1"
|
||||
And I click on grade item menu "Test assignment one" of type "gradeitem" on "grader" page
|
||||
And I choose "Single view for this item" in the open action menu
|
||||
Then the "perpage" select box should contain "1000"
|
||||
And the "perpage" select box should not contain "All"
|
||||
|
||||
Scenario: Page loads correctly with Max perpage limit
|
||||
Given "1100" "users" exist with the following data:
|
||||
| username | student[count] |
|
||||
| firstname | Student |
|
||||
| lastname | [count] |
|
||||
| email | student[count]@example.com |
|
||||
And "1100" "course enrolments" exist with the following data:
|
||||
| user | student[count] |
|
||||
| course | C1 |
|
||||
| role | student |
|
||||
When I am on the "Course 1" "grades > Grader report > View" page logged in as "teacher1"
|
||||
And I click on grade item menu "Test assignment one" of type "gradeitem" on "grader" page
|
||||
And I choose "Single view for this item" in the open action menu
|
||||
And I set the field "perpage" to "1000"
|
||||
Then I should see "1001" node occurrences of type "tr" in the "singleview-grades" "table"
|
||||
And I click on "2" "link" in the ".stickyfooter .pagination" "css_element"
|
||||
And I should see "101" node occurrences of type "tr" in the "singleview-grades" "table"
|
||||
And I should see "1" in the ".stickyfooter .pagination" "css_element"
|
||||
And I should see "2" in the ".stickyfooter .pagination" "css_element"
|
||||
And I should not see "3" in the ".stickyfooter .pagination" "css_element"
|
||||
|
||||
@javascript
|
||||
Scenario: The pagination bar is only displayed when there is more than one page on singleview report
|
||||
Given "21" "users" exist with the following data:
|
||||
|
||||
Reference in New Issue
Block a user