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