-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.1.9, 4.2.7, 4.3.4, 5.0
-
MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE, MOODLE_500_STABLE
-
MDL-81519-main
-
-
-
MDL-36011 added some unusual code where it produces empty rows until the number of rows in the table is equal to the desired page size which can be seen here.
In certain situations, the user can make the page size any number they want. For example one million. This can result in a ridiculous amount of markup being generated for no good reason and can bring down the webserver.
To see this:
- Create a course with a quiz with a single question and enrol a student
- As the student, attempt the quiz
- As the admin browse to the quiz and press the "Results" tab
- Under "Display options" set "Page size" to 1000000
- Press "Show report"
- Boom
The page will take forever to load, and using the network inspector you will see that a ridiculous amount of data is being transferred for a table that has only one meaningful row.
This exact thing happened to us when an academic accidentally pasted a student number in to that field. This resulted in almost 500mb of useless markup being generated and sent to the browser.
There are two issues here:
- It should not be possible to put such a huge number in that field, instead it should probably be a dropdown with sensible values like 25, 50, 100
- The finish_html method shouldn't produce empty rows
For 2, MDL-36011 seems to indicate it was done because when the headers are printed, it's not known how many total rows of data there will be. So to make the number of rows known at the time headers are printed, it was decided to just print as many rows as the specified page size. I guess what is being referred to in MDL-36011 is this part where the show/hide link needs to specify what it is controlling (the rows in this case). However there is actually enough information present at the time the table headers are printed to know the exact row count, so this hack/workaround was never needed in the first place and instead the correct number of rows should have been calculated.
Original issue description
Changing the display option "page size" on quiz reports has a big impact on page size and load time.
For example on a quiz with one student and one attempt, with the default page size of 30 the response request is ~300kB
On the same quiz, if you change the page size to 30000 the page size is then 25.35MB
The page takes also longer to load.
It seems weird to have a bigger page when the actual data is unchanged.
Step to reproduce:
- As a teacher
- Create a quiz
- Add a question to that quiz
- As a student
- Make an attempt on the quiz
- As a teacher
- go to the "Results" page of the quiz
- keep the "page size" at 30 and "Show report"
- check the browser's console network tab to see page size
- change "page size" to 3000 and show report
- check the browser's console again and notice that the page size is bigger
This size difference is because for some reason Moodle is creating rows in the result table based on the "page size" parameter value instead of the actual DB results.
The extra rows have the class `emptyrow` that makes them hidden but they are still in the DOM for no reason