mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-71838 quiz reports: average rows calc can run out of memory
Should not use get_records when you mean record_exists.
This commit is contained in:
parent
30b8ad51f4
commit
1287ecaeff
1 changed files with 10 additions and 8 deletions
|
@ -70,23 +70,25 @@ class quiz_overview_table extends quiz_attempts_report_table {
|
||||||
$this->add_separator();
|
$this->add_separator();
|
||||||
|
|
||||||
if (!empty($this->groupstudentsjoins->joins)) {
|
if (!empty($this->groupstudentsjoins->joins)) {
|
||||||
$sql = "SELECT DISTINCT u.id
|
$hasgroupstudents = $DB->record_exists_sql("
|
||||||
|
SELECT 1
|
||||||
FROM {user} u
|
FROM {user} u
|
||||||
{$this->groupstudentsjoins->joins}
|
{$this->groupstudentsjoins->joins}
|
||||||
WHERE {$this->groupstudentsjoins->wheres}";
|
WHERE {$this->groupstudentsjoins->wheres}
|
||||||
$groupstudents = $DB->get_records_sql($sql, $this->groupstudentsjoins->params);
|
", $this->groupstudentsjoins->params);
|
||||||
if ($groupstudents) {
|
if ($hasgroupstudents) {
|
||||||
$this->add_average_row(get_string('groupavg', 'grades'), $this->groupstudentsjoins);
|
$this->add_average_row(get_string('groupavg', 'grades'), $this->groupstudentsjoins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->studentsjoins->joins)) {
|
if (!empty($this->studentsjoins->joins)) {
|
||||||
$sql = "SELECT DISTINCT u.id
|
$hasstudents = $DB->record_exists_sql("
|
||||||
|
SELECT 1
|
||||||
FROM {user} u
|
FROM {user} u
|
||||||
{$this->studentsjoins->joins}
|
{$this->studentsjoins->joins}
|
||||||
WHERE {$this->studentsjoins->wheres}";
|
WHERE {$this->studentsjoins->wheres}
|
||||||
$students = $DB->get_records_sql($sql, $this->studentsjoins->params);
|
" , $this->studentsjoins->params);
|
||||||
if ($students) {
|
if ($hasstudents) {
|
||||||
$this->add_average_row(get_string('overallaverage', 'grades'), $this->studentsjoins);
|
$this->add_average_row(get_string('overallaverage', 'grades'), $this->studentsjoins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue