From 2d6dad4a32104264231ce9513469a3f7b14268ca Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Sun, 7 Sep 2025 19:26:13 +0200 Subject: [PATCH] MDL-86575 cohort: format cohort names in external service return data. --- public/cohort/externallib.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/cohort/externallib.php b/public/cohort/externallib.php index a1241f20911..a43899e55a7 100644 --- a/public/cohort/externallib.php +++ b/public/cohort/externallib.php @@ -145,6 +145,8 @@ class core_cohort_external extends external_api { $cohort->id = cohort_add_cohort($cohort); + $cohort->name = \core_external\util::format_string($cohort->name, $context); + list($cohort->description, $cohort->descriptionformat) = \core_external\util::format_text($cohort->description, $cohort->descriptionformat, $context, 'cohort', 'description', $cohort->id); @@ -284,6 +286,8 @@ class core_cohort_external extends external_api { throw new required_capability_exception($context, 'moodle/cohort:view', 'nopermissions', ''); } + $cohort->name = \core_external\util::format_string($cohort->name, $context); + // Only return theme when $CFG->allowcohortthemes is enabled. if (!empty($cohort->theme) && empty($CFG->allowcohortthemes)) { $cohort->theme = null; @@ -421,6 +425,8 @@ class core_cohort_external extends external_api { foreach ($results as $key => $cohort) { $cohortcontext = context::instance_by_id($cohort->contextid); + $cohort->name = \core_external\util::format_string($cohort->name, $cohortcontext); + // Only return theme when $CFG->allowcohortthemes is enabled. if (!empty($cohort->theme) && empty($CFG->allowcohortthemes)) { $cohort->theme = null;