mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-31355 mod_forum: different message when duedate has passed
This commit is contained in:
parent
cbf63d8efc
commit
82482e3d3e
@ -382,6 +382,11 @@ class discussion {
|
||||
get_string('cutoffdatereached', 'forum'),
|
||||
notification::NOTIFY_INFO
|
||||
))->set_show_closebutton();
|
||||
} else if ($forum->is_due_date_reached()) {
|
||||
$notifications[] = (new notification(
|
||||
get_string('thisforumisdue', 'forum', userdate($forum->get_due_date())),
|
||||
notification::NOTIFY_INFO
|
||||
))->set_show_closebutton();
|
||||
} else if ($forum->has_due_date()) {
|
||||
$notifications[] = (new notification(
|
||||
get_string('thisforumhasduedate', 'forum', userdate($forum->get_due_date())),
|
||||
|
@ -332,6 +332,11 @@ class discussion_list {
|
||||
get_string('cutoffdatereached', 'forum'),
|
||||
notification::NOTIFY_INFO
|
||||
))->set_show_closebutton();
|
||||
} else if ($forum->is_due_date_reached()) {
|
||||
$notifications[] = (new notification(
|
||||
get_string('thisforumisdue', 'forum', userdate($forum->get_due_date())),
|
||||
notification::NOTIFY_INFO
|
||||
))->set_show_closebutton();
|
||||
} else if ($forum->has_due_date()) {
|
||||
$notifications[] = (new notification(
|
||||
get_string('thisforumhasduedate', 'forum', userdate($forum->get_due_date())),
|
||||
|
@ -589,6 +589,7 @@ $string['subscriptions'] = 'Subscriptions';
|
||||
$string['tagarea_forum_posts'] = 'Forum posts';
|
||||
$string['tagsdeleted'] = 'Forum tags have been deleted';
|
||||
$string['thisforumisthrottled'] = 'This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at {$a->blockafter} posting(s) in {$a->blockperiod}';
|
||||
$string['thisforumisdue'] = 'The due date for posting to this forum was {$a}.';
|
||||
$string['thisforumhasduedate'] = 'The due date for posting to this forum is {$a}.';
|
||||
$string['timedhidden'] = 'Timed status: Hidden from students';
|
||||
$string['timedposts'] = 'Timed posts';
|
||||
|
@ -6337,6 +6337,26 @@ function forum_is_cutoff_date_reached($forum) {
|
||||
return $forumentity->is_cutoff_date_reached();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the specified forum's due date is reached.
|
||||
*
|
||||
* @param stdClass $forum The forum
|
||||
* @return bool
|
||||
*/
|
||||
function forum_is_due_date_reached($forum) {
|
||||
$entityfactory = \mod_forum\local\container::get_entity_factory();
|
||||
$coursemoduleinfo = get_fast_modinfo($forum->course);
|
||||
$cminfo = $coursemoduleinfo->instances['forum'][$forum->id];
|
||||
$forumentity = $entityfactory->get_forum_from_stdclass(
|
||||
$forum,
|
||||
context_module::instance($cminfo->id),
|
||||
$cminfo->get_course_module_record(),
|
||||
$cminfo->get_course()
|
||||
);
|
||||
|
||||
return $forumentity->is_due_date_reached();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the specified discussion is time-locked.
|
||||
*
|
||||
|
@ -3218,6 +3218,54 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the forum_is_due_date_reached function.
|
||||
*
|
||||
* @dataProvider forum_is_due_date_reached_provider
|
||||
* @param stdClass $forum
|
||||
* @param bool $expect
|
||||
*/
|
||||
public function test_forum_is_due_date_reached($forum, $expect) {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$this->setAdminUser();
|
||||
|
||||
$datagenerator = $this->getDataGenerator();
|
||||
$course = $datagenerator->create_course();
|
||||
$forum = $datagenerator->create_module('forum', (object) array_merge([
|
||||
'course' => $course->id
|
||||
], $forum));
|
||||
|
||||
$this->assertEquals($expect, forum_is_due_date_reached($forum));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dataprovider for forum_is_due_date_reached tests.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function forum_is_due_date_reached_provider() {
|
||||
$now = time();
|
||||
return [
|
||||
'duedate is unset' => [
|
||||
[],
|
||||
false
|
||||
],
|
||||
'duedate is 0' => [
|
||||
['duedate' => 0],
|
||||
false
|
||||
],
|
||||
'duedate is set and is in future' => [
|
||||
['duedate' => $now + 86400],
|
||||
false
|
||||
],
|
||||
'duedate is set and is in past' => [
|
||||
['duedate' => $now - 86400],
|
||||
true
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that {@link forum_update_post()} keeps correct forum_discussions usermodified.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user