Merge branch 'wip-MDL-57511-master' of git://github.com/Beedell/moodle
This commit is contained in:
@@ -1179,6 +1179,10 @@ function is_enrolled(context $context, $user = null, $withcapability = '', $only
|
||||
* Returns an array of joins, wheres and params that will limit the group of
|
||||
* users to only those enrolled and with given capability (if specified).
|
||||
*
|
||||
* Note this join will return duplicate rows for users who have been enrolled
|
||||
* several times (e.g. as manual enrolment, and as self enrolment). You may
|
||||
* need to use a SELECT DISTINCT in your query (see get_enrolled_sql for example).
|
||||
*
|
||||
* @param context $context
|
||||
* @param string $prefix optional, a prefix to the user id column
|
||||
* @param string|array $capability optional, may include a capability name, or array of names.
|
||||
|
||||
@@ -389,7 +389,8 @@ abstract class quiz_attempts_report_table extends table_sql {
|
||||
public function base_sql(\core\dml\sql_join $allowedstudentsjoins) {
|
||||
global $DB;
|
||||
|
||||
$fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') . ' AS uniqueid,';
|
||||
// Please note this uniqueid column is not the same as quiza.uniqueid.
|
||||
$fields = 'DISTINCT ' . $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') . ' AS uniqueid,';
|
||||
|
||||
if ($this->qmsubselect) {
|
||||
$fields .= "\n(CASE WHEN $this->qmsubselect THEN 1 ELSE 0 END) AS gradedattempt,";
|
||||
|
||||
@@ -90,6 +90,14 @@ class quiz_overview_report_testcase extends advanced_testcase {
|
||||
$DB->insert_record('quiz_attempts', $data);
|
||||
}
|
||||
|
||||
// This line is not really necessary for the test asserts below,
|
||||
// but what it does is add an extra user row returned by
|
||||
// get_enrolled_with_capabilities_join because of a second enrolment.
|
||||
// The extra row returned used to make $table->query_db complain
|
||||
// about duplicate records. So this is really a test that an extra
|
||||
// student enrolment does not cause duplicate records in this query.
|
||||
$generator->enrol_user($student2->id, $course->id, null, 'self');
|
||||
|
||||
// Actually getting the SQL to run is quite hard. Do a minimal set up of
|
||||
// some objects.
|
||||
$context = context_module::instance($quiz->cmid);
|
||||
|
||||
Reference in New Issue
Block a user