MDL-70124 course: Activity names are now trimmed.

This commit is contained in:
Tuan.Dinh
2021-02-11 11:12:59 +08:00
committed by Adrian Greeve
parent 007c270507
commit 8ae7019cf8
2 changed files with 8 additions and 2 deletions
+3 -2
View File
@@ -90,8 +90,9 @@ class course_module_name extends \core\output\inplace_editable {
// Check access.
\external_api::validate_context($context);
require_capability('moodle/course:manageactivities', $context);
// Update value.
set_coursemodule_name($itemid, $newvalue);
// Trim module name and Update value.
set_coursemodule_name($itemid, trim($newvalue));
$coursemodulerecord = get_coursemodule_from_id('', $itemid, 0, false, MUST_EXIST);
// Return instance.
$cm = get_fast_modinfo($coursemodulerecord->course)->get_cm($itemid);
+5
View File
@@ -1258,6 +1258,11 @@ abstract class moodleform_mod extends moodleform {
$data->gradepass = unformat_float($data->gradepass);
}
// Trim name for all activity name.
if (isset($data->name)) {
$data->name = trim($data->name);
}
$this->data_postprocessing($data);
}
return $data;