protected static function check_view_submission_assessments($submission, workshop $workshop) {
        global $USER;

        $ownsubmission = $submission->authorid == $USER->id;
        $canview = has_capability('mod/workshop:viewallassessments', $workshop->context) ||
            ($ownsubmission && $workshop->assessments_available());

        if ($canview) {
            // Here we should check if the user share group.
            if ($submission->authorid != $USER->id &&
                    !groups_user_groups_visible($workshop->course, $submission->authorid, $workshop->cm)) {
                throw new moodle_exception('notingroup');
            }
        } else {
            throw new moodle_exception('nopermissions', 'error', '', 'view assessment');
        }
    }
protected static function check_view_submission_assessments($submission, workshop $workshop) {
        global $USER;

        $ownsubmission = $submission->authorid == $USER->id;
        $canview = has_capability('mod/workshop:viewallassessments', $workshop->context) ||
            ($ownsubmission && $workshop->assessments_available());

        if ($canview) {
            // Here we should check if the user share group.
            if ($submission->authorid != $USER->id &&
                    !groups_user_groups_visible($workshop->course, $submission->authorid, $workshop->cm)) {
                throw new moodle_exception('notingroup');
            }
        } else {
            throw new moodle_exception('nopermissions', 'error', '', 'view assessment');
        }
    }
protected static function check_view_submission_assessments ( $ submission , workshop $ workshop ) { global $ USER ; $ ownsubmission = $ submission -> authorid == $ USER -> id ; $ canview = has_capability ( 'mod/workshop:viewallassessments' , $ workshop -> context ) || ( $ ownsubmission && $ workshop -> assessments_available ( ) ) ; if ( $ canview ) { // Here we should check if the user share group. if ( $ submission -> authorid != $ USER -> id && ! groups_user_groups_visible ( $ workshop -> course , $ submission -> authorid , $ workshop -> cm ) ) { throw new moodle_exception ( 'notingroup' ) ; } } else { throw new moodle_exception ( 'nopermissions' , 'error' , '' , 'view assessment' ) ; } }
Helper method for validating if the current user can view the submission assessments.

@param  stdClass   $submission submission object
@param  workshop   $workshop     workshop instance
@return void
@since  Moodle 3.4
Helper method for validating if the current user can view the submission assessments .