protected function get_graders($userid) {
        // Potential graders should be active users only.
        $potentialgraders = get_enrolled_users($this->context, "mod/assign:grade", null, 'u.*', null, null, null, true);

        $graders = array();
        if (groups_get_activity_groupmode($this->get_course_module()) == SEPARATEGROUPS) {
            if ($groups = groups_get_all_groups($this->get_course()->id, $userid, $this->get_course_module()->groupingid)) {
                foreach ($groups as $group) {
                    foreach ($potentialgraders as $grader) {
                        if ($grader->id == $userid) {
                            // Do not send self.
                            continue;
                        }
                        if (groups_is_member($group->id, $grader->id)) {
                            $graders[$grader->id] = $grader;
                        }
                    }
                }
            } else {
                // User not in group, try to find graders without group.
                foreach ($potentialgraders as $grader) {
                    if ($grader->id == $userid) {
                        // Do not send self.
                        continue;
                    }
                    if (!groups_has_membership($this->get_course_module(), $grader->id)) {
                        $graders[$grader->id] = $grader;
                    }
                }
            }
        } else {
            foreach ($potentialgraders as $grader) {
                if ($grader->id == $userid) {
                    // Do not send self.
                    continue;
                }
                // Must be enrolled.
                if (is_enrolled($this->get_course_context(), $grader->id)) {
                    $graders[$grader->id] = $grader;
                }
            }
        }
        return $graders;
    }
protected function get_graders($userid) {
        // Potential graders should be active users only.
        $potentialgraders = get_enrolled_users($this->context, "mod/assign:grade", null, 'u.*', null, null, null, true);

        $graders = array();
        if (groups_get_activity_groupmode($this->get_course_module()) == SEPARATEGROUPS) {
            if ($groups = groups_get_all_groups($this->get_course()->id, $userid, $this->get_course_module()->groupingid)) {
                foreach ($groups as $group) {
                    foreach ($potentialgraders as $grader) {
                        if ($grader->id == $userid) {
                            // Do not send self.
                            continue;
                        }
                        if (groups_is_member($group->id, $grader->id)) {
                            $graders[$grader->id] = $grader;
                        }
                    }
                }
            } else {
                // User not in group, try to find graders without group.
                foreach ($potentialgraders as $grader) {
                    if ($grader->id == $userid) {
                        // Do not send self.
                        continue;
                    }
                    if (!groups_has_membership($this->get_course_module(), $grader->id)) {
                        $graders[$grader->id] = $grader;
                    }
                }
            }
        } else {
            foreach ($potentialgraders as $grader) {
                if ($grader->id == $userid) {
                    // Do not send self.
                    continue;
                }
                // Must be enrolled.
                if (is_enrolled($this->get_course_context(), $grader->id)) {
                    $graders[$grader->id] = $grader;
                }
            }
        }
        return $graders;
    }
protected function get_graders ( $ userid ) { // Potential graders should be active users only. $ potentialgraders = get_enrolled_users ( $ this -> context , "mod/assign:grade" , null , 'u.*' , null , null , null , true ) ; $ graders = array ( ) ; if ( groups_get_activity_groupmode ( $ this -> get_course_module ( ) ) == SEPARATEGROUPS ) { if ( $ groups = groups_get_all_groups ( $ this -> get_course ( ) -> id , $ userid , $ this -> get_course_module ( ) -> groupingid ) ) { foreach ( $ groups as $ group ) { foreach ( $ potentialgraders as $ grader ) { if ( $ grader -> id == $ userid ) { // Do not send self. continue ; } if ( groups_is_member ( $ group -> id , $ grader -> id ) ) { $ graders [ $ grader -> id ] = $ grader ; } } } } else { // User not in group, try to find graders without group. foreach ( $ potentialgraders as $ grader ) { if ( $ grader -> id == $ userid ) { // Do not send self. continue ; } if ( ! groups_has_membership ( $ this -> get_course_module ( ) , $ grader -> id ) ) { $ graders [ $ grader -> id ] = $ grader ; } } } } else { foreach ( $ potentialgraders as $ grader ) { if ( $ grader -> id == $ userid ) { // Do not send self. continue ; } // Must be enrolled. if ( is_enrolled ( $ this -> get_course_context ( ) , $ grader -> id ) ) { $ graders [ $ grader -> id ] = $ grader ; } } } return $ graders ; }
Returns a list of teachers that should be grading given submission.

@param int $userid The submission to grade
@return array
Returns a list of teachers that should be grading given submission .