Skip to content

Commit 4c0555e

Browse files
committed
issue#45: trigger course_module_updated on dates update
1 parent 2c47928 commit 4c0555e

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
$cm = $cms[$modid];
183183
$mod = report_editdates_mod_date_extractor::make($cm->modname, $course);
184184
if ($mod) {
185-
$mod->save_dates($cm, $datesettings);
185+
$mod->save_new_dates($cm, $datesettings);
186186
}
187187
}
188188

@@ -199,7 +199,7 @@
199199
$blockdatextrator =
200200
report_editdates_block_date_extractor::make($block->blockname, $course);
201201
if ($blockdatextrator) {
202-
$blockdatextrator->save_dates($blockobj, $datesettings);
202+
$blockdatextrator->save_new_dates($blockobj, $datesettings);
203203
}
204204
}
205205
}

lib.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ abstract public function get_settings(cm_info $cm);
165165
*/
166166
abstract public function validate_dates(cm_info $cm, array $dates);
167167

168+
/**
169+
* Save the new dates for this course_module instance.
170+
*
171+
* @param \cm_info $cm the activity to save the dates for.
172+
* @param array $dates a list of new dates.
173+
*
174+
* @throws \coding_exception
175+
*/
176+
final public function save_new_dates(cm_info $cm, array $dates) {
177+
$this->save_dates($cm, $dates);
178+
\core\event\course_module_updated::create_from_cm($cm)->trigger();
179+
}
180+
168181
/**
169182
* Save the new dates for this course_module instance.
170183
* @param cm_info $cm the activity to save the dates for.
@@ -281,9 +294,20 @@ abstract public function get_settings(block_base $block);
281294
*/
282295
abstract public function validate_dates(block_base $block, array $dates);
283296

297+
/**
298+
* Save the new dates for this block instance.
299+
*
300+
* @param \block_base $block the block to save the dates for.
301+
* @param array $dates a list of new dates.
302+
*/
303+
final public function save_new_dates(block_base $block, array $dates) {
304+
$this->save_dates($block, $dates);
305+
}
306+
284307
/**
285308
* Save the new dates for this course_module instance.
286-
* @param cm_info $cm the activity to save the dates for.
309+
* @param \block_base $block the block to save the dates for.
310+
* @param array $dates a list of new dates.
287311
*/
288312
public function save_dates(block_base $block, array $dates) {
289313
global $DB;
@@ -435,7 +459,7 @@ function report_editdates_update_dates_by_section($courseid, array $sectionnums,
435459

436460
$modinstance = report_editdates_mod_data_date_extractor::make($cm->modname, $course);
437461
if ($modinstance) {
438-
$modinstance->save_dates($cm, $datesettings);
462+
$modinstance->save_new_dates($cm, $datesettings);
439463
}
440464
}
441465
$transaction->allow_commit();

0 commit comments

Comments
 (0)