}
/**
- *
- 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);
+ }
}
/**
* 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.
}
/**
- * 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);
+ }
}
/**
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;
}