mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-47011 core_grade: added ability to un-override grade_item weight
This commit is contained in:
parent
f8259c2fbf
commit
64b03e5bd7
@ -132,7 +132,7 @@ if ($mform->is_cancelled()) {
|
||||
unset($data->locked);
|
||||
unset($data->locktime);
|
||||
|
||||
$convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef');
|
||||
$convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef', 'aggregationcoef2');
|
||||
foreach ($convert as $param) {
|
||||
if (property_exists($data, $param)) {
|
||||
$data->$param = unformat_float($data->$param);
|
||||
@ -148,6 +148,16 @@ if ($mform->is_cancelled()) {
|
||||
$grade_item->decimals = null;
|
||||
}
|
||||
|
||||
// Change weightoverride flag.
|
||||
if (!isset($data->weightoverride)) {
|
||||
$data->weightoverride = 0; // Checkbox unticked.
|
||||
}
|
||||
// If we are using natural weight and the weight has been un-overriden, force parent category to recalculate weights.
|
||||
if ($grade_item->weightoverride != $data->weightoverride && $parent_category->aggregation == GRADE_AGGREGATE_SUM) {
|
||||
$parent_category->force_regrading();
|
||||
}
|
||||
$grade_item->weightoverride = $data->weightoverride;
|
||||
|
||||
if (empty($grade_item->id)) {
|
||||
$grade_item->itemtype = 'manual'; // all new items to be manual only
|
||||
$grade_item->insert();
|
||||
|
@ -97,6 +97,14 @@ class edit_item_form extends moodleform {
|
||||
$mform->setType('grademin', PARAM_RAW);
|
||||
}
|
||||
|
||||
$mform->addElement('checkbox', 'weightoverride', get_string('adjustedweight', 'grades'));
|
||||
$mform->addHelpButton('weightoverride', 'weightoverride', 'grades');
|
||||
|
||||
$mform->addElement('text', 'aggregationcoef2', get_string('weight', 'grades'));
|
||||
$mform->addHelpButton('aggregationcoef2', 'weight', 'grades');
|
||||
$mform->setType('aggregationcoef2', PARAM_RAW);
|
||||
$mform->hardFreeze('aggregationcoef2');
|
||||
|
||||
$mform->addElement('text', 'gradepass', get_string('gradepass', 'grades'));
|
||||
$mform->addHelpButton('gradepass', 'gradepass', 'grades');
|
||||
$mform->disabledIf('gradepass', 'gradetype', 'eq', GRADE_TYPE_NONE);
|
||||
@ -295,6 +303,17 @@ class edit_item_form extends moodleform {
|
||||
$mform->disabledIf('aggregationcoef', 'parentcategory', 'eq', $parent_category->id);
|
||||
}
|
||||
|
||||
// Remove fields used by natural weighting if the parent category is not using natural weighting.
|
||||
if ($parent_category->aggregation != GRADE_AGGREGATE_SUM) {
|
||||
print_object('removing');
|
||||
if ($mform->elementExists('weightoverride')) {
|
||||
$mform->removeElement('weightoverride');
|
||||
}
|
||||
if ($mform->elementExists('aggregationcoef2')) {
|
||||
$mform->removeElement('aggregationcoef2');
|
||||
}
|
||||
}
|
||||
|
||||
if ($category = $grade_item->get_item_category()) {
|
||||
if ($category->aggregation == GRADE_AGGREGATE_SUM) {
|
||||
if ($mform->elementExists('gradetype')) {
|
||||
|
@ -35,6 +35,7 @@ $string['addoutcome'] = 'Add an outcome';
|
||||
$string['addoutcomeitem'] = 'Add outcome item';
|
||||
$string['addscale'] = 'Add a scale';
|
||||
$string['adjusted'] = 'Adjusted';
|
||||
$string['adjustedweight'] = 'Weight adjusted';
|
||||
$string['aggregateextracreditmean'] = 'Mean of grades (with extra credits)';
|
||||
$string['aggregatemax'] = 'Highest grade';
|
||||
$string['aggregatemean'] = 'Mean of grades';
|
||||
@ -711,9 +712,12 @@ $string['viewbygroup'] = 'Group';
|
||||
$string['viewgrades'] = 'View grades';
|
||||
$string['warningexcludedsum'] = 'Warning: excluding of grades is not compatible with sum aggregation.';
|
||||
$string['weight'] = 'weight';
|
||||
$string['weight_help'] = 'A value used to determine the relative value of multiple grade items in a category or course.';
|
||||
$string['weightcourse'] = 'Use weighted grades for course';
|
||||
$string['weightedascending'] = 'Sort by weighted percent ascending';
|
||||
$string['weighteddescending'] = 'Sort by weighted percent descending';
|
||||
$string['weightoverride'] = 'weight adjustment';
|
||||
$string['weightoverride_help'] = 'Uncheck this to reset a grade item weight to its automatically calculated value. Checking this will prevent the weight being automatically adjusted.';
|
||||
$string['weightedpct'] = 'weighted %';
|
||||
$string['weightedpctcontribution'] = 'weighted % contribution';
|
||||
$string['weightorextracredit'] = 'Weight or extra credit';
|
||||
|
@ -1031,7 +1031,6 @@ class grade_category extends grade_object {
|
||||
|
||||
/**
|
||||
* Recalculate the weights of the grade items in this category.
|
||||
* THIS DOES NOT TAKE INTO ACCOUNT HIDDEN ACTIVITIES, GROUPS.
|
||||
*/
|
||||
private function auto_update_weights() {
|
||||
if ($this->aggregation != GRADE_AGGREGATE_SUM) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user