diff --git a/classes/helper.php b/classes/helper.php index 9fa7f70..63bb626 100644 --- a/classes/helper.php +++ b/classes/helper.php @@ -91,6 +91,25 @@ public static function update_emailvars($templatetext, $subject, $course, $user, $course->category = is_number($course->category) ? core_course_category::get($course->category)->get_formatted_name() : $course->category; + $mod = clone $mod; + if (!empty($mod->id)) { + if ($DB->record_exists('course_modules', ['id' => $mod->id])) { + $module = $DB->get_record('course_modules', ['id' => $mod->id]); + $name = $DB->get_field('modules', 'name', ['id' => $module->module]); + $mod->url = new moodle_url("/mod/$name/view.php", ['id' => $mod->id]); + + if (\mod_pulse\automation\helper::create()->timemanagement_installed()) { + $userenrolments = ltool_timemanagement_get_course_user_enrollment($course->id, $user->id); + $record = $DB->get_record('ltool_timemanagement_modules', ['cmid' => $mod->id ?? 0]); + if ($record) { + $dates = ltool_timemanagement_cal_coursemodule_managedates($record, $userenrolments[0]['timestart']); + $duedate = isset($dates['duedate']) ? userdate($dates['duedate']) : ''; + } + } + $mod->duedate = $duedate ?? ''; + } + } + $vars = new pulse_email_vars($user, $course, $sender, $mod, $conditionvars); foreach ($amethods as $varscat => $placeholders) {