Permalink
Browse files

Fixing bug #4345: quiz report perf issues I fixed last year not worki…

…ng on mysql 3.23. We have JOIN ... ON for INNER JOIN but not JOIN in mysql 3.23. Not merging to 1.6 as requirements are bumped
  • Loading branch information...
1 parent 8e11a72 commit 6f4b73112d8c6bf778f2a2cf177d9939790c2880 mjollnir_ committed Feb 6, 2006
Showing with 8 additions and 8 deletions.
  1. +2 −2 mod/quiz/report/analysis/report.php
  2. +6 −6 mod/quiz/report/overview/report.php
@@ -83,9 +83,9 @@ function display($quiz, $cm, $course) { /// This function just displays the
}
$sql = 'SELECT qa.* FROM '.$CFG->prefix.'user u '.
- 'JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid ';
+ 'INNER JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid ';
if (!empty($currentgroup)) {
- $sql .= ' JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid AND gm.groupid = '.$currentgroup;
+ $sql .= ' INNER JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid AND gm.groupid = '.$currentgroup;
}
$sql .= ' WHERE qa.quiz = '.$quiz->id. // ULPGC ecastro
' AND ( qa.sumgrades >= '.$scorelimit.' ) ';
@@ -244,24 +244,24 @@ function display($quiz, $cm, $course) { /// This function just displays the
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';
if ($course->id != SITEID) { // this is too complicated, so just do it for each of the four cases.
if (!empty($currentgroup) && empty($noattempts)) {
- $from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'user_students us ON us.userid = u.id JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid '.
- 'JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid AND qa.quiz = '.$quiz->id;
+ $from = 'FROM '.$CFG->prefix.'user u INNER JOIN '.$CFG->prefix.'user_students us ON us.userid = u.id INNER JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid '.
+ 'INNER JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid AND qa.quiz = '.$quiz->id;
$where = ' WHERE us.course = '.$course->id.' AND gm.groupid = '.$currentgroup;
} else if (!empty($currentgroup) && !empty($noattempts)) {
- $from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'user_students us ON us.userid = u.id JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid '.
+ $from = 'FROM '.$CFG->prefix.'user u INNER JOIN '.$CFG->prefix.'user_students us ON us.userid = u.id INNER JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid '.
'LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid AND qa.quiz = '.$quiz->id;
$where = ' WHERE us.course = '.$course->id.' AND gm.groupid = '.$currentgroup.' AND qa.userid IS NULL';
} else if (empty($currentgroup) && empty($noattempts)) {
- $from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid ';
+ $from = 'FROM '.$CFG->prefix.'user u INNER JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid ';
$where = ' WHERE qa.quiz = '.$quiz->id;
} else if (empty($currentgroup) && !empty($noattempts)) {
- $from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'user_students us ON us.userid = u.id LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid AND qa.quiz = '.$quiz->id;
+ $from = 'FROM '.$CFG->prefix.'user u INNER JOIN '.$CFG->prefix.'user_students us ON us.userid = u.id LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid AND qa.quiz = '.$quiz->id;
$where = ' WHERE us.course = '.$course->id.' AND qa.userid IS NULL';
}
$countsql = 'SELECT COUNT(DISTINCT('.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where;
} else {
if (empty($noattempts)) {
- $from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid ';
+ $from = 'FROM '.$CFG->prefix.'user u INNER JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid ';
$where = ' WHERE qa.quiz = '.$quiz->id;
$countsql = 'SELECT COUNT(DISTINCT('.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where;
}

0 comments on commit 6f4b731

Please sign in to comment.