Skip to content

Commit 2b67274

Browse files
committed
use join statement for better readability
1 parent 0285f47 commit 2b67274

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ function moodleoverflow_can_create_attachment($moodleoverflow, $context) {
639639
}
640640

641641
/**
642-
* Obtain grades from plugin's database tab
642+
* Get the grades of a moodleoverflow instance for all users or a single user.
643643
*
644644
* @param stdClass $moodleoverflow moodleoverflow object
645645
* @param int $userid optional userid, 0 means all users.
@@ -652,8 +652,9 @@ function moodleoverflow_get_user_grades($moodleoverflow, $userid = 0) {
652652
$params = ["moodleoverflowid" => $moodleoverflow->id];
653653

654654
$sql = "SELECT u.id AS userid, g.grade AS rawgrade
655-
FROM {user} u, {moodleoverflow_grades} g
656-
WHERE u.id = g.userid AND g.moodleoverflowid = :moodleoverflowid";
655+
FROM {user} u
656+
JOIN {moodleoverflow_grades} g ON u.id = g.userid
657+
WHERE g.moodleoverflowid = :moodleoverflowid";
657658

658659
if ($userid) {
659660
$sql .= ' AND u.id = :userid ';

0 commit comments

Comments
 (0)