* This function is used, in its new format, by restore_refresh_events()
*
* @param int $courseid
+ * @param int|stdClass $instance Lesson module instance or ID.
+ * @param int|stdClass $cm Course module object or ID (not used in this module).
* @return bool
*/
-function lesson_refresh_events($courseid = 0) {
+function lesson_refresh_events($courseid = 0, $instance = null, $cm = null) {
global $DB;
+ // If we have instance information then we can just update the one event instead of updating all events.
+ if (isset($instance)) {
+ if (!is_object($instance)) {
+ $instance = $DB->get_record('lesson', array('id' => $instance), '*', MUST_EXIST);
+ }
+ lesson_update_events($instance);
+ return true;
+ }
+
if ($courseid == 0) {
if (!$lessons = $DB->get_records('lesson')) {
return true;
function lesson_process_post_save(&$lesson) {
// Update the events relating to this lesson.
lesson_update_events($lesson);
+ $completionexpected = (!empty($lesson->completionexpected)) ? $lesson->completionexpected : null;
+ \core_completion\api::update_completion_date_event($lesson->coursemodule, 'lesson', $lesson, $completionexpected);
}
WHERE lessonid IN (SELECT id FROM {lesson} WHERE course = ?)
AND deadline <> 0", array($data->timeshift, $data->courseid));
+ // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
+ // See MDL-9367.
shift_course_mod_dates('lesson', array('available', 'deadline'), $data->timeshift, $data->courseid);
$status[] = array('component'=>$componentstr, 'item'=>get_string('datechanged'), 'error'=>false);
}