Skip to content

Commit

Permalink
Merge branch 'MDL-78432-401' of https://github.com/laurentdavid/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_401_STABLE
  • Loading branch information
junpataleta committed Jun 29, 2023
2 parents 2fd55ed + 54e62e6 commit d73c514
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion mod/label/lib.php
Expand Up @@ -34,7 +34,9 @@
* @return string
*/
function get_label_name($label) {
$name = html_to_text(format_string($label->intro, true));
$context = context_module::instance($label->coursemodule);
$intro = format_text($label->intro, $label->introformat, ['filter' => false, 'context' => $context]);
$name = html_to_text(format_string($intro, true, ['context' => $context]));
$name = preg_replace('/@@PLUGINFILE@@\/[[:^space:]]+/i', '', $name);
// Remove double space and also nbsp; characters.
$name = preg_replace('/\s+/u', ' ', $name);
Expand Down
27 changes: 26 additions & 1 deletion mod/label/tests/lib_test.php
Expand Up @@ -289,7 +289,32 @@ public function label_get_name_data_provider(): array {
'content' => '<audio controls="controls"><source src=""></audio>',
'format' => FORMAT_HTML,
'expected' => 'Text and media area'
]
],
'markdown' => [
'content' => "##Simple Title\n simple markdown format",
'format' => FORMAT_MARKDOWN,
'expected' => 'Simple Title simple markdown format'
],
'markdown with pluginfile' => [
'content' => "##Simple Title\n simple markdown format @@PLUGINFILE@@/moodle-hit-song.mp3",
'format' => FORMAT_MARKDOWN,
'expected' => 'Simple Title simple markdown format'
],
'plain text' => [
'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
'format' => FORMAT_PLAIN,
'expected' => 'Simple plain text'
],
'moodle format text' => [
'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
'format' => FORMAT_MOODLE,
'expected' => 'Simple plain text'
],
'html format text' => [
'content' => "<h1>Simple plain title</h1><p> with plain text</p> @@PLUGINFILE@@/moodle-hit-song.mp3",
'format' => FORMAT_HTML,
'expected' => 'Simple plain title with plain text'
],
];
}

Expand Down

0 comments on commit d73c514

Please sign in to comment.