mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
grade category edit form improved, fixed aggregation
This commit is contained in:
parent
854386bc04
commit
d5fab31f08
@ -9,7 +9,25 @@ class edit_category_form extends moodleform {
|
||||
// visible elements
|
||||
$mform->addElement('text', 'fullname', get_string('categoryname', 'grades'));
|
||||
|
||||
//TODO: add other elements
|
||||
$options = array(GRADE_AGGREGATE_MEAN_ALL =>get_string('aggregatemeanall', 'grades'),
|
||||
GRADE_AGGREGATE_MEDIAN =>get_string('aggregatemedian', 'grades'),
|
||||
GRADE_AGGREGATE_MEAN_GRADED=>get_string('aggregatemeangraded', 'grades'),
|
||||
GRADE_AGGREGATE_MIN =>get_string('aggregatemin', 'grades'),
|
||||
GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'),
|
||||
GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'));
|
||||
$mform->addElement('select', 'aggregation', get_string('aggregation', 'grades'), $options);
|
||||
$mform->setDefault('gradetype', GRADE_AGGREGATE_MEAN_ALL);
|
||||
|
||||
$options = array();
|
||||
$options[0] = get_string('none');
|
||||
for ($i=1; $i<=20; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$mform->addElement('select', 'keephigh', get_string('keephigh', 'grades'), $options);
|
||||
$mform->disabledIf('keephigh', 'droplow', 'noteq', 0);
|
||||
|
||||
$mform->addElement('select', 'droplow', get_string('droplow', 'grades'), $options);
|
||||
$mform->disabledIf('droplow', 'keephigh', 'noteq', 0);
|
||||
|
||||
// hidden params
|
||||
$mform->addElement('hidden', 'id', 0);
|
||||
@ -22,6 +40,27 @@ class edit_category_form extends moodleform {
|
||||
// buttons
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
|
||||
|
||||
/// tweak the form - depending on existing data
|
||||
function definition_after_data() {
|
||||
global $CFG;
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
if ($id = $mform->getElementValue('id')) {
|
||||
$grade_category = grade_category::fetch(array('id'=>$id));
|
||||
$grade_item = $grade_category->load_grade_item();
|
||||
|
||||
if ($grade_item->is_calculated()) {
|
||||
// following elements are ignored when calculation formula used
|
||||
$mform->removeElement('aggregation');
|
||||
$mform->removeElement('keephigh');
|
||||
$mform->removeElement('droplow');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -482,6 +482,7 @@ class grade_category extends grade_object {
|
||||
$modes = array_keys($freq, $top); // search for all modes (have the same highest count)
|
||||
rsort($modes, SORT_NUMERIC); // get highes mode
|
||||
$rawgrade = reset($modes);
|
||||
break;
|
||||
|
||||
case GRADE_AGGREGATE_MEAN_GRADED: // Arithmetic average of all final grades, unfinished are not calculated
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user