$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')));
// 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');
$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;
}
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'),
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);
* 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
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;