MDL-80072 core: Update uses of courseid to format_text

This commit is contained in:
Andrew Nicols 2023-11-11 16:58:57 +08:00
parent ae80cd739b
commit d6dc3847f4
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
3 changed files with 29 additions and 17 deletions

View File

@ -2013,17 +2013,10 @@ class coursecat_helper {
$options = (array)$options;
$context = context_course::instance($course->id);
if (!isset($options['context'])) {
// TODO see MDL-38521
// option 1 (current), page context - no code required
// option 2, system context
// $options['context'] = context_system::instance();
// option 3, course context:
// $options['context'] = $context;
// option 4, course category context:
// $options['context'] = $context->get_parent_context();
$options['context'] = $context;
}
$summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null);
$summary = format_text($summary, $course->summaryformat, $options, $course->id);
$summary = format_text($summary, $course->summaryformat, $options);
if (!empty($this->searchcriteria['search'])) {
$summary = highlight($this->searchcriteria['search'], $summary);
}

View File

@ -877,7 +877,9 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
case 'me':
$outinfo = $message->strtime;
$text = '*** <b>'.$sender->firstname.' '.substr($rawtext, 4).'</b>';
$outmain = format_text($text, FORMAT_MOODLE, $options, $courseid);
$outmain = format_text($text, FORMAT_MOODLE, array_merge((array) $options, [
'context' => \core\context\course::instance($courseid),
]));
break;
default:
// Error, we set special back to false to use the classic message output.
@ -889,7 +891,9 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
$matches = array();
preg_match($patternto, $rawtext, $matches);
if (isset($matches[1]) && isset($matches[2])) {
$text = format_text($matches[2], FORMAT_MOODLE, $options, $courseid);
$text = format_text($matches[2], FORMAT_MOODLE, array_merge((array) $options, [
'context' => \core\context\course::instance($courseid),
]));
$outinfo = $message->strtime;
$outmain = $sender->firstname.' '.get_string('saidto', 'chat').' <i>'.$matches[1].'</i>: '.$text;
} else {
@ -899,7 +903,9 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
}
if (!$special) {
$text = format_text($rawtext, FORMAT_MOODLE, $options, $courseid);
$text = format_text($rawtext, FORMAT_MOODLE, array_merge((array) $options, [
'context' => \core\context\course::instance($courseid),
]));
$outinfo = $message->strtime.' '.$sender->firstname;
$outmain = $text;
}
@ -1064,7 +1070,9 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
switch ($command) {
case 'me':
$text = '*** <b>'.$sender->firstname.' '.substr($rawtext, 4).'</b>';
$outmain = format_text($text, FORMAT_MOODLE, $options, $courseid);
$outmain = format_text($text, FORMAT_MOODLE, array_merge($options, [
'context' => \core\context\course::instance($courseid),
]));
break;
default:
// Error, we set special back to false to use the classic message output.
@ -1077,7 +1085,9 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
$matches = array();
preg_match($patternto, $rawtext, $matches);
if (isset($matches[1]) && isset($matches[2])) {
$text = format_text($matches[2], FORMAT_MOODLE, $options, $courseid);
$text = format_text($matches[2], FORMAT_MOODLE, array_merge($options, [
'context' => \core\context\course::instance($courseid),
]));
$outmain = $sender->firstname.' <b>'.get_string('saidto', 'chat').'</b> <i>'.$matches[1].'</i>: '.$text;
} else {
// Error, we set special back to false to use the classic message output.
@ -1086,7 +1096,9 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
}
if (!$special) {
$text = format_text($rawtext, FORMAT_MOODLE, $options, $courseid);
$text = format_text($rawtext, FORMAT_MOODLE, array_merge($options, [
'context' => \core\context\course::instance($courseid),
]));
$outmain = $text;
}

View File

@ -91,8 +91,15 @@ class workshop_rubric_list_assessment_form extends workshop_rubric_assessment_fo
$levelid = $fields->{'levelid__idx_'.$i.'__idy_'.$j};
$definition = $fields->{'definition__idx_'.$i.'__idy_'.$j};
$definitionformat = $fields->{'definition__idx_'.$i.'__idy_'.$j.'format'};
$levelgrp[] = $mform->createElement('radio', 'chosenlevelid__idx_'.$i, '',
format_text($definition, $definitionformat, null, $workshop->course->id), $levelid);
$levelgrp[] = $mform->createElement(
'radio',
"chosenlevelid__idx_{$i}",
'',
format_text($definition, $definitionformat, [
'context' => \core\context\course::instance($workshop->course->id),
]),
$levelid,
);
}
$mform->addGroup($levelgrp, 'levelgrp__idx_'.$i, '', "<br />\n", false);
}