MDL-13674 Course category fullname field is no longer required. If set to empty it will be recorded in the DB as ?, and the course name will be used instead wherever the category name is displayed. Merging from MOODLE_19_STABLE.
This commit is contained in:
@@ -75,6 +75,11 @@ if ($mform->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
|
||||
} else if ($data = $mform->get_data(false)) {
|
||||
// If no fullname is entered for a course category, put ? in the DB
|
||||
if (!isset($data->fullname) || $data->fullname == '') {
|
||||
$data->fullname = '?';
|
||||
}
|
||||
|
||||
if (!isset($data->aggregateonlygraded)) {
|
||||
$data->aggregateonlygraded = 0;
|
||||
}
|
||||
|
||||
@@ -266,6 +266,18 @@ class edit_category_form extends moodleform {
|
||||
$mform->removeElement('aggregatesubcats');
|
||||
}
|
||||
}
|
||||
|
||||
// If it is a course category, remove the "required" rule from the "fullname" element
|
||||
if ($grade_category->is_course_category()) {
|
||||
unset($mform->_rules['fullname']);
|
||||
$key = array_search('fullname', $mform->_required);
|
||||
unset($mform->_required[$key]);
|
||||
}
|
||||
|
||||
// If it is a course category and its fullname is ?, show an empty field
|
||||
if ($grade_category->is_course_category() && $mform->getElementValue('fullname') == '?') {
|
||||
$mform->setDefault('fullname', '');
|
||||
}
|
||||
}
|
||||
|
||||
// no parent header for course category
|
||||
@@ -273,8 +285,7 @@ class edit_category_form extends moodleform {
|
||||
$mform->removeElement('headerparent');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -129,7 +129,7 @@ function upgrade_18_gradebook($courseid) {
|
||||
// create course category
|
||||
$course_category = new object();
|
||||
$course_category->courseid = $courseid;
|
||||
$course_category->fullname = get_string('coursegradecategory', 'grades');
|
||||
$course_category->fullname = '?';
|
||||
$course_category->parent = null;
|
||||
$course_category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2;
|
||||
$course_category->timemodified = $course_category->timecreated = time();
|
||||
|
||||
@@ -315,7 +315,7 @@ class grade_category extends grade_object {
|
||||
*/
|
||||
function insert_course_category($courseid) {
|
||||
$this->courseid = $courseid;
|
||||
$this->fullname = get_string('coursegradecategory', 'grades');
|
||||
$this->fullname = '?';
|
||||
$this->path = null;
|
||||
$this->parent = null;
|
||||
$this->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2;
|
||||
@@ -995,7 +995,8 @@ class grade_category extends grade_object {
|
||||
* @return string name
|
||||
*/
|
||||
function get_name() {
|
||||
if (empty($this->parent)) {
|
||||
// For a course category, we return the course name if the fullname is set to '?' in the DB (empty in the category edit form)
|
||||
if (empty($this->parent) && $this->fullname == '?') {
|
||||
$course = get_record('course', 'id', $this->courseid);
|
||||
return format_string($course->fullname);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user