public function get_student_grades($courseactivities) {

        if (empty($courseactivities)) {
            return array();
        }

        $grades = array();
        foreach ($courseactivities as $contextid => $instance) {
            $gradesinfo = grade_get_grades($this->course->id, 'mod', $instance->modname, $instance->instance, $this->studentids);

            // Sort them by activity context and user.
            if ($gradesinfo && $gradesinfo->items) {
                foreach ($gradesinfo->items as $gradeitem) {
                    foreach ($gradeitem->grades as $userid => $grade) {
                        if (empty($grades[$contextid][$userid])) {
                            // Initialise it as array because a single activity can have multiple grade items (e.g. workshop).
                            $grades[$contextid][$userid] = array();
                        }
                        $grades[$contextid][$userid][$gradeitem->id] = $grade;
                    }
                }
            }
        }

        return $grades;
    }
public function get_student_grades($courseactivities) {

        if (empty($courseactivities)) {
            return array();
        }

        $grades = array();
        foreach ($courseactivities as $contextid => $instance) {
            $gradesinfo = grade_get_grades($this->course->id, 'mod', $instance->modname, $instance->instance, $this->studentids);

            // Sort them by activity context and user.
            if ($gradesinfo && $gradesinfo->items) {
                foreach ($gradesinfo->items as $gradeitem) {
                    foreach ($gradeitem->grades as $userid => $grade) {
                        if (empty($grades[$contextid][$userid])) {
                            // Initialise it as array because a single activity can have multiple grade items (e.g. workshop).
                            $grades[$contextid][$userid] = array();
                        }
                        $grades[$contextid][$userid][$gradeitem->id] = $grade;
                    }
                }
            }
        }

        return $grades;
    }
public function get_student_grades ( $ courseactivities ) { if ( empty ( $ courseactivities ) ) { return array ( ) ; } $ grades = array ( ) ; foreach ( $ courseactivities as $ contextid => $ instance ) { $ gradesinfo = grade_get_grades ( $ this -> course -> id , 'mod' , $ instance -> modname , $ instance -> instance , $ this -> studentids ) ; // Sort them by activity context and user. if ( $ gradesinfo && $ gradesinfo -> items ) { foreach ( $ gradesinfo -> items as $ gradeitem ) { foreach ( $ gradeitem -> grades as $ userid => $ grade ) { if ( empty ( $ grades [ $ contextid ] [ $ userid ] ) ) { // Initialise it as array because a single activity can have multiple grade items (e.g. workshop). $ grades [ $ contextid ] [ $ userid ] = array ( ) ; } $ grades [ $ contextid ] [ $ userid ] [ $ gradeitem -> id ] = $ grade ; } } } } return $ grades ; }
Returns the course students grades.

@param array $courseactivities
@return array
Returns the course students grades .