/** * 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(); }
function fill_parents(&$parents, &$items, $element, $idnumber, $accuratetotals = false, $alltotals = true) { foreach ($element['children'] as $sortorder => $child) { switch ($child['type']) { case 'courseitem': case 'categoryitem': continue 2; case 'category': $childid = $child['object']->grade_item->id; break; default: $childid = substr($child['eid'], 1, 8); } if (!isset($parents[$childid]) && isset($element['type']) && $element['type'] != 'courseitem') { $parents[$childid]->id = $idnumber; $parents[$childid]->agg = $element['object']->aggregation; } if (!empty($child['children'])) { fill_parents($parents, $items, $child, $childid, $accuratetotals, $alltotals); } // accumulate max scores for parent // if ($accuratetotals && $alltotals) { if (isset($accuratetotals) && $accuratetotals && isset($alltotals) && $alltotals && (isset($items[$childid]->aggregationcoef) && $items[$childid]->aggregationcoef != 1 || isset($parents[$childid]->agg) && $parents[$childid]->agg == GRADE_AGGREGATE_WEIGHTED_MEAN)) { $items[$idnumber]->max_earnable += isset($items[$childid]->max_earnable) ? $items[$childid]->max_earnable : $items[$childid]->grademax; } } return; }