original_string: public function delete($source=null) {
          global $DB;
  
          // Trigger the scale deleted event.
          if (!empty($this->standard)) {
              $eventcontext = context_system::instance();
          } else {
              if (!empty($this->courseid)) {
                  $eventcontext = context_course::instance($this->courseid);
              } else {
                  $eventcontext = context_system::instance();
              }
          }
          $event = \core\event\scale_deleted::create(array(
              'objectid' => $this->id,
              'context' => $eventcontext
          ));
          $event->trigger();
          if (parent::delete($source)) {
              $context = context_system::instance();
              $fs = get_file_storage();
              $files = $fs->get_area_files($context->id, 'grade', 'scale', $this->id);
              foreach ($files as $file) {
                  $file->delete();
              }
              return true;
          }
          return false;
      }
code: public function delete($source=null) {
          global $DB;
  
          // Trigger the scale deleted event.
          if (!empty($this->standard)) {
              $eventcontext = context_system::instance();
          } else {
              if (!empty($this->courseid)) {
                  $eventcontext = context_course::instance($this->courseid);
              } else {
                  $eventcontext = context_system::instance();
              }
          }
          $event = \core\event\scale_deleted::create(array(
              'objectid' => $this->id,
              'context' => $eventcontext
          ));
          $event->trigger();
          if (parent::delete($source)) {
              $context = context_system::instance();
              $fs = get_file_storage();
              $files = $fs->get_area_files($context->id, 'grade', 'scale', $this->id);
              foreach ($files as $file) {
                  $file->delete();
              }
              return true;
          }
          return false;
      }
code_tokens: public function delete ( $ source = null ) { global $ DB ; // Trigger the scale deleted event. if ( ! empty ( $ this -> standard ) ) { $ eventcontext = context_system :: instance ( ) ; } else { if ( ! empty ( $ this -> courseid ) ) { $ eventcontext = context_course :: instance ( $ this -> courseid ) ; } else { $ eventcontext = context_system :: instance ( ) ; } } $ event = \ core \ event \ scale_deleted :: create ( array ( 'objectid' => $ this -> id , 'context' => $ eventcontext ) ) ; $ event -> trigger ( ) ; if ( parent :: delete ( $ source ) ) { $ context = context_system :: instance ( ) ; $ fs = get_file_storage ( ) ; $ files = $ fs -> get_area_files ( $ context -> id , 'grade' , 'scale' , $ this -> id ) ; foreach ( $ files as $ file ) { $ file -> delete ( ) ; } return true ; } return false ; }
docstring: Deletes this scale from the database.
  
  @param string $source from where was the object deleted (mod/forum, manual, etc.)
  @return bool success
docstring_tokens: Deletes this scale from the database .