MDL-9889 Fixed a couple of bugs that were only detected by PHP5. Nothing major at all.

This commit is contained in:
nicolasconnault 2007-05-24 02:08:20 +00:00
parent 11bf5b8301
commit a15428a2f6
3 changed files with 10 additions and 5 deletions

View File

@ -653,7 +653,8 @@ class grade_category extends grade_object {
return null;
}
}
return get_class($this->children[0]);
reset($this->children);
return get_class(current($this->children));
}
/**

View File

@ -555,7 +555,8 @@ class grade_item extends grade_object {
$final_grade->itemid = $this->id;
$final_grade->userid = $raw_grade->userid;
if ($final_grade->gradevalue > $this->grademax) {
die("FINAL GRADE EXCEEDED grademax FIRST");
debugging("FINAL GRADE EXCEEDED grademax FIRST");
return false;
}
$success = $success & $final_grade->insert();
$this->grade_grades_final[$final_grade->userid] = $final_grade;
@ -577,6 +578,9 @@ class grade_item extends grade_object {
if (empty($grade_calculation)) { // There is no calculation in DB
return false;
} elseif (empty($this->calculation) || !is_object($this->calculation)) { // The calculation isn't yet loaded
$this->calculation = $grade_calculation;
return $grade_calculation;
} elseif ($grade_calculation->calculation != $this->calculation->calculation) { // The object's calculation is not in sync with the DB (new value??)
$this->calculation = $grade_calculation;
return $grade_calculation;

View File

@ -162,12 +162,12 @@ class grade_tree {
* @return string Type
*/
function get_element_type($element) {
if (!empty($element->element['object'])) {
if (is_object($element)) {
$object = $element;
} elseif (!empty($element->element['object'])) {
$object = $element->element['object'];
} elseif (!empty($element['object'])) {
$object = $element['object'];
} elseif (is_object($element)) {
$object = $element;
} else {
debugging("Invalid element given to grade_tree::get_element_type.");
return false;