public function delete() {
        global $DB, $PAGE;

        // Remove any records if it has already been met.
        $DB->delete_records('badge_criteria_met', array('critid' => $this->id));

        // Remove all parameters records.
        $DB->delete_records('badge_criteria_param', array('critid' => $this->id));

        // Finally remove criterion itself.
        $DB->delete_records('badge_criteria', array('id' => $this->id));

        // Trigger event, badge criteria deleted.
        $eventparams = array('objectid' => $this->id,
            'context' => $PAGE->context,
            'other' => array('badgeid' => $this->badgeid));
        $event = \core\event\badge_criteria_deleted::create($eventparams);
        $event->trigger();
    }