From f18f275bc3169060eab13894b19a97fbcefac1fc Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 5 Apr 2023 16:14:37 +0200 Subject: [PATCH] Fix allow teachers marking their own posts as the solution --- classes/ratings.php | 2 +- locallib.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/ratings.php b/classes/ratings.php index e130dfdbaa..899755d6d1 100644 --- a/classes/ratings.php +++ b/classes/ratings.php @@ -783,7 +783,7 @@ public static function moodleoverflow_user_can_rate($post, $modulecontext, $user } // Check the capability. - return $userid != $post->userid && capabilities::has(capabilities::RATE_POST, $modulecontext, $userid) + return capabilities::has(capabilities::RATE_POST, $modulecontext, $userid) && $post->reviewed == 1; } diff --git a/locallib.php b/locallib.php index 60c40029bb..64b8589ab0 100644 --- a/locallib.php +++ b/locallib.php @@ -380,7 +380,8 @@ function moodleoverflow_print_latest_discussions($moodleoverflow, $cm, $page = - $preparedarray[$i]['userupvoted'] = ($rating->rating ?? null) == RATING_UPVOTE; $preparedarray[$i]['userdownvoted'] = ($rating->rating ?? null) == RATING_DOWNVOTE; - $preparedarray[$i]['canchange'] = \mod_moodleoverflow\ratings::moodleoverflow_user_can_rate($firstpost, $context); + $preparedarray[$i]['canchange'] = \mod_moodleoverflow\ratings::moodleoverflow_user_can_rate($firstpost, $context) && + $startuser->id != $USER->id; $preparedarray[$i]['postid'] = $discussion->firstpost; // Go to the next discussion.