public static function delete_submission($submissionid) {
        global $USER, $DB;

        $params = self::validate_parameters(self::delete_submission_parameters(), array('submissionid' => $submissionid));
        $warnings = array();

        // Get and validate the submission and workshop.
        $submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
        list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);

        // Check if we can delete the submission.
        if (!has_capability('mod/workshop:deletesubmissions', $context)) {
            require_capability('mod/workshop:submit', $context);
            // We can delete our own submission, on time and not yet assessed.
            $candeletesubmission = $submission->authorid == $USER->id;
            $candeletesubmission = $candeletesubmission && $workshop->modifying_submission_allowed($USER->id);
            $candeletesubmission = $candeletesubmission && count($workshop->get_assessments_of_submission($submission->id)) == 0;
            if (!$candeletesubmission) {
                throw new moodle_exception('nopermissions', 'error', '', 'delete submission');
            }
        }

        $workshop->delete_submission($submission);

        return array(
            'status' => true,
            'warnings' => $warnings
        );
    }
public static function delete_submission($submissionid) {
        global $USER, $DB;

        $params = self::validate_parameters(self::delete_submission_parameters(), array('submissionid' => $submissionid));
        $warnings = array();

        // Get and validate the submission and workshop.
        $submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
        list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);

        // Check if we can delete the submission.
        if (!has_capability('mod/workshop:deletesubmissions', $context)) {
            require_capability('mod/workshop:submit', $context);
            // We can delete our own submission, on time and not yet assessed.
            $candeletesubmission = $submission->authorid == $USER->id;
            $candeletesubmission = $candeletesubmission && $workshop->modifying_submission_allowed($USER->id);
            $candeletesubmission = $candeletesubmission && count($workshop->get_assessments_of_submission($submission->id)) == 0;
            if (!$candeletesubmission) {
                throw new moodle_exception('nopermissions', 'error', '', 'delete submission');
            }
        }

        $workshop->delete_submission($submission);

        return array(
            'status' => true,
            'warnings' => $warnings
        );
    }
public static function delete_submission ( $ submissionid ) { global $ USER , $ DB ; $ params = self :: validate_parameters ( self :: delete_submission_parameters ( ) , array ( 'submissionid' => $ submissionid ) ) ; $ warnings = array ( ) ; // Get and validate the submission and workshop. $ submission = $ DB -> get_record ( 'workshop_submissions' , array ( 'id' => $ params [ 'submissionid' ] ) , '*' , MUST_EXIST ) ; list ( $ workshop , $ course , $ cm , $ context ) = self :: validate_workshop ( $ submission -> workshopid ) ; // Check if we can delete the submission. if ( ! has_capability ( 'mod/workshop:deletesubmissions' , $ context ) ) { require_capability ( 'mod/workshop:submit' , $ context ) ; // We can delete our own submission, on time and not yet assessed. $ candeletesubmission = $ submission -> authorid == $ USER -> id ; $ candeletesubmission = $ candeletesubmission && $ workshop -> modifying_submission_allowed ( $ USER -> id ) ; $ candeletesubmission = $ candeletesubmission && count ( $ workshop -> get_assessments_of_submission ( $ submission -> id ) ) == 0 ; if ( ! $ candeletesubmission ) { throw new moodle_exception ( 'nopermissions' , 'error' , '' , 'delete submission' ) ; } } $ workshop -> delete_submission ( $ submission ) ; return array ( 'status' => true , 'warnings' => $ warnings ) ; }
Deletes the given submission.

@param int $submissionid the submission id.
@return array containing the result status and warnings.
@since Moodle 3.4
@throws moodle_exception
Deletes the given submission .