]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9506 Added grade_grades_text object to grade_grades_final and raw objects.
authornicolasconnault <nicolasconnault>
Wed, 9 May 2007 08:10:27 +0000 (08:10 +0000)
committernicolasconnault <nicolasconnault>
Wed, 9 May 2007 08:10:27 +0000 (08:10 +0000)
lib/grade/grade_grades_final.php
lib/grade/grade_grades_raw.php
lib/grade/grade_grades_text.php

index 64d3a5272037356a8ba137a828137e3d4df35e79..16a57394017e410d59e9a15fbc8fa13bed60f758 100644 (file)
@@ -96,9 +96,14 @@ class grade_grades_final extends grade_object {
     }
 
     /**
-     * 
-    function get_text() {
-
+     * Loads the grade_grades_text object linked to this grade (through the intersection of itemid and userid), and
+     * saves it as a class variable for this final object.
+     * @return object
+     */
+    function load_text() {
+        if (empty($this->grade_grades_text)) {
+            return $this->grade_grades_text = grade_grades_text::fetch('itemid', $this->itemid, 'userid', $this->userid);
+        } 
     }
 
     /**
index 3294e98e38bbb3a543f2f2600cf8ed55a38688b7..eeceef3e32d9227433761e1c95d7eb88c0d0be34 100644 (file)
@@ -91,9 +91,9 @@ class grade_grades_raw extends grade_object {
      * Additional textual information about this grade. It can be automatically generated 
      * from the module or entered manually by the teacher. This is kept in its own table
      * for efficiency reasons, so it is encapsulated in its own object, and included in this raw grade object.
-     * @var object $text
+     * @var object $grade_grades_text
      */
-    var $text;
+    var $grade_grades_text;
 
     /**
      * Constructor. Extends the basic functionality defined in grade_object.
@@ -118,14 +118,14 @@ class grade_grades_raw extends grade_object {
     }
     
     /**
-     * Loads the grade_grades_text object linked to this raw grade, into the $this->text variable, if 
-     * such record exists. Otherwise returns null.
+     * Loads the grade_grades_text object linked to this grade (through the intersection of itemid and userid), and
+     * saves it as a class variable for this final object.
+     * @return object
      */
     function load_text() {
-        if (!empty($this->id)) {
-            $this->text = grade_grades_text::fetch('gradesid', $this->id);
-        }
-        return $this->text;
+        if (empty($this->grade_grades_text)) {
+            return $this->grade_grades_text = grade_grades_text::fetch('itemid', $this->itemid, 'userid', $this->userid);
+        } 
     }
 
     /**
index f2e7a9d73db8bcc0043a43057f5b172f05550d7d..9a28bd5bc156d144550586def74235697b2bdf9e 100644 (file)
@@ -94,7 +94,6 @@ class grade_grades_text extends grade_object {
     function fetch($field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields="*") { 
         if ($grade_text = get_record('grade_grades_text', $field1, $value1, $field2, $value2, $field3, $value3, $fields)) {
             if (isset($this) && get_class($this) == 'grade_grades_text') {
-                print_object($this);
                 foreach ($grade_text as $param => $value) {
                     $this->$param = $value;
                 }