Skip to content

Commit

Permalink
MDL-61951 core_grading: SQL improvements for grading_instance join
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed May 11, 2018
1 parent 6f213a2 commit b3252ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions grade/grading/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public static function get_contexts_for_userid(int $userid) : contextlist {
FROM {context} c
JOIN {grading_areas} a ON a.contextid = c.id
JOIN {grading_definitions} d ON d.areaid = a.id
LEFT JOIN {grading_instances} i ON i.definitionid = d.id
LEFT JOIN {grading_instances} i ON i.definitionid = d.id AND i.raterid = :raterid
WHERE c.contextlevel = :contextlevel
AND (d.usercreated = :usercreated OR d.usermodified = :usermodified OR i.raterid = :raterid)";
AND (d.usercreated = :usercreated OR d.usermodified = :usermodified OR i.id IS NOT NULL)";
$params = [
'usercreated' => $userid,
'usermodified' => $userid,
Expand Down Expand Up @@ -152,9 +152,9 @@ protected static function export_definitions(\context $context, array $subcontex
];

if (!empty($userid)) {
$join .= ' LEFT JOIN {grading_instances} i ON i.definitionid = d.id';
$join .= ' LEFT JOIN {grading_instances} i ON i.definitionid = d.id AND i.raterid = :raterid';
$select .= ' AND (usercreated = :usercreated
OR usermodified = :usermodified OR i.raterid = :raterid)';
OR usermodified = :usermodified OR i.id IS NOT NULL)';
$params['usercreated'] = $userid;
$params['usermodified'] = $userid;
$params['raterid'] = $userid;
Expand Down

0 comments on commit b3252ec

Please sign in to comment.