Skip to content

Commit a7dd09f

Browse files
author
Laur0r
authored
Merge pull request #106 from NinaHerrmann/fix/sendreviewnotification
Fix/sendreviewnotification
2 parents 32430fe + ea79ad9 commit a7dd09f

File tree

8 files changed

+29
-11
lines changed

8 files changed

+29
-11
lines changed

classes/review.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public static function get_first_review_post($moodleoverflowid, $afterpostid = n
9393
$afterdiscussionid = $DB->get_field('moodleoverflow_posts', 'discussion', ['id' => $afterpostid],
9494
MUST_EXIST);
9595

96-
$orderby = 'CASE WHEN (p.discussion > :afterdiscussionid OR (p.discussion = :afterdiscussionid2 AND p.id > :afterpostid)) THEN 0 ELSE 1 END, ';
96+
$orderby = 'CASE WHEN (p.discussion > :afterdiscussionid OR (p.discussion = :afterdiscussionid2 AND p.id
97+
> :afterpostid)) THEN 0 ELSE 1 END, ';
9798
$params['afterdiscussionid'] = $afterdiscussionid;
9899
$params['afterdiscussionid2'] = $afterdiscussionid;
99100
$params['afterpostid'] = $afterpostid;

classes/task/send_mails.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,16 @@ public function send_review_notifications() {
106106
if ($moodleoverflow == null || $moodleoverflow->id != $postinfo->mid) {
107107
$cm = get_coursemodule_from_instance('moodleoverflow', $postinfo->mid, 0, false, MUST_EXIST);
108108
$modulecontext = \context_module::instance($cm->id);
109-
$usersto = get_users_by_capability($modulecontext, 'mod/moodleoverflow:reviewpost');
109+
$userswithcapability = get_users_by_capability($modulecontext, 'mod/moodleoverflow:reviewpost');
110+
$coursecontext = \context_course::instance($course->id);
111+
$usersenrolled = get_enrolled_users($coursecontext);
112+
$usersto = array();
113+
foreach ($userswithcapability as $user) {
114+
if (in_array($user, $usersenrolled)) {
115+
array_push($usersto, $user);
116+
}
117+
}
118+
110119
$moodleoverflow = $DB->get_record('moodleoverflow', ['id' => $postinfo->mid], '*', MUST_EXIST);
111120
}
112121

grade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2323
*/
2424
require_once(__DIR__ . "/../../config.php");
25-
25+
require_login();
2626
$id = required_param('id', PARAM_INT);
2727

2828
$cm = get_coursemodule_from_id('moodleoverflow', $id, 0, false, MUST_EXIST);

lang/en/moodleoverflow.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@
405405
$string['gradesupdated'] = 'Grades updated';
406406
$string['taskupdategrades'] = 'Moodleoverflow maintenance job to update grades';
407407

408-
// Anonymous Feature
408+
// Anonymous Feature.
409409
$string['anonymous'] = 'Anonymous';
410410
$string['anonymous_help'] = 'This will hide username from all question (and answers).<br>WARNING: Once the questions (and answers) are anonymized, this cannot be reversed.<br>The setting can only be changed to a higher degree of anonymity.';
411411
$string['anonymous:only_questions'] = 'Only questioners (Irreversible!)';
@@ -419,8 +419,9 @@
419419
$string['desc:anonymous'] = 'No names will be displayed.';
420420
$string['resetanonymous_warning'] = 'Are you sure? If you are in production, <b>this is most certainly a bad decision</b> because your students and teachers posted their questions and answers, believing they would remain anonymous. <br><br><b>{$a->fullanoncount}</b> forums are currently fully anonymized, and in <b>{$a->questionanoncount}</b> additional forums the questioners are anonymized.<br><br><b>In all these forums, the real names of posters will be displayed again, even in already existing posts!</b><br><br>There is no way of reverting those changes!</br>';
421421

422-
// Review feature
422+
// Review feature.
423423
$string['review'] = 'Review';
424+
$string['reviewpost'] = 'Review a post';
424425
$string['review_help'] = 'Select what has to be approved by a teacher before being shown to students.';
425426
$string['nothing'] = 'Nothing';
426427
$string['questions'] = 'Questions';

locallib.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,8 @@ function moodleoverflow_print_discussion($course, $cm, $moodleoverflow, $discuss
907907
echo '<div id="moodleoverflow-posts">';
908908

909909
// Print the other posts.
910-
echo moodleoverflow_print_posts_nested($course, $cm, $moodleoverflow, $discussion, $post, $istracked, $posts, null, $usermapping);
910+
echo moodleoverflow_print_posts_nested($course, $cm, $moodleoverflow, $discussion, $post, $istracked, $posts,
911+
null, $usermapping);
911912

912913
echo '</div>';
913914
}
@@ -1599,7 +1600,7 @@ function moodleoverflow_add_new_post($post) {
15991600

16001601
// Add the post to the database.
16011602
$post->id = $DB->insert_record('moodleoverflow_posts', $post);
1602-
$DB->set_field('moodleoverflow_posts', 'message', $post->message, array('id' => $post->id)); // ??
1603+
$DB->set_field('moodleoverflow_posts', 'message', $post->message, array('id' => $post->id));
16031604
moodleoverflow_add_attachment($post, $moodleoverflow, $cm);
16041605

16051606
if ($post->reviewed) {
@@ -1819,7 +1820,7 @@ function moodleoverflow_discussion_update_last_post($discussionid) {
18191820
return false;
18201821
}
18211822

1822-
// Find the last reviewed post of the discussion. (even if user has review capability, because it is written to DB)
1823+
// Find the last reviewed post of the discussion. (even if user has review capability, because it is written to DB).
18231824
$sql = "SELECT id, userid, modified
18241825
FROM {moodleoverflow_posts}
18251826
WHERE discussion = ?

markposts.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
}
107107

108108
// Mark all the discussions read.
109-
if (!\mod_moodleoverflow\readtracking::moodleoverflow_mark_discussion_read($discussionid, context_module::instance($cm->id), $user->id)) {
109+
if (!\mod_moodleoverflow\readtracking::moodleoverflow_mark_discussion_read($discussionid,
110+
context_module::instance($cm->id), $user->id)) {
110111

111112
// Display an error, if something failes.
112113
$message = get_string('markreadfailed', 'moodleoverflow');

settings.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@
9797
$settings->add(new admin_setting_configcheckbox('moodleoverflow/allowreview',
9898
get_string('allowreview', 'moodleoverflow'), get_string('allowreview_desc', 'moodleoverflow'), 1));
9999

100-
$settings->add(new admin_setting_configtext('moodleoverflow/reviewpossibleaftertime', get_string('reviewpossibleaftertime', 'moodleoverflow'),
101-
get_string('reviewpossibleaftertime_desc', 'moodleoverflow'), 3600, PARAM_INT));
100+
$settings->add(new admin_setting_configtext('moodleoverflow/reviewpossibleaftertime',
101+
get_string('reviewpossibleaftertime', 'moodleoverflow'),
102+
get_string('reviewpossibleaftertime_desc', 'moodleoverflow'), 1800, PARAM_INT));
102103

103104
// Set scales for the reputation.
104105
$votesettings = [];

tests/locallib_test.php

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function tearDown(): void {
4444

4545
/**
4646
* Test subscription using automatic subscription on create.
47+
* @covers \mod_moodleoverflow\subscriptions Subscription of users as default.
4748
*/
4849
public function test_moodleoverflow_auto_subscribe_on_create() {
4950
global $DB;
@@ -76,6 +77,7 @@ public function test_moodleoverflow_auto_subscribe_on_create() {
7677

7778
/**
7879
* Test subscription using forced subscription on create.
80+
* @covers \mod_moodleoverflow\subscriptions sorced Subscription of users.
7981
*/
8082
public function test_moodleoverflow_forced_subscribe_on_create() {
8183
global $DB;
@@ -107,6 +109,7 @@ public function test_moodleoverflow_forced_subscribe_on_create() {
107109

108110
/**
109111
* Test subscription using optional subscription on create.
112+
* @covers \mod_moodleoverflow\subscriptions optional subscription.
110113
*/
111114
public function test_moodleoverflow_optional_subscribe_on_create() {
112115
global $DB;
@@ -137,6 +140,7 @@ public function test_moodleoverflow_optional_subscribe_on_create() {
137140

138141
/**
139142
* Test subscription using disallow subscription on create.
143+
* @covers \mod_moodleoverflow\subscriptions prohibit Subscription of users.
140144
*/
141145
public function test_moodleoverflow_disallow_subscribe_on_create() {
142146
global $DB;

0 commit comments

Comments
 (0)