if ($completionexpectedtime !== null) {
// Calendar event exists so update it.
$event->name = get_string('completionexpectedfor', 'completion', $lang);
- $event->description = format_module_intro($modulename, $instance, $cmid);
+ $event->description = format_module_intro($modulename, $instance, $cmid, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $completionexpectedtime;
$event->timesort = $completionexpectedtime;
$event->visible = instance_is_visible($modulename, $instance);
// Event doesn't exist so create one.
if ($completionexpectedtime !== null) {
$event->name = get_string('completionexpectedfor', 'completion', $lang);
- $event->description = format_module_intro($modulename, $instance, $cmid);
+ $event->description = format_module_intro($modulename, $instance, $cmid, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $instance->course;
$event->groupid = 0;
$event->userid = 0;
$event = new stdClass();
$event->type = CALENDAR_EVENT_TYPE_ACTION;
- $event->description = format_module_intro('assign', $assigninstance, $cmid);
+ $event->description = format_module_intro('assign', $assigninstance, $cmid, false);
+ $event->format = FORMAT_HTML;
// Events module won't show user events when the courseid is nonzero.
$event->courseid = ($userid) ? 0 : $assigninstance->course;
$event->groupid = $groupid;
$event = new stdClass();
$event->type = CALENDAR_EVENT_TYPE_ACTION;
$event->name = $chat->name;
- $event->description = format_module_intro('chat', $chat, $chat->coursemodule);
+ $event->description = format_module_intro('chat', $chat, $chat->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $chat->course;
$event->groupid = 0;
$event->userid = 0;
if ($chat->schedule > 0) {
$event->type = CALENDAR_EVENT_TYPE_ACTION;
$event->name = $chat->name;
- $event->description = format_module_intro('chat', $chat, $chat->coursemodule);
+ $event->description = format_module_intro('chat', $chat, $chat->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $chat->chattime;
$event->timesort = $chat->chattime;
$event = new stdClass();
$event->type = CALENDAR_EVENT_TYPE_ACTION;
$event->name = $chat->name;
- $event->description = format_module_intro('chat', $chat, $chat->coursemodule);
+ $event->description = format_module_intro('chat', $chat, $chat->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $chat->course;
$event->groupid = 0;
$event->userid = 0;
$event = new stdClass();
$event->name = $chat->name;
$event->type = CALENDAR_EVENT_TYPE_ACTION;
- $event->description = format_module_intro('chat', $chat, $cm->id);
+ $event->description = format_module_intro('chat', $chat, $cm->id, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $chat->chattime;
$event->timesort = $chat->chattime;
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'chat', 'instance' => $chat->id,
if ((!empty($choice->timeopen)) && ($choice->timeopen > 0)) {
// Calendar event exists so update it.
$event->name = get_string('calendarstart', 'choice', $choice->name);
- $event->description = format_module_intro('choice', $choice, $choice->coursemodule);
+ $event->description = format_module_intro('choice', $choice, $choice->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $choice->timeopen;
$event->timesort = $choice->timeopen;
$event->visible = instance_is_visible('choice', $choice);
// Event doesn't exist so create one.
if ((!empty($choice->timeopen)) && ($choice->timeopen > 0)) {
$event->name = get_string('calendarstart', 'choice', $choice->name);
- $event->description = format_module_intro('choice', $choice, $choice->coursemodule);
+ $event->description = format_module_intro('choice', $choice, $choice->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $choice->course;
$event->groupid = 0;
$event->userid = 0;
if ((!empty($choice->timeclose)) && ($choice->timeclose > 0)) {
// Calendar event exists so update it.
$event->name = get_string('calendarend', 'choice', $choice->name);
- $event->description = format_module_intro('choice', $choice, $choice->coursemodule);
+ $event->description = format_module_intro('choice', $choice, $choice->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $choice->timeclose;
$event->timesort = $choice->timeclose;
$event->visible = instance_is_visible('choice', $choice);
// Event doesn't exist so create one.
if ((!empty($choice->timeclose)) && ($choice->timeclose > 0)) {
$event->name = get_string('calendarend', 'choice', $choice->name);
- $event->description = format_module_intro('choice', $choice, $choice->coursemodule);
+ $event->description = format_module_intro('choice', $choice, $choice->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $choice->course;
$event->groupid = 0;
$event->userid = 0;
if ($data->timeavailablefrom > 0) {
// Calendar event exists so update it.
$event->name = get_string('calendarstart', 'data', $data->name);
- $event->description = format_module_intro('data', $data, $data->coursemodule);
+ $event->description = format_module_intro('data', $data, $data->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $data->timeavailablefrom;
$event->timesort = $data->timeavailablefrom;
$event->visible = instance_is_visible('data', $data);
// Event doesn't exist so create one.
if (isset($data->timeavailablefrom) && $data->timeavailablefrom > 0) {
$event->name = get_string('calendarstart', 'data', $data->name);
- $event->description = format_module_intro('data', $data, $data->coursemodule);
+ $event->description = format_module_intro('data', $data, $data->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $data->course;
$event->groupid = 0;
$event->userid = 0;
if ($data->timeavailableto > 0) {
// Calendar event exists so update it.
$event->name = get_string('calendarend', 'data', $data->name);
- $event->description = format_module_intro('data', $data, $data->coursemodule);
+ $event->description = format_module_intro('data', $data, $data->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $data->timeavailableto;
$event->timesort = $data->timeavailableto;
$event->visible = instance_is_visible('data', $data);
// Event doesn't exist so create one.
if (isset($data->timeavailableto) && $data->timeavailableto > 0) {
$event->name = get_string('calendarend', 'data', $data->name);
- $event->description = format_module_intro('data', $data, $data->coursemodule);
+ $event->description = format_module_intro('data', $data, $data->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $data->course;
$event->groupid = 0;
$event->userid = 0;
$event->eventtype = FEEDBACK_EVENT_TYPE_OPEN;
$event->type = empty($feedback->timeclose) ? CALENDAR_EVENT_TYPE_ACTION : CALENDAR_EVENT_TYPE_STANDARD;
$event->name = get_string('calendarstart', 'feedback', $feedback->name);
- $event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule);
+ $event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $feedback->timeopen;
$event->timesort = $feedback->timeopen;
$event->visible = instance_is_visible('feedback', $feedback);
$event->type = CALENDAR_EVENT_TYPE_ACTION;
$event->eventtype = FEEDBACK_EVENT_TYPE_CLOSE;
$event->name = get_string('calendarend', 'feedback', $feedback->name);
- $event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule);
+ $event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $feedback->timeclose;
$event->timesort = $feedback->timeclose;
$event->visible = instance_is_visible('feedback', $feedback);
if (!empty($forum->duedate)) {
$event->name = get_string('calendardue', 'forum', $forum->name);
- $event->description = format_module_intro('forum', $forum, $cmid);
+ $event->description = format_module_intro('forum', $forum, $cmid, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $forum->course;
$event->modulename = 'forum';
$event->instance = $forum->id;
$event = new stdClass();
$event->type = !$deadline ? CALENDAR_EVENT_TYPE_ACTION : CALENDAR_EVENT_TYPE_STANDARD;
- $event->description = format_module_intro('lesson', $lesson, $cmid);
+ $event->description = format_module_intro('lesson', $lesson, $cmid, false);
+ $event->format = FORMAT_HTML;
// Events module won't show user events when the courseid is nonzero.
$event->courseid = ($userid) ? 0 : $lesson->course;
$event->groupid = $groupid;
$event = new stdClass();
$event->type = !$timeclose ? CALENDAR_EVENT_TYPE_ACTION : CALENDAR_EVENT_TYPE_STANDARD;
- $event->description = format_module_intro('quiz', $quiz, $cmid);
+ $event->description = format_module_intro('quiz', $quiz, $cmid, false);
+ $event->format = FORMAT_HTML;
// Events module won't show user events when the courseid is nonzero.
$event->courseid = ($userid) ? 0 : $quiz->course;
$event->groupid = $groupid;
if ((!empty($scorm->timeopen)) && ($scorm->timeopen > 0)) {
// Calendar event exists so update it.
$event->name = get_string('calendarstart', 'scorm', $scorm->name);
- $event->description = format_module_intro('scorm', $scorm, $cmid);
+ $event->description = format_module_intro('scorm', $scorm, $cmid, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $scorm->timeopen;
$event->timesort = $scorm->timeopen;
$event->visible = instance_is_visible('scorm', $scorm);
// Event doesn't exist so create one.
if ((!empty($scorm->timeopen)) && ($scorm->timeopen > 0)) {
$event->name = get_string('calendarstart', 'scorm', $scorm->name);
- $event->description = format_module_intro('scorm', $scorm, $cmid);
+ $event->description = format_module_intro('scorm', $scorm, $cmid, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $scorm->course;
$event->groupid = 0;
$event->userid = 0;
if ((!empty($scorm->timeclose)) && ($scorm->timeclose > 0)) {
// Calendar event exists so update it.
$event->name = get_string('calendarend', 'scorm', $scorm->name);
- $event->description = format_module_intro('scorm', $scorm, $cmid);
+ $event->description = format_module_intro('scorm', $scorm, $cmid, false);
+ $event->format = FORMAT_HTML;
$event->timestart = $scorm->timeclose;
$event->timesort = $scorm->timeclose;
$event->visible = instance_is_visible('scorm', $scorm);
// Event doesn't exist so create one.
if ((!empty($scorm->timeclose)) && ($scorm->timeclose > 0)) {
$event->name = get_string('calendarend', 'scorm', $scorm->name);
- $event->description = format_module_intro('scorm', $scorm, $cmid);
+ $event->description = format_module_intro('scorm', $scorm, $cmid, false);
+ $event->format = FORMAT_HTML;
$event->courseid = $scorm->course;
$event->groupid = 0;
$event->userid = 0;
* The callback get_shortcuts() is now deprecated. Please use get_course_content_items and get_all_content_items instead.
See source code examples in get_course_content_items() and get_all_content_items() in mod/lti/lib.php for details.
+* When creating the calendar events and setting the event description to match the module intro description, the filters
+ must not be applied on the passed description text. Doing so leads to loosing some expected text filters features and
+ causes unnecessarily early theme and output initialisation in unit tests. If your activity creates calendar events,
+ you probably have code like:
+ ```
+ $event->description = format_module_intro('quiz', $quiz, $cmid);
+ ```
+ You need to change it to:
+ ```
+ $event->description = format_module_intro('quiz', $quiz, $cmid, false);
+ $event->format = FORMAT_HTML;
+ ```
+ Even this is still technically wrong. Content should normally only be formatted just before it is output. Ideally, we
+ should pass the raw description text, format and have a way to copy the embedded files; or provide another way for the
+ calendar to call the right format_text() later. The calendar API does not allow us to do these things easily at the
+ moment. Therefore, this compromise approach is used. The false parameter added ensures that text filters are not run
+ at this time which is important. And the format must be set to HTML, because otherwise it would use the current user's
+ preferred editor default format.
+* Related to the above and to help with detecting the problematic places in contributed 3rd party modules, the
+ testing_module_generator::create_instance() now throws coding_exception if creating a module instance initialised the
+ theme and output as a side effect.
=== 3.8 ===
// the common properties for all events
$base = new stdClass();
$base->description = format_module_intro('workshop', $workshop, $cmid, false);
+ $base->format = FORMAT_HTML;
$base->courseid = $workshop->course;
$base->groupid = 0;
$base->userid = 0;