Yuck, what a mess.
To be sure everything is working correctly, I guess you need to check with at least the following options in all combinations:
- $this->is_fixed_students() true/false
- $this->get_pref('showuseridnumber') true/false
- has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context) true/false
And make sure you have all possible types of header row, student row, and average row visible.
We really need a better way to handle tables with configurable columns. You might like to look at what I started to do in the question bank: http://git.moodle.org/gw?p=moodle.git;a=blob;f=question/editlib.php;h=af49fae3c8e75e9a7a90a115601f075bc2e7c461;hb=HEAD#l815. Really, that should be refactored to separate out the question-bank specific stuff from the generic stuff. It also needs to be refactored to use renderers now. Anyway, that is just food for thought for the future. We don't want any more work before 2.0 that we can help.