public function fill_table($activitylink = false, $studentcoursesonly = false) {
        global $CFG, $DB, $OUTPUT, $USER;

        if ($studentcoursesonly && count($this->studentcourseids) == 0) {
            return false;
        }

        // Only show user's courses instead of all courses.
        if ($this->courses) {
            $coursesdata = $this->setup_courses_data($studentcoursesonly);

            foreach ($coursesdata as $coursedata) {

                $course = $coursedata['course'];
                $coursecontext = $coursedata['context'];
                $finalgrade = $coursedata['finalgrade'];
                $courseitem = $coursedata['courseitem'];

                $coursename = format_string(get_course_display_name_for_list($course), true, array('context' => $coursecontext));
                // Link to the activity report version of the user grade report.
                if ($activitylink) {
                    $courselink = html_writer::link(new moodle_url('/course/user.php', array('mode' => 'grade', 'id' => $course->id,
                        'user' => $this->user->id)), $coursename);
                } else {
                    $courselink = html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id,
                        'userid' => $this->user->id, 'group' => $this->gpr->groupid)), $coursename);
                }

                $data = array($courselink, grade_format_gradevalue($finalgrade, $courseitem, true));

                if ($this->showrank['any']) {
                    if ($this->showrank[$course->id] && !is_null($finalgrade)) {
                        $rank = $coursedata['rank'];
                        $numusers = $coursedata['numusers'];
                        $data[] = "$rank/$numusers";
                    } else {
                        // No grade, no rank.
                        // Or this course wants rank hidden.
                        $data[] = '-';
                    }
                }

                $this->table->add_data($data);
            }

            return true;
        } else {
            echo $OUTPUT->notification(get_string('notenrolled', 'grades'), 'notifymessage');
            return false;
        }
    }
public function fill_table($activitylink = false, $studentcoursesonly = false) {
        global $CFG, $DB, $OUTPUT, $USER;

        if ($studentcoursesonly && count($this->studentcourseids) == 0) {
            return false;
        }

        // Only show user's courses instead of all courses.
        if ($this->courses) {
            $coursesdata = $this->setup_courses_data($studentcoursesonly);

            foreach ($coursesdata as $coursedata) {

                $course = $coursedata['course'];
                $coursecontext = $coursedata['context'];
                $finalgrade = $coursedata['finalgrade'];
                $courseitem = $coursedata['courseitem'];

                $coursename = format_string(get_course_display_name_for_list($course), true, array('context' => $coursecontext));
                // Link to the activity report version of the user grade report.
                if ($activitylink) {
                    $courselink = html_writer::link(new moodle_url('/course/user.php', array('mode' => 'grade', 'id' => $course->id,
                        'user' => $this->user->id)), $coursename);
                } else {
                    $courselink = html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id,
                        'userid' => $this->user->id, 'group' => $this->gpr->groupid)), $coursename);
                }

                $data = array($courselink, grade_format_gradevalue($finalgrade, $courseitem, true));

                if ($this->showrank['any']) {
                    if ($this->showrank[$course->id] && !is_null($finalgrade)) {
                        $rank = $coursedata['rank'];
                        $numusers = $coursedata['numusers'];
                        $data[] = "$rank/$numusers";
                    } else {
                        // No grade, no rank.
                        // Or this course wants rank hidden.
                        $data[] = '-';
                    }
                }

                $this->table->add_data($data);
            }

            return true;
        } else {
            echo $OUTPUT->notification(get_string('notenrolled', 'grades'), 'notifymessage');
            return false;
        }
    }
public function fill_table ( $ activitylink = false , $ studentcoursesonly = false ) { global $ CFG , $ DB , $ OUTPUT , $ USER ; if ( $ studentcoursesonly && count ( $ this -> studentcourseids ) == 0 ) { return false ; } // Only show user's courses instead of all courses. if ( $ this -> courses ) { $ coursesdata = $ this -> setup_courses_data ( $ studentcoursesonly ) ; foreach ( $ coursesdata as $ coursedata ) { $ course = $ coursedata [ 'course' ] ; $ coursecontext = $ coursedata [ 'context' ] ; $ finalgrade = $ coursedata [ 'finalgrade' ] ; $ courseitem = $ coursedata [ 'courseitem' ] ; $ coursename = format_string ( get_course_display_name_for_list ( $ course ) , true , array ( 'context' => $ coursecontext ) ) ; // Link to the activity report version of the user grade report. if ( $ activitylink ) { $ courselink = html_writer :: link ( new moodle_url ( '/course/user.php' , array ( 'mode' => 'grade' , 'id' => $ course -> id , 'user' => $ this -> user -> id ) ) , $ coursename ) ; } else { $ courselink = html_writer :: link ( new moodle_url ( '/grade/report/user/index.php' , array ( 'id' => $ course -> id , 'userid' => $ this -> user -> id , 'group' => $ this -> gpr -> groupid ) ) , $ coursename ) ; } $ data = array ( $ courselink , grade_format_gradevalue ( $ finalgrade , $ courseitem , true ) ) ; if ( $ this -> showrank [ 'any' ] ) { if ( $ this -> showrank [ $ course -> id ] && ! is_null ( $ finalgrade ) ) { $ rank = $ coursedata [ 'rank' ] ; $ numusers = $ coursedata [ 'numusers' ] ; $ data [ ] = "$rank/$numusers" ; } else { // No grade, no rank. // Or this course wants rank hidden. $ data [ ] = '-' ; } } $ this -> table -> add_data ( $ data ) ; } return true ; } else { echo $ OUTPUT -> notification ( get_string ( 'notenrolled' , 'grades' ) , 'notifymessage' ) ; return false ; } }
Fill the table for displaying.

@param bool $activitylink If this report link to the activity report or the user report.
@param bool $studentcoursesonly Only show courses that the user is a student of.
Fill the table for displaying .