MDL-11363 fixing defaults of new optional fields of grade classes - now properly applied when creating new instances too
This commit is contained in:
@@ -1269,9 +1269,7 @@ class grade_item extends grade_object {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$grade = grade_grade::fetch(array('itemid'=>$this->id, 'userid'=>$userid))) {
|
||||
$grade = new grade_grade(array('itemid'=>$this->id, 'userid'=>$userid), false);
|
||||
}
|
||||
$grade = new grade_grade(array('itemid'=>$this->id, 'userid'=>$userid));
|
||||
$grade->grade_item =& $this; // prevent db fetching of this grade_item
|
||||
|
||||
if ($grade->is_locked()) {
|
||||
@@ -1381,9 +1379,7 @@ class grade_item extends grade_object {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$grade = grade_grade::fetch(array('itemid'=>$this->id, 'userid'=>$userid))) {
|
||||
$grade = new grade_grade(array('itemid'=>$this->id, 'userid'=>$userid), false);
|
||||
}
|
||||
$grade = new grade_grade(array('itemid'=>$this->id, 'userid'=>$userid));
|
||||
$grade->grade_item =& $this; // prevent db fetching of this grade_item
|
||||
|
||||
if ($grade->is_locked()) {
|
||||
|
||||
@@ -66,12 +66,20 @@ class grade_object {
|
||||
*/
|
||||
function grade_object($params=NULL, $fetch=true) {
|
||||
if (!empty($params) and (is_array($params) or is_object($params))) {
|
||||
if ($fetch and $data = $this->fetch($params)) {
|
||||
grade_object::set_properties($this, $data);
|
||||
if ($fetch) {
|
||||
if ($data = $this->fetch($params)) {
|
||||
grade_object::set_properties($this, $data);
|
||||
} else {
|
||||
grade_object::set_properties($this, $this->optional_fields);//apply defaults for optional fields
|
||||
grade_object::set_properties($this, $params);
|
||||
}
|
||||
|
||||
} else {
|
||||
grade_object::set_properties($this, $params);
|
||||
}
|
||||
|
||||
} else {
|
||||
grade_object::set_properties($this, $this->optional_fields);//apply defaults for optional fields
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user