Skip to content

Commit 125cc5a

Browse files
authored
Merge pull request #126 from learnweb/fix/allow-self-vote-solution
Fix allow teachers marking their own posts as solution
2 parents da009fd + f18f275 commit 125cc5a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

classes/ratings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ public static function moodleoverflow_user_can_rate($post, $modulecontext, $user
783783
}
784784

785785
// Check the capability.
786-
return $userid != $post->userid && capabilities::has(capabilities::RATE_POST, $modulecontext, $userid)
786+
return capabilities::has(capabilities::RATE_POST, $modulecontext, $userid)
787787
&& $post->reviewed == 1;
788788
}
789789

locallib.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ function moodleoverflow_print_latest_discussions($moodleoverflow, $cm, $page = -
380380

381381
$preparedarray[$i]['userupvoted'] = ($rating->rating ?? null) == RATING_UPVOTE;
382382
$preparedarray[$i]['userdownvoted'] = ($rating->rating ?? null) == RATING_DOWNVOTE;
383-
$preparedarray[$i]['canchange'] = \mod_moodleoverflow\ratings::moodleoverflow_user_can_rate($firstpost, $context);
383+
$preparedarray[$i]['canchange'] = \mod_moodleoverflow\ratings::moodleoverflow_user_can_rate($firstpost, $context) &&
384+
$startuser->id != $USER->id;
384385
$preparedarray[$i]['postid'] = $discussion->firstpost;
385386

386387
// Go to the next discussion.

0 commit comments

Comments
 (0)