diff --git a/index.php b/index.php index 8b9da01..823f546 100644 --- a/index.php +++ b/index.php @@ -206,7 +206,13 @@ // Commit transaction and finish up. $transaction->allow_commit(); + + // Rebuild all course cache / calendar dates rebuild_course_cache($course->id); + $task = new \core\task\refresh_mod_calendar_events_task(); + $task->set_custom_data(array('courseid' => $course->id)); + \core\task\manager::queue_adhoc_task($task, true); + redirect($PAGE->url, get_string('changessaved')); } diff --git a/mod/forumdates.php b/mod/forumdates.php index 82815e8..8e3d2c6 100644 --- a/mod/forumdates.php +++ b/mod/forumdates.php @@ -67,4 +67,17 @@ public function validate_dates(cm_info $cm, array $dates) { } return $errors; } + + public function save_dates(cm_info $cm, array $dates) { + global $DB, $COURSE, $CFG; + parent::save_dates($cm, $dates); + + require_once($CFG->dirroot.'/mod/forum/locallib.php'); + $forum = $DB->get_record('forum', ['id' => $cm->instance]); + $forum->cmidnumber = $cm->id; + + // Update the calendar and grades. + forum_update_calendar($forum, $cm->id); + forum_grade_item_update($forum); + } }