$returnurl = $gpr->get_return_url(null); //first make sure we have proper final grades - we need it for locking changes grade_regrade_final_grades($courseid); // get the grading tree object // note: total must be first for moving to work correctly, if you want it last moving code must be rewritten! $gtree = new grade_tree($courseid, false, false); if (empty($eid)) { $element = null; $object = null; } else { if (!($element = $gtree->locate_element($eid))) { error('Incorrect element id!', $returnurl); } $object = $element['object']; } $switch = grade_report::get_pref('aggregationposition'); $strgrades = get_string('grades'); $strgraderreport = get_string('graderreport', 'grades'); $strcategoriesedit = get_string('categoriesedit', 'grades'); $strcategoriesanditems = get_string('categoriesanditems', 'grades'); $navigation = grade_build_nav(__FILE__, $strcategoriesanditems, array('courseid' => $courseid)); $moving = false; switch ($action) { case 'delete': if ($eid) { $confirm = optional_param('confirm', 0, PARAM_BOOL); if ($confirm and confirm_sesskey()) { $object->delete('grade/report/grader/category'); redirect($returnurl); } else { print_header_simple($strgrades . ': ' . $strgraderreport, ': ' . $strcategoriesedit, $navigation, '', '', true, '', navmenu($course));
/** * Given the name of a user preference (without grade_report_ prefix), locally saves then returns * the value of that preference. If the preference has already been fetched before, * the saved value is returned. If the preference is not set at the User level, the $CFG equivalent * is given (site default). * @static (Can be called statically, but then doesn't benefit from caching) * @param string $pref The name of the preference (do not include the grade_report_ prefix) * @param int $objectid An optional itemid or categoryid to check for a more fine-grained preference * @return mixed The value of the preference */ public function get_pref($pref, $objectid = null) { global $CFG; $fullprefname = 'grade_report_' . $pref; $shortprefname = 'grade_' . $pref; $retval = null; if (!isset($this) or get_class($this) != 'grade_report') { if (!empty($objectid)) { $retval = get_user_preferences($fullprefname . $objectid, grade_report::get_pref($pref)); } elseif (isset($CFG->{$fullprefname})) { $retval = get_user_preferences($fullprefname, $CFG->{$fullprefname}); } elseif (isset($CFG->{$shortprefname})) { $retval = get_user_preferences($fullprefname, $CFG->{$shortprefname}); } else { $retval = null; } } else { if (empty($this->prefs[$pref . $objectid])) { if (!empty($objectid)) { $retval = get_user_preferences($fullprefname . $objectid); if (empty($retval)) { // No item pref found, we are returning the global preference $retval = $this->get_pref($pref); $objectid = null; } } else { $retval = get_user_preferences($fullprefname, $CFG->{$fullprefname}); } $this->prefs[$pref . $objectid] = $retval; } else { $retval = $this->prefs[$pref . $objectid]; } } return $retval; }
} require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('moodle/grade:manage', $context); // default return url $gpr = new grade_plugin_return(); $returnurl = $gpr->get_return_url('index.php?id=' . $course->id); $mform = new edit_category_form(null, array('gpr' => $gpr)); if ($id) { if (!($grade_category = grade_category::fetch(array('id' => $id, 'courseid' => $course->id)))) { error('Incorrect category id!'); } $grade_category->apply_forced_settings(); $category = $grade_category->get_record_data(); // Get Category preferences $category->pref_aggregationview = grade_report::get_pref('aggregationview', $id); // Load agg coef $grade_item = $grade_category->load_grade_item(); $category->aggregationcoef = format_float($grade_item->aggregationcoef, 4); // set parent $category->parentcategory = $grade_category->parent; } else { $grade_category = new grade_category(array('courseid' => $courseid), false); $grade_category->apply_default_settings(); $grade_category->apply_forced_settings(); $category = $grade_category->get_record_data(); $category->aggregationcoef = format_float(0, 4); } $mform->set_data($category); if ($mform->is_cancelled()) { redirect($returnurl);