MDL-19015 removed category item editing from normal item edit form
This commit is contained in:
+10
-15
@@ -57,19 +57,16 @@ if ($grade_item = grade_item::fetch(array('id'=>$id, 'courseid'=>$courseid))) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/outcomeitem.php?id='.$id.'&courseid='.$courseid;
|
||||
redirect($gpr->add_url_params($url));
|
||||
}
|
||||
$item = $grade_item->get_record_data();
|
||||
|
||||
if ($grade_item->is_course_item()) {
|
||||
$parent_category = null;
|
||||
$item->parentcategory = 0;
|
||||
} else if ($grade_item->is_category_item()) {
|
||||
$parent_category = $grade_item->get_parent_category();
|
||||
$parent_category = $parent_category->get_parent_category();
|
||||
$item->parentcategory = $parent_category->id;
|
||||
} else {
|
||||
$parent_category = $grade_item->get_parent_category();
|
||||
$item->parentcategory = $parent_category->id;
|
||||
if ($grade_item->is_course_item() or $grade_item->is_category_item()) {
|
||||
$grade_category = $grade_item->get_item_category();
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/category.php?id='.$grade_category->id.'&courseid='.$courseid;
|
||||
redirect($gpr->add_url_params($url));
|
||||
}
|
||||
|
||||
$item = $grade_item->get_record_data();
|
||||
$parent_category = $grade_item->get_parent_category();
|
||||
$item->parentcategory = $parent_category->id;
|
||||
|
||||
} else {
|
||||
$heading = get_string('newitem', 'grades');
|
||||
$grade_item = new grade_item(array('courseid'=>$courseid, 'itemtype'=>'manual'), false);
|
||||
@@ -94,9 +91,7 @@ $item->gradepass = format_float($item->gradepass, $decimalpoints);
|
||||
$item->multfactor = format_float($item->multfactor, 4);
|
||||
$item->plusfactor = format_float($item->plusfactor, 4);
|
||||
|
||||
if (empty($parent_category)) {
|
||||
$item->aggregationcoef = 0;
|
||||
} else if ($parent_category->aggregation == GRADE_AGGREGATE_SUM or $parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN2) {
|
||||
if ($parent_category->aggregation == GRADE_AGGREGATE_SUM or $parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN2) {
|
||||
$item->aggregationcoef = $item->aggregationcoef == 0 ? 0 : 1;
|
||||
} else {
|
||||
$item->aggregationcoef = format_float($item->aggregationcoef, 4);
|
||||
|
||||
@@ -146,17 +146,12 @@ class edit_item_form extends moodleform {
|
||||
$mform->addElement('header', 'headerparent', get_string('parentcategory', 'grades'));
|
||||
|
||||
$options = array();
|
||||
$default = '';
|
||||
$coefstring = '';
|
||||
$categories = grade_category::fetch_all(array('courseid'=>$COURSE->id));
|
||||
|
||||
foreach ($categories as $cat) {
|
||||
$cat->apply_forced_settings();
|
||||
$options[$cat->id] = $cat->get_name();
|
||||
|
||||
if ($cat->is_course_category()) {
|
||||
$default = $cat->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($categories) > 1) {
|
||||
@@ -223,60 +218,38 @@ class edit_item_form extends moodleform {
|
||||
}
|
||||
}
|
||||
|
||||
//remove the aggregation coef element if not needed
|
||||
if ($grade_item->is_course_item()) {
|
||||
if ($mform->elementExists('parentcategory')) {
|
||||
$mform->removeElement('parentcategory');
|
||||
}
|
||||
// if we wanted to change parent of existing item - we would have to verify there are no circular references in parents!!!
|
||||
if ($mform->elementExists('parentcategory')) {
|
||||
$mform->hardFreeze('parentcategory');
|
||||
}
|
||||
|
||||
$parent_category = $grade_item->get_parent_category();
|
||||
$parent_category->apply_forced_settings();
|
||||
|
||||
if (!$parent_category->is_aggregationcoef_used()) {
|
||||
if ($mform->elementExists('aggregationcoef')) {
|
||||
$mform->removeElement('aggregationcoef');
|
||||
}
|
||||
|
||||
} else {
|
||||
// if we wanted to change parent of existing item - we would have to verify there are no circular references in parents!!!
|
||||
if ($mform->elementExists('parentcategory')) {
|
||||
$mform->hardFreeze('parentcategory');
|
||||
}
|
||||
$coefstring = $grade_item->get_coefstring();
|
||||
|
||||
if ($grade_item->is_category_item()) {
|
||||
$category = $grade_item->get_item_category();
|
||||
$parent_category = $category->get_parent_category();
|
||||
} else {
|
||||
$parent_category = $grade_item->get_parent_category();
|
||||
}
|
||||
|
||||
$parent_category->apply_forced_settings();
|
||||
|
||||
if (!$parent_category->is_aggregationcoef_used()) {
|
||||
if ($mform->elementExists('aggregationcoef')) {
|
||||
$mform->removeElement('aggregationcoef');
|
||||
}
|
||||
} else {
|
||||
if ($grade_item->is_category_item()) {
|
||||
$parent_category = $parent_category->get_parent_category();
|
||||
$coefstring = $parent_category->get_grade_item()->get_coefstring();
|
||||
if ($coefstring !== '') {
|
||||
if ($coefstring == 'aggregationcoefextrasum') {
|
||||
// advcheckbox is not compatible with disabledIf!
|
||||
$element =& $mform->createElement('checkbox', 'aggregationcoef', get_string($coefstring, 'grades'));
|
||||
} else {
|
||||
$parent_category->apply_forced_settings();
|
||||
$coefstring = $grade_item->get_coefstring();
|
||||
$element =& $mform->createElement('text', 'aggregationcoef', get_string($coefstring, 'grades'));
|
||||
}
|
||||
|
||||
if ($coefstring !== '') {
|
||||
if ($coefstring == 'aggregationcoefextrasum') {
|
||||
// advcheckbox is not compatible with disabledIf!
|
||||
$element =& $mform->createElement('checkbox', 'aggregationcoef', get_string($coefstring, 'grades'));
|
||||
} else {
|
||||
$element =& $mform->createElement('text', 'aggregationcoef', get_string($coefstring, 'grades'));
|
||||
}
|
||||
if ($mform->elementExists('parentcategory')) {
|
||||
$mform->insertElementBefore($element, 'parentcategory');
|
||||
} else {
|
||||
$mform->insertElementBefore($element, 'id');
|
||||
}
|
||||
$mform->setHelpButton('aggregationcoef', array($coefstring, get_string($coefstring, 'grades'), 'grade'), true);
|
||||
if ($mform->elementExists('parentcategory')) {
|
||||
$mform->insertElementBefore($element, 'parentcategory');
|
||||
} else {
|
||||
$mform->insertElementBefore($element, 'id');
|
||||
}
|
||||
|
||||
$mform->disabledIf('aggregationcoef', 'parentcategory', 'eq', $parent_category->id);
|
||||
$mform->setHelpButton('aggregationcoef', array($coefstring, get_string($coefstring, 'grades'), 'grade'), true);
|
||||
}
|
||||
|
||||
$mform->disabledIf('aggregationcoef', 'parentcategory', 'eq', $parent_category->id);
|
||||
}
|
||||
|
||||
if ($category = $grade_item->get_item_category()) {
|
||||
|
||||
Reference in New Issue
Block a user