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;
    }