MDL-19091 removed custom scales from different courses + added BC hack; backported from MOODLE_19_STABLE

This commit is contained in:
skodak
2009-05-07 08:39:29 +00:00
parent 28087eb710
commit d9be236f5d
5 changed files with 41 additions and 14 deletions
+1 -2
View File
@@ -44,7 +44,6 @@ $gpr = new grade_plugin_return();
$returnurl = $gpr->get_return_url('index.php?id='.$course->id);
$mform = new edit_category_form(null, array('gpr'=>$gpr));
$heading = get_string('categoryedit', 'grades');
if ($id) {
@@ -75,7 +74,7 @@ if ($id) {
$category = $grade_category->get_record_data();
}
$mform->set_data($category);
$mform = new edit_category_form(null, array('current'=>$category, 'gpr'=>$gpr));
if ($mform->is_cancelled()) {
redirect($returnurl);
+17 -2
View File
@@ -33,6 +33,8 @@ class edit_category_form extends moodleform {
global $CFG, $COURSE, $DB;
$mform =& $this->_form;
$category = $this->_customdata['current'];
$this->aggregation_options = array(GRADE_AGGREGATE_MEAN =>get_string('aggregatemean', 'grades'),
GRADE_AGGREGATE_WEIGHTED_MEAN =>get_string('aggregateweightedmean', 'grades'),
GRADE_AGGREGATE_WEIGHTED_MEAN2 =>get_string('aggregateweightedmean2', 'grades'),
@@ -128,9 +130,20 @@ class edit_category_form extends moodleform {
//$mform->disabledIf('calculation', 'gradetype', 'eq', GRADE_TYPE_NONE);
$options = array(0=>get_string('usenoscale', 'grades'));
if ($scales = $DB->get_records('scale')) {
if ($scales = grade_scale::fetch_all_local($COURSE->id)) {
foreach ($scales as $scale) {
$options[$scale->id] = format_string($scale->name);
$options[$scale->id] = $scale->get_name();
}
}
if ($scales = grade_scale::fetch_all_global()) {
foreach ($scales as $scale) {
$options[$scale->id] = $scale->get_name();
}
}
// ugly BC hack - it was possbile to use custom scale from other courses :-(
if (!empty($category->grade_item_scaleid) and !isset($options[$category->grade_item_scaleid])) {
if ($scale = grade_scale::fetch(array('id'=>$category->grade_item_scaleid))) {
$options[$scale->id] = $scale->get_name().' '.get_string('incorrectcustomscale', 'grades');
}
}
$mform->addElement('select', 'grade_item_scaleid', get_string('scale'), $options);
@@ -239,6 +252,8 @@ class edit_category_form extends moodleform {
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
//-------------------------------------------------------------------------------
$this->set_data($category);
}
+5 -8
View File
@@ -43,12 +43,6 @@ require_capability('moodle/grade:manage', $context);
$gpr = new grade_plugin_return();
$returnurl = $gpr->get_return_url('index.php?id='.$course->id);
$mform = new edit_item_form(null, array('gpr'=>$gpr));
if ($mform->is_cancelled()) {
redirect($returnurl);
}
$heading = get_string('itemsedit', 'grades');
if ($grade_item = grade_item::fetch(array('id'=>$id, 'courseid'=>$courseid))) {
@@ -97,9 +91,12 @@ if ($parent_category->aggregation == GRADE_AGGREGATE_SUM or $parent_category->ag
$item->aggregationcoef = format_float($item->aggregationcoef, 4);
}
$mform->set_data($item);
$mform = new edit_item_form(null, array('current'=>$item, 'gpr'=>$gpr));
if ($data = $mform->get_data()) {
if ($mform->is_cancelled()) {
redirect($returnurl);
} else if ($data = $mform->get_data(false)) {
if (!isset($data->aggregationcoef)) {
$data->aggregationcoef = 0;
+17 -2
View File
@@ -33,6 +33,8 @@ class edit_item_form extends moodleform {
$mform =& $this->_form;
$item = $this->_customdata['current'];
/// visible elements
$mform->addElement('header', 'general', get_string('gradeitem', 'grades'));
@@ -57,9 +59,20 @@ class edit_item_form extends moodleform {
//$mform->disabledIf('calculation', 'gradetype', 'eq', GRADE_TYPE_NONE);
$options = array(0=>get_string('usenoscale', 'grades'));
if ($scales = $DB->get_records('scale')) {
if ($scales = grade_scale::fetch_all_local($COURSE->id)) {
foreach ($scales as $scale) {
$options[$scale->id] = format_string($scale->name);
$options[$scale->id] = $scale->get_name();
}
}
if ($scales = grade_scale::fetch_all_global()) {
foreach ($scales as $scale) {
$options[$scale->id] = $scale->get_name();
}
}
// ugly BC hack - it was possbile to use custom scale from other courses :-(
if (!empty($item->scaleid) and !isset($options[$item->scaleid])) {
if ($scale = grade_scale::fetch(array('id'=>$item->scaleid))) {
$options[$scale->id] = $scale->get_name().get_string('incorrectcustomscale', 'grades');
}
}
$mform->addElement('select', 'scaleid', get_string('scale'), $options);
@@ -184,6 +197,8 @@ class edit_item_form extends moodleform {
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
//-------------------------------------------------------------------------------
$this->set_data($item);
}
+1
View File
@@ -310,6 +310,7 @@ $string['importsuccess'] = 'Grade import success';
$string['importxml'] = 'Import XML';
$string['includescalesinaggregation'] = 'Include scales in aggregation';
$string['incorrectcourseid'] = 'Course ID was incorrect';
$string['incorrectcustomscale'] = '(Incorrect custom scale, please change.)';
$string['incorrectminmax'] = 'The minimum must be lower than the maximum';
$string['inherit'] = 'Inherit';
$string['intersectioninfo'] = 'Student/Grade info';