Skip to content

Commit

Permalink
issue#45: trigger course_module_updated on dates update
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriim committed Dec 12, 2022
1 parent 2c47928 commit 4c0555e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
$cm = $cms[$modid];
$mod = report_editdates_mod_date_extractor::make($cm->modname, $course);
if ($mod) {
$mod->save_dates($cm, $datesettings);
$mod->save_new_dates($cm, $datesettings);
}
}

Expand All @@ -199,7 +199,7 @@
$blockdatextrator =
report_editdates_block_date_extractor::make($block->blockname, $course);
if ($blockdatextrator) {
$blockdatextrator->save_dates($blockobj, $datesettings);
$blockdatextrator->save_new_dates($blockobj, $datesettings);
}
}
}
Expand Down
28 changes: 26 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ abstract public function get_settings(cm_info $cm);
*/
abstract public function validate_dates(cm_info $cm, array $dates);

/**
* Save the new dates for this course_module instance.
*
* @param \cm_info $cm the activity to save the dates for.
* @param array $dates a list of new dates.
*
* @throws \coding_exception
*/
final public function save_new_dates(cm_info $cm, array $dates) {
$this->save_dates($cm, $dates);
\core\event\course_module_updated::create_from_cm($cm)->trigger();
}

/**
* Save the new dates for this course_module instance.
* @param cm_info $cm the activity to save the dates for.
Expand Down Expand Up @@ -281,9 +294,20 @@ abstract public function get_settings(block_base $block);
*/
abstract public function validate_dates(block_base $block, array $dates);

/**
* Save the new dates for this block instance.
*
* @param \block_base $block the block to save the dates for.
* @param array $dates a list of new dates.
*/
final public function save_new_dates(block_base $block, array $dates) {
$this->save_dates($block, $dates);
}

/**
* Save the new dates for this course_module instance.
* @param cm_info $cm the activity to save the dates for.
* @param \block_base $block the block to save the dates for.
* @param array $dates a list of new dates.
*/
public function save_dates(block_base $block, array $dates) {
global $DB;
Expand Down Expand Up @@ -435,7 +459,7 @@ function report_editdates_update_dates_by_section($courseid, array $sectionnums,

$modinstance = report_editdates_mod_data_date_extractor::make($cm->modname, $course);
if ($modinstance) {
$modinstance->save_dates($cm, $datesettings);
$modinstance->save_new_dates($cm, $datesettings);
}
}
$transaction->allow_commit();
Expand Down

0 comments on commit 4c0555e

Please sign in to comment.