mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 04:33:13 +01:00
MDL-11495 removed GRADE_DECIMALS_DEFAULT null constant, is_null() used instead for tests, -1 used in menu options
This commit is contained in:
parent
34d6a78987
commit
dafbc521ba
@ -27,7 +27,7 @@ class edit_grade_display_form extends moodleform {
|
||||
$mform->setDefault('display', $coursegradedisplaytype);
|
||||
$mform->setType($coursegradedisplaytype, PARAM_INT);
|
||||
|
||||
$options = array(GRADE_DECIMALS_DEFAULT => get_string('default', 'grades'), 0, 1, 2, 3, 4, 5);
|
||||
$options = array(-1=>get_string('default', 'grades'), 0, 1, 2, 3, 4, 5);
|
||||
$label = get_string('decimalpoints', 'grades') . ' (' . get_string('default', 'grades') . ': ' . $options[$CFG->grade_report_decimalpoints] . ')';
|
||||
$mform->addElement('select', 'decimals', $label, $options);
|
||||
$mform->setHelpButton('decimals', array(false, get_string('decimalpoints', 'grades'), false, true, false, get_string("configdecimalpoints", 'grades')));
|
||||
|
@ -57,7 +57,7 @@ if ($mform->is_cancelled()) {
|
||||
|
||||
// Update course item's decimals type
|
||||
if (isset($data->decimals)) {
|
||||
if (strlen($data->decimals) < 1) {
|
||||
if ($data->decimals < 0) {
|
||||
$data->decimals = null;
|
||||
}
|
||||
set_field('grade_items', 'decimals', $data->decimals, 'courseid', $courseid, 'itemtype', 'course');
|
||||
|
@ -83,7 +83,7 @@ if ($data = $mform->get_data(false)) {
|
||||
$grade_item->outcomeid = null;
|
||||
|
||||
// Handle null decimals value
|
||||
if (strlen($data->decimals) < 1) {
|
||||
if (!array_key_exists('decimals', $data) or $data->decimals < 0) {
|
||||
$grade_item->decimals = null;
|
||||
}
|
||||
|
||||
|
@ -98,14 +98,11 @@ class edit_item_form extends moodleform {
|
||||
false, true, false, get_string("configgradedisplaytype", 'grades')));
|
||||
|
||||
// Determine default value for decimalpoints (site or course)
|
||||
$course_gradedecimals = get_field('grade_items', 'decimals', 'courseid', $COURSE->id, 'itemtype', 'course');
|
||||
$site_gradedecimals = $CFG->grade_report_decimalpoints;
|
||||
$default_gradedecimals = $course_gradedecimals;
|
||||
|
||||
if ($course_gradedecimals == GRADE_DECIMALS_DEFAULT) {
|
||||
$default_gradedecimals = $site_gradedecimals;
|
||||
$default_gradedecimals = get_field('grade_items', 'decimals', 'courseid', $COURSE->id, 'itemtype', 'course');
|
||||
if (is_null($default_gradedecimals)) {
|
||||
$default_gradedecimals = $CFG->grade_report_decimalpoints;
|
||||
}
|
||||
$options = array(GRADE_DECIMALS_DEFAULT => get_string('default', 'grades'), 0, 1, 2, 3, 4, 5);
|
||||
$options = array(-1=>get_string('default', 'grades'), 0, 1, 2, 3, 4, 5);
|
||||
$label = get_string('decimalpoints', 'grades') . ' (' . get_string('default', 'grades') . ': ' . $options[$default_gradedecimals] . ')';
|
||||
$mform->addElement('select', 'decimals', $label, $options);
|
||||
$mform->setHelpButton('decimals', array(false, get_string('decimalpoints', 'grades'),
|
||||
|
@ -64,7 +64,6 @@ define('GRADE_DISPLAY_TYPE_DEFAULT', 0);
|
||||
define('GRADE_DISPLAY_TYPE_REAL', 1);
|
||||
define('GRADE_DISPLAY_TYPE_PERCENTAGE', 2);
|
||||
define('GRADE_DISPLAY_TYPE_LETTER', 3);
|
||||
define('GRADE_DECIMALS_DEFAULT', null);
|
||||
|
||||
define('GRADE_REPORT_AGGREGATION_POSITION_LEFT', 0);
|
||||
define('GRADE_REPORT_AGGREGATION_POSITION_RIGHT', 1);
|
||||
|
@ -212,7 +212,7 @@ class grade_item extends grade_object {
|
||||
* The number of digits after the decimal point symbol. Applies only to REAL and PERCENTAGE grade display types.
|
||||
* @var int $decimals
|
||||
*/
|
||||
var $decimals = GRADE_DECIMALS_DEFAULT;
|
||||
var $decimals = null;
|
||||
|
||||
/**
|
||||
* 0 if visible, 1 always hidden or date not visible until
|
||||
@ -1722,14 +1722,14 @@ class grade_item extends grade_object {
|
||||
global $CFG;
|
||||
static $cache = array();
|
||||
|
||||
if ($this->decimals == GRADE_DECIMALS_DEFAULT) {
|
||||
if (is_null($this->decimals)) {
|
||||
if (array_key_exists($this->courseid, $cache)) {
|
||||
return $cache[$this->courseid];
|
||||
} else if (count($cache) > 100) {
|
||||
$cache = array(); // cache size limit
|
||||
}
|
||||
$gradedecimals = get_field('grade_items', 'decimals', 'courseid', $this->courseid, 'itemtype', 'course');
|
||||
if ($gradedecimals == GRADE_DECIMALS_DEFAULT) {
|
||||
if (is_null($gradedecimals)) {
|
||||
$gradedecimals = $CFG->grade_report_decimalpoints;
|
||||
}
|
||||
$cache[$this->courseid] = $gradedecimals;
|
||||
|
Loading…
x
Reference in New Issue
Block a user