$category = $grade_category->get_record_data();
// Get Category preferences
$category->pref_aggregationview = grade_report::get_pref('aggregationview', $id);
-
+//GVA Patch
+ $grade_item = $grade_category->load_grade_item();
+ $category->aggregationcoef = $grade_item->aggregationcoef;
+//End Patch
} else {
$grade_category = new grade_category();
$grade_category->courseid = $course->id;
error("Could not set preference aggregationview to $value for this grade category");
}
}
+//GVA Patch
+
+ if (isset($data->weightcourse)) {
+ global $COURSE;
+ $course_category = grade_category::fetch_course_category($COURSE->id);
+ $course_category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN;
+ $course_category->update();
+ }
+
+ if (!isset($grade_item)) {
+ $grade_item = $grade_category->load_grade_item();
+ }
+ if (isset($data->aggregationcoef)){
+ $data_item->aggregationcoef = $data->aggregationcoef;
+ grade_item::set_properties($grade_item, $data_item);
+ $grade_item->update();
+ }
+//End Patch
redirect($returnurl);
}
$mform->addElement('select', 'aggregation', get_string('aggregation', 'grades'), $options);
$mform->setHelpButton('aggregation', array('aggregation', get_string('aggregation', 'grades'), 'grade'));
+//GVA Patch
+ $mform->addElement('checkbox', 'weightcourse', 'Weight grades for course'); //To Do Localize
+ $mform->addElement('text', 'aggregationcoef', get_string('aggregationcoefweight', 'grades'));
+ $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoefweight', 'grades'),
+ false, true, false, get_string('aggregationcoefweighthelp', 'grades')));
+ $mform->disabledIf('aggregationcoef', 'weightcourse', 'notchecked');
+//End Patch
+
$mform->addElement('checkbox', 'aggregateonlygraded', get_string('aggregateonlygraded', 'grades'));
$mform->setHelpButton('aggregateonlygraded', array(false, get_string('aggregateonlygraded', 'grades'),
false, true, false, get_string('aggregateonlygradedhelp', 'grades')));
/// tweak the form - depending on existing data
function definition_after_data() {
- global $CFG;
+ global $CFG, $COURSE;
$mform =& $this->_form;
$mform->removeElement('droplow');
}
}
+
+//GVA Patch
+ if (!$id = $mform->getElementValue('id')) {
+ $mform->setDefault('aggregateonlygraded',1);
+ $parent_category = grade_category::fetch_course_category($COURSE->id);
+ if ($parent_category->is_aggregationcoef_used()) {
+ if ($mform->elementExists('weightcourse')) {
+ $mform->removeElement('weightcourse');
+ }
+ }
+ }
+//End Patch
if ($id = $mform->getElementValue('id')) {
$grade_category = grade_category::fetch(array('id'=>$id));
$grade_item = $grade_category->load_grade_item();
+//GVA Patch
+ $category = $grade_item->get_item_category();
+ if(!$category->aggregateonlygraded) {
+ $mform->setAdvanced('aggregateonlygraded', false);
+ }
+ if ($grade_item->is_course_item()) { //An actual course, not a category, etc.
+
+ if ($mform->elementExists('aggregationcoef')) {
+ $mform->removeElement('aggregationcoef');
+ }
+ if ($mform->elementExists('weightcourse')) {
+ $mform->removeElement('weightcourse');
+ }
+ }
+
+ if (!$grade_item->is_category_item()) {
+ if ($mform->elementExists('weightcourse')) {
+ $mform->removeElement('weightcourse');
+ }
+ } else {
+ $category = $grade_item->get_item_category();
+ $parent_category = $category->get_parent_category();
+ if ($parent_category->is_aggregationcoef_used()) {
+ if ($mform->elementExists('weightcourse')) {
+ $mform->removeElement('weightcourse');
+ }
+ }
+ }
+//End Patch
if ($grade_item->is_calculated()) {
// following elements are ignored when calculation formula used
if ($mform->elementExists('aggregation')) {