original_string: public static function update($itemid, $newvalue) {
          $context = context_module::instance($itemid);
          // Check access.
          \external_api::validate_context($context);
          require_capability('moodle/course:manageactivities', $context);
          // Update value.
          set_coursemodule_name($itemid, $newvalue);
          $coursemodulerecord = get_coursemodule_from_id('', $itemid, 0, false, MUST_EXIST);
          // Return instance.
          $cm = get_fast_modinfo($coursemodulerecord->course)->get_cm($itemid);
          return new static($cm, true);
      }
code: public static function update($itemid, $newvalue) {
          $context = context_module::instance($itemid);
          // Check access.
          \external_api::validate_context($context);
          require_capability('moodle/course:manageactivities', $context);
          // Update value.
          set_coursemodule_name($itemid, $newvalue);
          $coursemodulerecord = get_coursemodule_from_id('', $itemid, 0, false, MUST_EXIST);
          // Return instance.
          $cm = get_fast_modinfo($coursemodulerecord->course)->get_cm($itemid);
          return new static($cm, true);
      }
code_tokens: public static function update ( $ itemid , $ newvalue ) { $ context = context_module :: instance ( $ itemid ) ; // Check access. \ external_api :: validate_context ( $ context ) ; require_capability ( 'moodle/course:manageactivities' , $ context ) ; // Update value. set_coursemodule_name ( $ itemid , $ newvalue ) ; $ coursemodulerecord = get_coursemodule_from_id ( '' , $ itemid , 0 , false , MUST_EXIST ) ; // Return instance. $ cm = get_fast_modinfo ( $ coursemodulerecord -> course ) -> get_cm ( $ itemid ) ; return new static ( $ cm , true ) ; }
docstring: Updates course module name
  
  @param int $itemid course module id
  @param string $newvalue new name
  @return static
docstring_tokens: Updates course module name