public function delete_assessment($id) {
        global $DB;

        if (empty($id)) {
            return true;
        }

        $fs = get_file_storage();

        if (is_array($id)) {
            $DB->delete_records_list('workshop_grades', 'assessmentid', $id);
            foreach ($id as $itemid) {
                $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_content', $itemid);
                $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_attachment', $itemid);
            }
            $DB->delete_records_list('workshop_assessments', 'id', $id);

        } else {
            $DB->delete_records('workshop_grades', array('assessmentid' => $id));
            $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_content', $id);
            $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_attachment', $id);
            $DB->delete_records('workshop_assessments', array('id' => $id));
        }

        return true;
    }
public function delete_assessment($id) {
        global $DB;

        if (empty($id)) {
            return true;
        }

        $fs = get_file_storage();

        if (is_array($id)) {
            $DB->delete_records_list('workshop_grades', 'assessmentid', $id);
            foreach ($id as $itemid) {
                $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_content', $itemid);
                $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_attachment', $itemid);
            }
            $DB->delete_records_list('workshop_assessments', 'id', $id);

        } else {
            $DB->delete_records('workshop_grades', array('assessmentid' => $id));
            $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_content', $id);
            $fs->delete_area_files($this->context->id, 'mod_workshop', 'overallfeedback_attachment', $id);
            $DB->delete_records('workshop_assessments', array('id' => $id));
        }

        return true;
    }
public function delete_assessment ( $ id ) { global $ DB ; if ( empty ( $ id ) ) { return true ; } $ fs = get_file_storage ( ) ; if ( is_array ( $ id ) ) { $ DB -> delete_records_list ( 'workshop_grades' , 'assessmentid' , $ id ) ; foreach ( $ id as $ itemid ) { $ fs -> delete_area_files ( $ this -> context -> id , 'mod_workshop' , 'overallfeedback_content' , $ itemid ) ; $ fs -> delete_area_files ( $ this -> context -> id , 'mod_workshop' , 'overallfeedback_attachment' , $ itemid ) ; } $ DB -> delete_records_list ( 'workshop_assessments' , 'id' , $ id ) ; } else { $ DB -> delete_records ( 'workshop_grades' , array ( 'assessmentid' => $ id ) ) ; $ fs -> delete_area_files ( $ this -> context -> id , 'mod_workshop' , 'overallfeedback_content' , $ id ) ; $ fs -> delete_area_files ( $ this -> context -> id , 'mod_workshop' , 'overallfeedback_attachment' , $ id ) ; $ DB -> delete_records ( 'workshop_assessments' , array ( 'id' => $ id ) ) ; } return true ; }
Delete assessment record or records.

Removes associated records from the workshop_grades table, too.

@param int|array $id assessment id or array of assessments ids
@todo Give grading strategy plugins a chance to clean up their data, too.
@return bool true
Delete assessment record or records .