mod/quiz: replace $db->Concat() with sql_concat()
This commit is contained in:
@@ -217,7 +217,7 @@ class quiz_report extends quiz_default_report {
|
||||
$table->setup();
|
||||
|
||||
// this sql is a join of the attempts table and the user table. I do this so I can sort by user name and attempt number (not id)
|
||||
$select = 'SELECT '.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS userattemptid, qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timefinish, u.id AS userid, u.firstname, u.lastname, u.picture ';
|
||||
$select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS userattemptid, qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timefinish, u.id AS userid, u.firstname, u.lastname, u.picture ';
|
||||
$from = 'FROM '.$CFG->prefix.'user u LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON (u.id = qa.userid AND qa.quiz = '.$quiz->id.') ';
|
||||
$where = 'WHERE u.id IN ('.$userids.') ';
|
||||
$where .= 'AND '.$db->IfNull('qa.attempt', '0').' != 0 ';
|
||||
@@ -237,7 +237,7 @@ class quiz_report extends quiz_default_report {
|
||||
}
|
||||
|
||||
// set up the pagesize
|
||||
$total = count_records_sql('SELECT COUNT(DISTINCT('.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where);
|
||||
$total = count_records_sql('SELECT COUNT(DISTINCT('.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where);
|
||||
$table->pagesize(10, $total);
|
||||
|
||||
// this is for getting the correct records for a given page
|
||||
@@ -330,7 +330,7 @@ class quiz_report extends quiz_default_report {
|
||||
$userids = implode(',', array_keys($users));
|
||||
|
||||
// this sql joins the attempts table and the user table
|
||||
$select = 'SELECT '.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS userattemptid,
|
||||
$select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS userattemptid,
|
||||
qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timefinish, qa.preview,
|
||||
u.id AS userid, u.firstname, u.lastname, u.picture ';
|
||||
$from = 'FROM '.$CFG->prefix.'user u LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON (u.id = qa.userid AND qa.quiz = '.$quiz->id.') ';
|
||||
|
||||
@@ -243,7 +243,7 @@ class quiz_report extends quiz_default_report {
|
||||
$contextlists = get_related_contexts_string(get_context_instance(CONTEXT_COURSE, $course->id));
|
||||
|
||||
// Construct the SQL
|
||||
$select = 'SELECT '.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, '.
|
||||
$select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, '.
|
||||
'qa.uniqueid as attemptuniqueid, qa.id AS attempt, u.id AS userid, u.firstname, u.lastname, u.picture, '.
|
||||
'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.
|
||||
@@ -279,12 +279,12 @@ class quiz_report extends quiz_default_report {
|
||||
$where = ' WHERE qa.quiz = '.$quiz->id.' AND qa.preview = 0';
|
||||
} // noattempts = 2 means we want all students, with or without attempts
|
||||
}
|
||||
$countsql = 'SELECT COUNT(DISTINCT('.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where;
|
||||
$countsql = 'SELECT COUNT(DISTINCT('.sql_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 ';
|
||||
$where = ' WHERE qa.quiz = '.$quiz->id.' AND qa.preview = 0';
|
||||
$countsql = 'SELECT COUNT(DISTINCT('.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where;
|
||||
$countsql = 'SELECT COUNT(DISTINCT('.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where;
|
||||
}
|
||||
}
|
||||
if (!$download) {
|
||||
|
||||
Reference in New Issue
Block a user