/**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $page The current page being viewed (when report is paged)
  * @param int $sortitemid The id of the grade_item by which to sort the table
  */
 function grade_report_laegrader($courseid, $gpr, $context, $page = null, $sortitemid = null)
 {
     global $CFG;
     parent::grade_report($courseid, $gpr, $context, $page);
     $this->canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
     $this->accuratetotals = ($temp = grade_get_setting($this->courseid, 'report_laegrader_accuratetotals', $CFG->grade_report_laegrader_accuratetotals)) ? $temp : 0;
     // need this array, even tho its useless in the laegrader report or we'll generate warnings
     $this->collapsed = array('aggregatesonly' => array(), 'gradesonly' => array());
     if (empty($CFG->enableoutcomes)) {
         $nooutcomes = false;
     } else {
         $nooutcomes = get_user_preferences('grade_report_shownooutcomes');
     }
     // force category_last to true
     $switch = true;
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, false, $switch, null, $nooutcomes);
     // Fill items with parent information needed later
     $this->gtree->parents = array();
     fill_parents($this->gtree->parents, $this->gtree->items, $this->gtree->top_element, $this->gtree->top_element['object']->grade_item->id, $this->accuratetotals);
     //        fill_parents($this->gtree->items, $this->gtree->top_element,$this->gtree->top_element['object']->id,$this->gtree->top_element['object']->aggregation);
     $this->sortitemid = $sortitemid;
     // base url for sorting by first/last name
     $studentsperpage = 0;
     //$this->get_pref('studentsperpage');
     $perpage = '';
     $curpage = '';
     $this->baseurl = 'index.php?id=' . $this->courseid . $perpage . $curpage . '&';
     $this->pbarurl = 'index.php?id=' . $this->courseid . $perpage . '&';
     $this->setup_groups();
     $this->setup_sortitemid();
 }