MDL-70124 course: Activity names are now trimmed.
authorTuan.Dinh <tuan.caodinh@nashtechglobal.com>
Thu, 12 Nov 2020 03:18:43 +0000 (10:18 +0700)
committerAdrian Greeve <abgreeve@gmail.com>
Thu, 11 Feb 2021 03:12:59 +0000 (11:12 +0800)
course/classes/output/course_module_name.php
course/moodleform_mod.php

index 5602b21..709846c 100644 (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);
index 2bbdac0..59a93ef 100644 (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;