Commit 3af7eee0 authored by Shamim Rezaie's avatar Shamim Rezaie
Browse files

Merge branch 'MDL-75072-master' of https://github.com/junpataleta/moodle

parents 718cb293 d4fe1b30
...@@ -44,7 +44,7 @@ class backup_forum_activity_structure_step extends backup_activity_structure_ste ...@@ -44,7 +44,7 @@ class backup_forum_activity_structure_step extends backup_activity_structure_ste
'maxbytes', 'maxattachments', 'forcesubscribe', 'trackingtype', 'maxbytes', 'maxattachments', 'forcesubscribe', 'trackingtype',
'rsstype', 'rssarticles', 'timemodified', 'warnafter', 'rsstype', 'rssarticles', 'timemodified', 'warnafter',
'blockafter', 'blockperiod', 'completiondiscussions', 'completionreplies', 'blockafter', 'blockperiod', 'completiondiscussions', 'completionreplies',
'completionposts', 'displaywordcount', 'lockdiscussionafter', 'grade_forum', 'usecoursefullname')); 'completionposts', 'displaywordcount', 'lockdiscussionafter', 'grade_forum'));
$discussions = new backup_nested_element('discussions'); $discussions = new backup_nested_element('discussions');
......
...@@ -73,8 +73,7 @@ class forum { ...@@ -73,8 +73,7 @@ class forum {
'displaywordcount' => $forum->should_display_word_count(), 'displaywordcount' => $forum->should_display_word_count(),
'lockdiscussionafter' => $forum->get_lock_discussions_after(), 'lockdiscussionafter' => $forum->get_lock_discussions_after(),
'duedate' => $forum->get_due_date(), 'duedate' => $forum->get_due_date(),
'cutoffdate' => $forum->get_cutoff_date(), 'cutoffdate' => $forum->get_cutoff_date()
'usecoursefullname' => $forum->use_course_fullname()
]; ];
}, $forums); }, $forums);
} }
......
...@@ -107,8 +107,6 @@ class forum { ...@@ -107,8 +107,6 @@ class forum {
private $duedate; private $duedate;
/** @var int $cutoffdate Timestamp after which forum posts will no longer be accepted */ /** @var int $cutoffdate Timestamp after which forum posts will no longer be accepted */
private $cutoffdate; private $cutoffdate;
/** @var bool $usecoursefullname Whether to use course full name instead of short name in notifications */
private $usecoursefullname;
/** /**
* Constructor * Constructor
...@@ -146,7 +144,6 @@ class forum { ...@@ -146,7 +144,6 @@ class forum {
* @param int $lockdiscussionafter Timestamp after which discussions should be locked * @param int $lockdiscussionafter Timestamp after which discussions should be locked
* @param int $duedate Timestamp that represents the due date for forum posts * @param int $duedate Timestamp that represents the due date for forum posts
* @param int $cutoffdate Timestamp after which forum posts will no longer be accepted * @param int $cutoffdate Timestamp after which forum posts will no longer be accepted
* @param bool $usecoursefullname Whether to use course full name instead of short name in notifications
*/ */
public function __construct( public function __construct(
context $context, context $context,
...@@ -181,8 +178,7 @@ class forum { ...@@ -181,8 +178,7 @@ class forum {
bool $displaywordcount, bool $displaywordcount,
int $lockdiscussionafter, int $lockdiscussionafter,
int $duedate, int $duedate,
int $cutoffdate, int $cutoffdate
bool $usecoursefullname = false
) { ) {
$this->context = $context; $this->context = $context;
$this->coursemodule = $coursemodule; $this->coursemodule = $coursemodule;
...@@ -217,7 +213,6 @@ class forum { ...@@ -217,7 +213,6 @@ class forum {
$this->lockdiscussionafter = $lockdiscussionafter; $this->lockdiscussionafter = $lockdiscussionafter;
$this->duedate = $duedate; $this->duedate = $duedate;
$this->cutoffdate = $cutoffdate; $this->cutoffdate = $cutoffdate;
$this->usecoursefullname = $usecoursefullname;
} }
/** /**
...@@ -674,13 +669,4 @@ class forum { ...@@ -674,13 +669,4 @@ class forum {
return $this->is_discussion_time_locked($discussion); return $this->is_discussion_time_locked($discussion);
} }
/**
* Should use course full name instead of short name in notifications?
*
* @return bool
*/
public function use_course_fullname(): bool {
return $this->usecoursefullname;
}
} }
...@@ -104,8 +104,7 @@ class entity { ...@@ -104,8 +104,7 @@ class entity {
$record->displaywordcount, $record->displaywordcount,
$record->lockdiscussionafter, $record->lockdiscussionafter,
$record->duedate, $record->duedate,
$record->cutoffdate, $record->cutoffdate
$record->usecoursefullname ?? false
); );
} }
......
...@@ -155,7 +155,7 @@ class forum_post implements \renderable, \templatable { ...@@ -155,7 +155,7 @@ class forum_post implements \renderable, \templatable {
$data = $this->export_for_template_shared($renderer); $data = $this->export_for_template_shared($renderer);
return $data + array( return $data + array(
'id' => html_entity_decode($this->post->id), 'id' => html_entity_decode($this->post->id),
'coursename' => html_entity_decode($this->get_forum_coursename()), 'coursename' => html_entity_decode($this->get_coursename()),
'courselink' => html_entity_decode($this->get_courselink()), 'courselink' => html_entity_decode($this->get_courselink()),
'forumname' => html_entity_decode($this->get_forumname()), 'forumname' => html_entity_decode($this->get_forumname()),
'showdiscussionname' => html_entity_decode($this->get_showdiscussionname()), 'showdiscussionname' => html_entity_decode($this->get_showdiscussionname()),
...@@ -197,7 +197,7 @@ class forum_post implements \renderable, \templatable { ...@@ -197,7 +197,7 @@ class forum_post implements \renderable, \templatable {
$data = $this->export_for_template_shared($renderer); $data = $this->export_for_template_shared($renderer);
return $data + array( return $data + array(
'id' => $this->post->id, 'id' => $this->post->id,
'coursename' => $this->get_forum_coursename(), 'coursename' => $this->get_coursename(),
'courselink' => $this->get_courselink(), 'courselink' => $this->get_courselink(),
'forumname' => $this->get_forumname(), 'forumname' => $this->get_forumname(),
'showdiscussionname' => $this->get_showdiscussionname(), 'showdiscussionname' => $this->get_showdiscussionname(),
...@@ -485,19 +485,6 @@ class forum_post implements \renderable, \templatable { ...@@ -485,19 +485,6 @@ class forum_post implements \renderable, \templatable {
)); ));
} }
/**
* The name of the course that the forum is in, based on forum setting.
*
* @return string
*/
public function get_forum_coursename() {
if ($this->forum->usecoursefullname) {
return $this->get_coursefullname();
} else {
return $this->get_coursename();
}
}
/** /**
* The name of the forum. * The name of the forum.
* *
......
...@@ -327,7 +327,8 @@ class send_user_notifications extends \core\task\adhoc_task { ...@@ -327,7 +327,8 @@ class send_user_notifications extends \core\task\adhoc_task {
'sitefullname' => format_string($site->fullname), 'sitefullname' => format_string($site->fullname),
'siteshortname' => format_string($site->shortname), 'siteshortname' => format_string($site->shortname),
'courseidnumber' => $data->get_courseidnumber(), 'courseidnumber' => $data->get_courseidnumber(),
'coursename' => $data->get_forum_coursename(), 'coursefullname' => $data->get_coursefullname(),
'courseshortname' => $data->get_coursename(),
]; ];
$postsubject = html_to_text(get_string('postmailsubject', 'forum', $a), 0); $postsubject = html_to_text(get_string('postmailsubject', 'forum', $a), 0);
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
<FIELD NAME="completionposts" TYPE="int" LENGTH="9" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Nonzero if a certain number of posts or replies (total) are required to mark this forum complete for a user."/> <FIELD NAME="completionposts" TYPE="int" LENGTH="9" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Nonzero if a certain number of posts or replies (total) are required to mark this forum complete for a user."/>
<FIELD NAME="displaywordcount" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> <FIELD NAME="displaywordcount" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="lockdiscussionafter" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> <FIELD NAME="lockdiscussionafter" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="usecoursefullname" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
......
...@@ -338,17 +338,21 @@ function xmldb_forum_upgrade($oldversion) { ...@@ -338,17 +338,21 @@ function xmldb_forum_upgrade($oldversion) {
// Automatically generated Moodle v4.0.0 release upgrade line. // Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this. // Put any upgrade step following this.
if ($oldversion < 2022041901) { if ($oldversion < 2022062700) {
// Define field usecoursefullname to be added to forum. // Unset $CFG->forum_usecoursefullname.
unset_config('forum_usecoursefullname');
// Define field usecoursefullname to be dropped from forum.
$table = new xmldb_table('forum'); $table = new xmldb_table('forum');
$field = new xmldb_field('usecoursefullname', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', $field = new xmldb_field('usecoursefullname');
'lockdiscussionafter');
// Conditionally launch add field usecoursefullname. // Conditionally launch drop field usecoursefullname.
if (!$dbman->field_exists($table, $field)) { if ($dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field); $dbman->drop_field($table, $field);
} }
upgrade_mod_savepoint(true, 2022041901, 'forum');
// Forum savepoint reached.
upgrade_mod_savepoint(true, 2022062700, 'forum');
} }
return true; return true;
......
...@@ -159,7 +159,6 @@ class mod_forum_external extends external_api { ...@@ -159,7 +159,6 @@ class mod_forum_external extends external_api {
'numdiscussions' => new external_value(PARAM_INT, 'Number of discussions in the forum', VALUE_OPTIONAL), 'numdiscussions' => new external_value(PARAM_INT, 'Number of discussions in the forum', VALUE_OPTIONAL),
'cancreatediscussions' => new external_value(PARAM_BOOL, 'If the user can create discussions', VALUE_OPTIONAL), 'cancreatediscussions' => new external_value(PARAM_BOOL, 'If the user can create discussions', VALUE_OPTIONAL),
'lockdiscussionafter' => new external_value(PARAM_INT, 'After what period a discussion is locked', VALUE_OPTIONAL), 'lockdiscussionafter' => new external_value(PARAM_INT, 'After what period a discussion is locked', VALUE_OPTIONAL),
'usecoursefullname' => new external_value(PARAM_INT, 'Whether to use course full name for notifications'),
'istracked' => new external_value(PARAM_BOOL, 'If the user is tracking the forum', VALUE_OPTIONAL), 'istracked' => new external_value(PARAM_BOOL, 'If the user is tracking the forum', VALUE_OPTIONAL),
'unreadpostscount' => new external_value(PARAM_INT, 'The number of unread posts for tracked forums', 'unreadpostscount' => new external_value(PARAM_INT, 'The number of unread posts for tracked forums',
VALUE_OPTIONAL), VALUE_OPTIONAL),
......
...@@ -138,7 +138,6 @@ $string['configsubscriptiontype'] = 'Default setting for subscription mode.'; ...@@ -138,7 +138,6 @@ $string['configsubscriptiontype'] = 'Default setting for subscription mode.';
$string['configshortpost'] = 'Any post under this length (in characters not including HTML) is considered short (see below).'; $string['configshortpost'] = 'Any post under this length (in characters not including HTML) is considered short (see below).';
$string['configtrackingtype'] = 'Default setting for read tracking.'; $string['configtrackingtype'] = 'Default setting for read tracking.';
$string['configtrackreadposts'] = 'Set to \'yes\' if you want to track read/unread for each user.'; $string['configtrackreadposts'] = 'Set to \'yes\' if you want to track read/unread for each user.';
$string['configusecoursefullname'] = 'Default setting to use course full name instead of course short name for notifications.';
$string['configusermarksread'] = 'If \'yes\', the user must manually mark a post as read. If \'no\', when the post is viewed it is marked as read.'; $string['configusermarksread'] = 'If \'yes\', the user must manually mark a post as read. If \'no\', when the post is viewed it is marked as read.';
$string['confirmsubscribediscussion'] = 'Do you really want to subscribe to discussion \'{$a->discussion}\' in forum \'{$a->forum}\'?'; $string['confirmsubscribediscussion'] = 'Do you really want to subscribe to discussion \'{$a->discussion}\' in forum \'{$a->forum}\'?';
$string['confirmunsubscribediscussion'] = 'Do you really want to unsubscribe from discussion \'{$a->discussion}\' in forum \'{$a->forum}\'?'; $string['confirmunsubscribediscussion'] = 'Do you really want to unsubscribe from discussion \'{$a->discussion}\' in forum \'{$a->forum}\'?';
...@@ -525,7 +524,7 @@ $string['postincontext'] = 'See this post in context'; ...@@ -525,7 +524,7 @@ $string['postincontext'] = 'See this post in context';
$string['postmailinfo'] = 'This is a copy of a message posted in {$a}.'; $string['postmailinfo'] = 'This is a copy of a message posted in {$a}.';
$string['postmailnow'] = '<p>This post will be mailed out immediately to all forum subscribers.</p>'; $string['postmailnow'] = '<p>This post will be mailed out immediately to all forum subscribers.</p>';
$string['postmailreply'] = 'To reply click on this link: {$a}'; $string['postmailreply'] = 'To reply click on this link: {$a}';
$string['postmailsubject'] = '{$a->coursename}: {$a->subject}'; $string['postmailsubject'] = '{$a->courseshortname}: {$a->subject}';
$string['postrating1'] = 'Mostly separate knowing'; $string['postrating1'] = 'Mostly separate knowing';
$string['postrating2'] = 'Separate and connected'; $string['postrating2'] = 'Separate and connected';
$string['postrating3'] = 'Mostly connected knowing'; $string['postrating3'] = 'Mostly connected knowing';
...@@ -744,8 +743,6 @@ $string['unsubscribealldone'] = 'All optional forum subscriptions were removed. ...@@ -744,8 +743,6 @@ $string['unsubscribealldone'] = 'All optional forum subscriptions were removed.
$string['unsubscribeallempty'] = 'You are not subscribed to any forums. To disable all notifications from this server go to Messaging in My Profile Settings.'; $string['unsubscribeallempty'] = 'You are not subscribed to any forums. To disable all notifications from this server go to Messaging in My Profile Settings.';
$string['unsubscribed'] = 'Unsubscribed'; $string['unsubscribed'] = 'Unsubscribed';
$string['unsubscribeshort'] = 'Unsubscribe'; $string['unsubscribeshort'] = 'Unsubscribe';
$string['usecoursefullname'] = 'Use course full name in notifications';
$string['usecoursefullname_help'] = 'Use course full name instead of course short name for notifications.';
$string['useexperimentalui'] = 'Use experimental nested discussion view'; $string['useexperimentalui'] = 'Use experimental nested discussion view';
$string['usermarksread'] = 'Manual message read marking'; $string['usermarksread'] = 'Manual message read marking';
$string['usernavigation'] = 'User navigation'; $string['usernavigation'] = 'User navigation';
......
...@@ -184,10 +184,6 @@ function forum_update_instance($forum, $mform) { ...@@ -184,10 +184,6 @@ function forum_update_instance($forum, $mform) {
$forum->assesstimefinish = 0; $forum->assesstimefinish = 0;
} }
if (empty($forum->usecoursefullname)) {
$forum->usecoursefullname = 0;
}
$oldforum = $DB->get_record('forum', array('id'=>$forum->id)); $oldforum = $DB->get_record('forum', array('id'=>$forum->id));
// MDL-3942 - if the aggregation type or scale (i.e. max grade) changes then recalculate the grades for the entire forum // MDL-3942 - if the aggregation type or scale (i.e. max grade) changes then recalculate the grades for the entire forum
...@@ -596,7 +592,7 @@ function forum_print_recent_activity($course, $viewfullnames, $timestart) { ...@@ -596,7 +592,7 @@ function forum_print_recent_activity($course, $viewfullnames, $timestart) {
f.scale, f.grade_forum, f.maxbytes, f.maxattachments, f.forcesubscribe, f.scale, f.grade_forum, f.maxbytes, f.maxattachments, f.forcesubscribe,
f.trackingtype, f.rsstype, f.rssarticles, f.timemodified, f.warnafter, f.blockafter, f.trackingtype, f.rsstype, f.rssarticles, f.timemodified, f.warnafter, f.blockafter,
f.blockperiod, f.completiondiscussions, f.completionreplies, f.completionposts, f.blockperiod, f.completiondiscussions, f.completionreplies, f.completionposts,
f.displaywordcount, f.lockdiscussionafter, f.grade_forum_notify, f.usecoursefullname, f.displaywordcount, f.lockdiscussionafter, f.grade_forum_notify,
d.name AS discussionname, d.firstpost, d.userid AS discussionstarter, d.name AS discussionname, d.firstpost, d.userid AS discussionstarter,
d.assessed AS discussionassessed, d.timemodified, d.usermodified, d.forum, d.groupid, d.assessed AS discussionassessed, d.timemodified, d.usermodified, d.forum, d.groupid,
d.timestart, d.timeend, d.pinned, d.timelocked, d.timestart, d.timeend, d.pinned, d.timelocked,
...@@ -688,8 +684,7 @@ function forum_print_recent_activity($course, $viewfullnames, $timestart) { ...@@ -688,8 +684,7 @@ function forum_print_recent_activity($course, $viewfullnames, $timestart) {
'completionposts' => $post->completionposts, 'completionposts' => $post->completionposts,
'displaywordcount' => $post->displaywordcount, 'displaywordcount' => $post->displaywordcount,
'lockdiscussionafter' => $post->lockdiscussionafter, 'lockdiscussionafter' => $post->lockdiscussionafter,
'grade_forum_notify' => $post->grade_forum_notify, 'grade_forum_notify' => $post->grade_forum_notify
'usecoursefullname' => $post->usecoursefullname
]; ];
// Build the forum entity from the factory. // Build the forum entity from the factory.
$forumentity = $entityfactory->get_forum_from_stdclass($forumrecord, $context, $coursemodule, $course); $forumentity = $entityfactory->get_forum_from_stdclass($forumrecord, $context, $coursemodule, $course);
......
...@@ -126,10 +126,6 @@ class mod_forum_mod_form extends moodleform_mod { ...@@ -126,10 +126,6 @@ class mod_forum_mod_form extends moodleform_mod {
} }
$mform->setDefault('trackingtype', $default); $mform->setDefault('trackingtype', $default);
$mform->addElement('checkbox', 'usecoursefullname', get_string('usecoursefullname', 'forum'), null);
$mform->addHelpButton('usecoursefullname', 'usecoursefullname', 'forum');
$mform->setDefault('usecoursefullname', $CFG->forum_usecoursefullname);
if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) { if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) {
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$mform->addElement('header', 'rssheader', get_string('rss')); $mform->addElement('header', 'rssheader', get_string('rss'));
......
...@@ -95,10 +95,6 @@ if ($ADMIN->fulltree) { ...@@ -95,10 +95,6 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'forum'), $settings->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'forum'),
get_string('configdigestmailtime', 'forum'), 17, $options)); get_string('configdigestmailtime', 'forum'), 17, $options));
// Use full course name for notification.
$settings->add(new admin_setting_configcheckbox('forum_usecoursefullname', get_string('usecoursefullname', 'forum'),
get_string('configusecoursefullname', 'forum'), 0));
if (empty($CFG->enablerssfeeds)) { if (empty($CFG->enablerssfeeds)) {
$options = array(0 => get_string('rssglobaldisabled', 'admin')); $options = array(0 => get_string('rssglobaldisabled', 'admin'));
$str = get_string('configenablerssfeeds', 'forum').'<br />'.get_string('configenablerssfeedsdisabled2', 'admin'); $str = get_string('configenablerssfeeds', 'forum').'<br />'.get_string('configenablerssfeedsdisabled2', 'admin');
......
...@@ -90,7 +90,6 @@ class entities_forum_test extends \advanced_testcase { ...@@ -90,7 +90,6 @@ class entities_forum_test extends \advanced_testcase {
$lockdiscussionafter = 0; $lockdiscussionafter = 0;
$duedate = 0; $duedate = 0;
$cutoffdate = 0; $cutoffdate = 0;
$usecoursefullname = 0;
$sendnotification = false; $sendnotification = false;
$forum = new forum_entity( $forum = new forum_entity(
$context, $context,
...@@ -125,8 +124,7 @@ class entities_forum_test extends \advanced_testcase { ...@@ -125,8 +124,7 @@ class entities_forum_test extends \advanced_testcase {
$displaywordcount, $displaywordcount,
$lockdiscussionafter, $lockdiscussionafter,
$duedate, $duedate,
$cutoffdate, $cutoffdate
$usecoursefullname
); );
$this->assertEquals($context, $forum->get_context()); $this->assertEquals($context, $forum->get_context());
...@@ -169,6 +167,5 @@ class entities_forum_test extends \advanced_testcase { ...@@ -169,6 +167,5 @@ class entities_forum_test extends \advanced_testcase {
$this->assertEquals(false, $forum->is_due_date_reached()); $this->assertEquals(false, $forum->is_due_date_reached());
$this->assertEquals(false, $forum->has_cutoff_date()); $this->assertEquals(false, $forum->has_cutoff_date());
$this->assertEquals(false, $forum->is_cutoff_date_reached()); $this->assertEquals(false, $forum->is_cutoff_date_reached());
$this->assertEquals(false, $forum->use_course_fullname());
} }
} }
...@@ -910,7 +910,7 @@ class mail_test extends \advanced_testcase { ...@@ -910,7 +910,7 @@ class mail_test extends \advanced_testcase {
// Post a discussion to the forum. // Post a discussion to the forum.
$subject = 'This is the very long forum post subject that somebody was very kind of leaving, it is intended to check if long subject comes in mail correctly. Thank you.'; $subject = 'This is the very long forum post subject that somebody was very kind of leaving, it is intended to check if long subject comes in mail correctly. Thank you.';
$a = (object)array('coursename' => $course->shortname, 'forumname' => $forum->name, 'subject' => $subject); $a = (object)array('courseshortname' => $course->shortname, 'forumname' => $forum->name, 'subject' => $subject);
$expectedsubject = get_string('postmailsubject', 'forum', $a); $expectedsubject = get_string('postmailsubject', 'forum', $a);
list($discussion, $post) = $this->helper_post_to_forum($forum, $author, array('name' => $subject)); list($discussion, $post) = $this->helper_post_to_forum($forum, $author, array('name' => $subject));
...@@ -930,50 +930,6 @@ class mail_test extends \advanced_testcase { ...@@ -930,50 +930,6 @@ class mail_test extends \advanced_testcase {
$this->assertEquals($expectedsubject, $message->subject); $this->assertEquals($expectedsubject, $message->subject);
} }
/**
* Test usecoursefullname option for notification.
*
* @covers \mod_forum\task\send_user_notifications
*/
public function test_usecoursefullname() {
$this->resetAfterTest();
$record = [];
$record['fullname'] = 'Test Course Full Name';
$record['shortname'] = 'Shortname';
// Create a course, with a forum.
$course = $this->getDataGenerator()->create_course($record);
$options = array('course' => $course->id, 'forcesubscribe' => FORUM_FORCESUBSCRIBE, 'usecoursefullname' => true);
$forum = $this->getDataGenerator()->create_module('forum', $options);
// Create a user enrolled in the course as student.
list($author) = $this->helper_create_users($course, 1);
// Post a discussion to the forum.
$subject = 'This is the forum post subject.';
// Expect coursefullname instead of shortname.
$a = (object)array('coursename' => $course->fullname, 'subject' => $subject);
$expectedsubject = get_string('postmailsubject', 'forum', $a);
list($discussion, $post) = $this->helper_post_to_forum($forum, $author, array('name' => $subject));
// Run cron and check that the expected number of users received the notification.
$expect = [
'author' => (object) [
'userid' => $author->id,
'messages' => 1,
],
];
$this->queue_tasks_and_assert($expect);
$this->send_notifications_and_assert($author, [$post]);
$messages = $this->messagesink->get_messages();
$this->assertEquals($expectedsubject, $messages[0]->subject);
$this->assertStringContainsString($course->fullname, $messages[0]->fullmessage);
$this->assertStringContainsString($course->fullname, $messages[0]->fullmessagehtml);
}
/** /**
* Test inital email and reply email subjects * Test inital email and reply email subjects
*/ */
......
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2022041901; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2022062700; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2022041200; // Requires this Moodle version. $plugin->requires = 2022041200; // Requires this Moodle version.
$plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics) $plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment