mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-57878 mod_*: added inclusion of completion event and callbacks
Part of MDL-55611 epic.
This commit is contained in:
parent
88d14007b3
commit
b3bd7a66a0
12 changed files with 487 additions and 5 deletions
|
@ -88,6 +88,10 @@ function glossary_add_instance($glossary) {
|
|||
$glossary->id = $returnid;
|
||||
glossary_grade_item_update($glossary);
|
||||
|
||||
$completiontimeexpected = !empty($glossary->completionexpected) ? $glossary->completionexpected : null;
|
||||
\core_completion\api::update_completion_date_event($glossary->coursemodule,
|
||||
'glossary', $glossary->id, $completiontimeexpected);
|
||||
|
||||
return $returnid;
|
||||
}
|
||||
|
||||
|
@ -133,6 +137,10 @@ function glossary_update_instance($glossary) {
|
|||
}
|
||||
glossary_grade_item_update($glossary);
|
||||
|
||||
$completiontimeexpected = !empty($glossary->completionexpected) ? $glossary->completionexpected : null;
|
||||
\core_completion\api::update_completion_date_event($glossary->coursemodule,
|
||||
'glossary', $glossary->id, $completiontimeexpected);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -212,6 +220,8 @@ function glossary_delete_instance($id) {
|
|||
|
||||
glossary_grade_item_delete($glossary);
|
||||
|
||||
\core_completion\api::update_completion_date_event($cm->id, 'glossary', $glossary->id, null);
|
||||
|
||||
$DB->delete_records('glossary', array('id'=>$id));
|
||||
|
||||
// Reset caches.
|
||||
|
@ -4159,3 +4169,32 @@ function forum_get_fontawesome_icon_map() {
|
|||
'mod_glossary:export' => 'fa-download'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles creating actions for events.
|
||||
*
|
||||
* @param \core_calendar\event $event
|
||||
* @param \core_calendar\action_factory $factory
|
||||
* @return \core_calendar\local\event\value_objects\action|\core_calendar\local\interfaces\action_interface|null
|
||||
*/
|
||||
function mod_glossary_core_calendar_provide_event_action(\core_calendar\event $event,
|
||||
\core_calendar\action_factory $factory) {
|
||||
$cm = get_fast_modinfo($event->courseid)->instances['glossary'][$event->instance];
|
||||
|
||||
$course = new stdClass();
|
||||
$course->id = $event->courseid;
|
||||
$completion = new \completion_info($course);
|
||||
|
||||
$completiondata = $completion->get_data($cm, false);
|
||||
|
||||
if ($completiondata->completionstate != COMPLETION_INCOMPLETE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $factory->create_instance(
|
||||
get_string('view'),
|
||||
new \moodle_url('/mod/glossary/view.php', ['id' => $cm->id]),
|
||||
1,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue